File tree 1 file changed +61
-0
lines changed
1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ namespace :git do
2
+ require 'fileutils'
3
+
4
+ IGNORE_REPOS = [
5
+ "origin" ,
6
+ "upstream" ,
7
+ ]
8
+
9
+ TEAM_REPOS = {
10
+ 'donthorp' => 'git@github.com:donthorp/kandan.git' ,
11
+ 'gabceb' => 'git://github.com/gabceb/kandan-1.git' ,
12
+ 'fusion94' => 'git://github.com/fusion94/kandan.git' ,
13
+ 'SpencerCooley' => 'git://github.com/SpencerCooley/kandan.git' ,
14
+ 'jrgifford' => 'git://github.com/jrgifford/kandan.git' ,
15
+ }
16
+
17
+ def get_remotes
18
+ remotes = [ ]
19
+ o = `git remote` . split ( "\n " )
20
+ o . each ( ) do |r |
21
+ next if IGNORE_REPOS . include? ( r )
22
+ remotes << r
23
+ end
24
+
25
+ return remotes
26
+ end
27
+
28
+ def get_user
29
+ `git config --get github.user` . chop ( )
30
+ end
31
+
32
+ def get_team_repos
33
+ repos = TEAM_REPOS
34
+ repos . delete ( get_user ( ) )
35
+ return repos
36
+ end
37
+
38
+ desc "Add team upstream repos"
39
+ task :add_team_repos do
40
+
41
+ remotes = get_remotes ( )
42
+
43
+ get_team_repos ( ) . each ( ) do |k , v |
44
+ if remotes . include? ( k )
45
+ puts "Skipping remote for #{ k } . Already added."
46
+ next
47
+ end
48
+
49
+ sh %{git remote add #{ k } #{ v } }
50
+ end
51
+ end
52
+
53
+ desc "Prune removed branches from remotes"
54
+ task :prune_team_repos do
55
+ repos = get_team_repos ( )
56
+
57
+ repos . each ( ) do |k , v |
58
+ sh %{git remote prune #{ k } }
59
+ end
60
+ end
61
+ end
You can’t perform that action at this time.
0 commit comments