Skip to content

Commit

Permalink
Merge pull request #118 from donthorp/rake-git-tasks
Browse files Browse the repository at this point in the history
Add add_team_repos and prune_team_repos tasks to assist in PR handling
  • Loading branch information
fusion94 committed Feb 24, 2013
2 parents 17a3a19 + 802d93e commit 138409d
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions lib/tasks/git.rake
@@ -0,0 +1,61 @@
namespace :git do
require 'fileutils'

IGNORE_REPOS = [
"origin",
"upstream",
]

TEAM_REPOS = {
'donthorp' => 'git@github.com:donthorp/kandan.git',
'gabceb' => 'git://github.com/gabceb/kandan-1.git',
'fusion94' => 'git://github.com/fusion94/kandan.git',
'SpencerCooley' => 'git://github.com/SpencerCooley/kandan.git',
'jrgifford' => 'git://github.com/jrgifford/kandan.git',
}

def get_remotes
remotes = []
o = `git remote`.split("\n")
o.each() do |r|
next if IGNORE_REPOS.include?(r)
remotes << r
end

return remotes
end

def get_user
`git config --get github.user`.chop()
end

def get_team_repos
repos = TEAM_REPOS
repos.delete(get_user())
return repos
end

desc "Add team upstream repos"
task :add_team_repos do

remotes = get_remotes()

get_team_repos().each() do |k,v|
if remotes.include?(k)
puts "Skipping remote for #{k}. Already added."
next
end

sh %{git remote add #{k} #{v}}
end
end

desc "Prune removed branches from remotes"
task :prune_team_repos do
repos = get_team_repos()

repos.each() do |k,v|
sh %{git remote prune #{k}}
end
end
end

0 comments on commit 138409d

Please sign in to comment.