public
Description: A set of Sake tasks to make developing with Git easier.
Clone URL: git://github.com/eventualbuddha/sake-git.git
Search Repo:
Whoops, git-svn rebase says it takes the same arguments as git-rebase, but 
it doesn't, so we need to switch to the branch before rebasing.
Wed Apr 16 13:09:44 -0700 2008
commit  728c55860bf1ac2827a85fafcaaec9d4de9b3488
tree    dbce85bf36a7af0b6f5d9b168731a84068470de7
parent  560e71d386ce094f85a1c6e09d144b3b3c853cb3
...
1
2
 
 
 
3
4
5
...
30
31
32
 
 
 
 
 
 
 
 
 
 
33
34
35
 
 
 
 
 
 
 
 
 
36
37
38
 
 
 
 
39
40
 
41
42
43
...
143
144
145
146
 
147
148
149
150
151
152
 
153
154
155
156
157
 
158
159
160
...
192
193
194
195
196
 
 
 
197
198
199
...
1
2
3
4
5
6
7
8
...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
60
61
62
63
64
65
66
67
68
69
...
169
170
171
 
172
173
174
175
176
177
 
178
179
180
181
182
 
183
184
185
186
...
218
219
220
 
 
221
222
223
224
225
226
0
@@ -1,5 +1,8 @@
0
 desc "This is just here for the other tasks and isn't intended for your use"
0
 task 'git:helpers' do
0
+ class GitError < RuntimeError; end
0
+ class GitRebaseError < GitError; end
0
+
0
   def git_branch
0
     `git-branch`.grep(/^\*/).first.strip[(2..-1)]
0
   end
0
@@ -30,14 +33,37 @@ task 'git:helpers' do
0
         end
0
     end
0
   end
0
+
0
+ def git_checkout(what = nil)
0
+ branch = git_branch
0
+ sh("git-checkout #{what}") if branch != what
0
+ if block_given?
0
+ yield
0
+ sh("git-checkout #{branch}") if branch != what
0
+ end
0
+ end
0
+
0
   def git_fetch
0
     sh("git#{"-svn" if git_svn?} fetch")
0
   end
0
+
0
+ def assert_command_succeeded(*args)
0
+ raise *args if $?.exitstatus != 0
0
+ end
0
+
0
+ def assert_rebase_succeeded(what = nil)
0
+ assert_command_succeeded GitRebaseError, "conflict while rebasing branch #{what}"
0
+ end
0
+
0
   def git_rebase(what = nil)
0
     if git_svn? then
0
- sh("git-svn rebase --local #{what}")
0
+ git_checkout what do
0
+ sh("git-svn rebase --local")
0
+ assert_rebase_succeeded what
0
+ end
0
     else
0
       sh("git-rebase origin/master #{what}")
0
+ assert_rebase_succeeded what
0
     end
0
   end
0
   def git_push
0
@@ -143,18 +169,18 @@ task 'git:open' => [ 'git:helpers' ] do
0
       puts(%{* Already on branch "#{newbranch}"})
0
     else
0
       puts(%{* Switching to existing branch "#{newbranch}"})
0
- `git-checkout #{newbranch}`
0
+ git_checkout newbranch
0
     end
0
     exit(0)
0
   end
0
   unless (branch == "master") then
0
     puts("* Switching to master")
0
- `git-checkout master`
0
+ git_checkout 'master'
0
   end
0
   `git-checkout -b #{newbranch}`
0
   unless $?.exitstatus.zero? then
0
     puts("* Couldn't create branch #{newbranch}, switching back to #{branch}")
0
- `git-checkout #{branch}`
0
+ git_checkout branch
0
     exit(1)
0
   end
0
   exit(0)
0
@@ -192,8 +218,9 @@ task 'git:update:all' => [ 'git:helpers' ] do
0
     switch = true
0
     git_branches.each do |b|
0
       puts("* Updating branch #{b}")
0
- git_rebase(b)
0
- unless $?.exitstatus.zero? then
0
+ begin
0
+ git_rebase(b)
0
+ rescue GitRebaseError => e
0
         puts("* Couldn't rebase #{b}, aborting so you can clean it up")
0
         switch = false
0
         break

Comments

    No one has commented yet.