Howto publish a git repository with ruby as zipfile - ruby-on-rails

I am using OpenProject as project management software and I am not very familiar with ruby and rails, but using the gitolite-plugin works quite well.
I am looking for a solution to provide a link to the OpenProject users where they can directly download the gitolite-hosted repository as a zipfile.
Is that possible ?
I am willing to put pieces of code together, so even partially solutions and hints are welcome.
thx.

Nothing in oliverguenther/openproject-revisions_git would do a :
git bundle (full repo history in one file)
git archive (latest working tree as one zip file)
You would need to extend that plugin in order to expose that feature, implementing a ruby function to call git-archive on the right project, a bit like in this gist:
(extract)
# Runs the `git archive` command to pull your repository out
# into a tar or tar.gz and writes it to a temporary directory
#
# Args:
# * path - path within the repository to archive, defaults to the root
#
# Returns the path to the tar file
def archive(path=nil)
#archive_path = path || ''
create_tmp_directory
#tar_path = "#{#tmp_directory_path}/archive.tar#{#gzip}"
Dir.chdir #path
puts "Archived repository" if run_shell_cmd "git archive --prefix=#{#archive_path}/ #{#branch}:#{#archive_path} -o #{#tar_path}" and #verbose
Dir.chdir #pwd
#tar_path
end

Related

cmake: Download easylogging++ and use sources directly

I would like to download easylogging++ package, extract the content and then directly use easylogging++.h and easylogging++.cc in my sources.
I started with this:
ExternalProject_Add(
easyloggingpp
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/downloads
URL https://github.com/muflihun/easyloggingpp/archive/v9.96.4.tar.gz
INSTALL_COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/external/easyloggingpp && cp src/easyloggingpp-9.96.4/src/* ${CMAKE_CURRENT_BINARY_DIR}/external/easyloggingpp/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/external/easyloggingpp)
set(easylogging ${CMAKE_CURRENT_BINARY_DIR}/external/easyloggingpp/easylogging++.cc)
..
add_dependencies(myproject easyloggingpp)
This creates downloads/ directory in my project, but it's empty and no files appear in external/ directory, even the directory itself is not created.
How can I achieve downloading this package and directly merging its sources with mine? I would like to achieve something similar to bazel's new_http_archive.
It seems that ExternalProject_Add is not for the use case I am trying to implement. It looks like the download is only executed during compilation step, not the configuration step. That's a bummer.
I was able to achieve similar result by coding this manually and it works fairly well:
file(MAKE_DIRECTORY downloads external)
################################################################################
# Easylogging++
################################################################################
if(EXISTS "external/easyloggingpp")
else()
file(MAKE_DIRECTORY external/easyloggingpp)
file(DOWNLOAD
https://github.com/muflihun/easyloggingpp/archive/v9.96.4.zip
downloads/easyloggingpp.zip)
execute_process(COMMAND unzip downloads/easyloggingpp.zip -d downloads)
file(GLOB easyloggingpp_files downloads/easyloggingpp-9.96.4/src/easylogging++.*)
file(COPY ${easyloggingpp_files} DESTINATION external/easyloggingpp)
endif()
include_directories(external/easyloggingpp)
set(easyloggingpp external/easyloggingpp/easylogging++.cc)
This works perfectly fine for me and I adtually understand what is happening during the process. The cool things are that cmake . step doesn't download unless it is necessary.

New at Git .. please give suggesstion

I have MVC project which was already on git or in git whatever i don't know. Than i formatted my PC and than again install Git. but I don't know How actually it works. i gone through many tutorials and blogs but it is not happening.
As my project was already in GIT. so i have .git folder in my Project. and also have .gitignore file.
which have following data:
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
x64/
build/
bld/
[Bb]in/
[Oo]bj/
# Roslyn cache directories
*.ide/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
#NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
#*.pubxml
# NuGet Packages Directory
packages/*
## TODO: If the tool you use requires repositories.config
## uncomment the next line
#!packages/repositories.config
# Enable "build/" folder in the NuGet Packages folder since
# NuGet packages use it for MSBuild targets.
# This line needs to be after the ignore of the build folder
# (and the packages folder if the line above has been uncommented)
!packages/build/
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/Marketplace/DesignTemplates/NC Tourism Beta/extractedfiles/backend/
/Marketplace/DesignTemplates/NC Tourism Beta/prod/backend/
*.bak
*.png
*.db
*.jpg
My project folder resides in F:/MarketPlace/MarketPlace path.
And I written following Commands in GItBash..
Sadhana#Viprak-Sadhana MINGW64 ~
$ cd..
bash: cd..: command not found
Sadhana#Viprak-Sadhana MINGW64 ~
$ git init
Initialized empty Git repository in C:/Users/Sadhana/.git/
Sadhana#Viprak-Sadhana MINGW64 ~ (master)
$ .gitignore
bash: .gitignore: command not found
Sadhana#Viprak-Sadhana MINGW64 ~ (master)
$ cd C:Users/sadhana/.git
Sadhana#Viprak-Sadhana MINGW64 /c/Users/sadhana/.git (GIT_DIR!)
$ git init --bare marketplace.git
Initialized empty Git repository in C:/Users/Sadhana/.git/marketplace.git/
Sadhana#Viprak-Sadhana MINGW64 /c/Users/sadhana/.git (GIT_DIR!)
$ .gitignore
bash: .gitignore: command not found
Now what should i do for my project to be run.
If your .git folder is usable, you should see the name of the branch in git bash upon changing your directory to the folder where .git is located. You should not need to execute the 'git init' command, since this will create a new .git folder. It sounds like what you want to do is recover the existing repository, so we need to determine if your previous .git folder contains anything valuable.
Also, .gitignore is the file where you can specify files that should not be included in changesets.
Try navigating to 'C:Users/sadhana/' and see if git bash picks up on the repository in the .git folder. You'll see the name of the branch if it goes well :)

Running RoR application in Windows, which was developed in Linux

I have a RoR application working in Linux environment. I have to move that to windows environment. When I run
bundle exec rails server
I see this error
There was a Errno::ENOENT while loading omniauth-cas.gemspec:
No such file or directory - git ls-files -- bin/* from
When I opened the files, I saw these lines
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split
In these lines, I can understand that ls-files is a Linux command, which never work in Windows. With what should I replace this statement so that it runs in windows?
Start by figuring out what your current working directory is for your running script.
Add this line at the beginning:
puts Dir.pwd.
This will tell you in which current working directory ruby is running your script. You will most likely see it's not where you assume it is. Then make sure you're specifying pathnames properly for windows. See the docs here how to properly format pathnames for windows:
http://www.ruby-doc.org/core/classes/IO.html
Then either use Dir.chdir to change the working directory to the place where text.txt is, or specify the absolute pathname to the file according to the instructions in the IO docs above. That SHOULD do it...
Adding a 3rd solution which might be the most convenient one if you're putting the text files among your script files:
Dir.chdir(File.dirname(__FILE__))
This will automatically change the current working directory to the same directory as the .rb file that is running the script.

Noob Capistrano question on preserving upload directories

In response to this blog post: http://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/
I have three questions:
Can anyone confirm if the recipe there works?
Where and how do I put that recipe?
I have two folders need to stay across each revisions: /products and /public/images/site_images what recipe should I run to be able to achieve this?
I have near zero experience with Capistrano and all I have been able to do so far was just cap deploy and cap deploy:cold, so a script which I could just copy-paste would be greatly appreciated.
Thank you
Yes, I'm currently using it in my own projects.
You can just append the code at the end of your deploy.rb file
If products is outside the public folder, you can't link it from the public side. Also, public/images is already expected to be checked into your SCM repository
The recipe assumes you want to have a complete new folder available from public side to host the user uploaded documents.
The folder should be excluded from your SCM configuration to prevent accidental commits. You should avoid to use the public/images folder for external uploaded files or you will have many headaches trying to synchronize your development configuration, managed by a SCM, with the public state.
This is how I did it in the end, by manual approach
I hope this will help all the early coders out there:
1. cd to releases to find out folder to synchronize
cd /home/yourapp/rails_apps/main/releases/
2. find the folder to sync, one level above last folder shown with ls
REMEMBER!
With ls, the folder list goes as follows:
folder1    folder5
folder2    folder6
folder3    folder7
folder4    folder8
So in this case, copy from folder7
3. copy the folders
To copy images
rsync -av --stats --progress /home/yourapp/rails_apps/main/releases/20100517183232/public/images/ /home/yourapp/rails_apps/main/current/public/images/
To copy products
rsync -av --stats --progress /home/yourapp/rails_apps/main/releases/20100517183232/products/ /home/yourapp/rails_apps/main/current/products/
Wondering if they could be automated somehow?

git and ASP MVC

Anyone know of good articles for setting up a new project with git and ASP.NET MVC?
Just wondering what to include and ignore and what to do about deployment.
Gitignore
You asked about what to ignore -- here is my default .gitignore for ASP.NET MVC projects:
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo
# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll
!/packages/*/lib/*/*.dll
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
####################
# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/
###############
# Directories #
###############
bin/
obj/
TestResults/
###################
# Web publish log #
###################
*.Publish.xml
#############
# Resharper #
#############
/_ReSharper.*
*.ReSharper.*
############
# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
######################
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
Setting up a new project
For help on setting up a new project, I would install msysgit since you're most likely on Windows and check out learn.github to learn about getting started with git.
Of course, the master (Skeet) suggests you do most everything from the console -- and I tend to agree with him. Git is just easier that way IMHO. If you'd like a handy git reference, check out the git reference.
Deployments
As somebody else already mentioned -- check out AppHarbor for deployments. Those guys aim to be the 'Heroku of ASP.NET'.
There is a great post on codebetter.com today. It is about OSS projects but I bet it is applicable to you as well because it is describing GIT.
The right part of the article is the link to Kyle's blog and especially Getting Started with Git and GitHub on Windows.
If you're already using git and ASP MVC you should also check out AppHarbor http://appharbor.com/ for deployment and hosting. It integrates right into your workflow.
Corrected link
http://codebetter.com/blogs/aaron.jensen/archive/2009/03/12/hosting-your-oss-project-on-github.aspx
Mine is super simple:
*/packages/*
/packages/*
obj/
bin/
TestResults/
_ReSharper.*
*.csproj.user
*.resharper.user
*.resharper
*.suo
*.cache
*~
*.swp
*.resharper.user
*.rptproj.user
*.db
*.sdf
*.tmp
For the example of gitignore files check github gitignore examples and one for visual studio VisualStudio.gitignore

Resources