Created
October 23, 2009 22:16
-
-
Save jaderobbins/217222 to your computer and use it in GitHub Desktop.
Rake file for redmine that either 1. fetches new git information or 2. clones a copy of the remote address to the local location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :redmine do | |
namespace :git do | |
task :refresh => :environment do | |
gitFolder = '/path/to/git/repos' | |
Repository.find(:all).each do |r| | |
if r.scm_name == "Git" | |
if r.url =~ /^#{gitFolder}/ | |
puts "------" | |
puts "SCM is set to local, pull from origin" | |
system("cd #{r.url}; git fetch .") | |
else | |
p = r.project.identifier | |
puts "------" | |
puts "SCM is set to a remote address, clone a local copy" | |
system("cd #{gitFolder}; git clone --bare #{r.url} #{p}.git") | |
puts "Local clone ready, set the SCM url to '#{gitFolder}/#{p}.git'" | |
r.url = "#{gitFolder}/#{p}.git" | |
r.save | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment