Skip to content

Instantly share code, notes, and snippets.

@jaderobbins
Created October 23, 2009 22:16
Show Gist options
  • Save jaderobbins/217222 to your computer and use it in GitHub Desktop.
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
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