git-topic 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +11 -4
  3. data/Gemfile.lock +37 -15
  4. data/History.rdoc +19 -0
  5. data/README.rdoc +80 -95
  6. data/VERSION.yml +1 -1
  7. data/lib/git_topic.rb +105 -34
  8. data/lib/git_topic/cli.rb +35 -16
  9. data/lib/git_topic/comment.rb +2 -2
  10. data/lib/{core_ext.rb → git_topic/core_ext.rb} +70 -5
  11. data/lib/git_topic/git.rb +72 -35
  12. data/lib/git_topic/logger.rb +51 -0
  13. data/lib/git_topic/naming.rb +51 -8
  14. data/spec/comment_spec.rb +1 -0
  15. data/spec/git_topic_abandon_spec.rb +112 -0
  16. data/spec/git_topic_accept_spec.rb +8 -4
  17. data/spec/git_topic_comment_spec.rb +60 -7
  18. data/spec/git_topic_comments_spec.rb +1 -0
  19. data/spec/git_topic_done_spec.rb +8 -6
  20. data/spec/git_topic_install_aliases_spec.rb +1 -0
  21. data/spec/git_topic_logging_spec.rb +74 -0
  22. data/spec/git_topic_reject_spec.rb +5 -4
  23. data/spec/git_topic_review_spec.rb +51 -3
  24. data/spec/git_topic_setup_spec.rb +3 -2
  25. data/spec/git_topic_status_spec.rb +13 -2
  26. data/spec/git_topic_work_on_spec.rb +69 -9
  27. data/spec/spec_helper.rb +31 -12
  28. data/spec/template/origin/objects/16/f0fda5a88c44380ec3f687ec2e82fe702af7f7 +1 -0
  29. data/spec/template/origin/objects/17/5faa9939b9ac3d71ce53c42aee5e6e6a0c785c +0 -0
  30. data/spec/template/origin/objects/19/cf2c8a1f688b055774982d5010e6e30a664cc0 +0 -0
  31. data/spec/template/origin/objects/19/df194219c4296b82a9bfc8923def101c8485f1 +2 -0
  32. data/spec/template/origin/objects/28/222998cef35ffc5f39aa5c33c410624870e14e +0 -0
  33. data/spec/template/origin/objects/2b/56d40e3a8cdd99f6dbd02172231af5f44b1a4a +0 -0
  34. data/spec/template/origin/objects/3a/23df5be628d9dc86c3c201ed90666ca48706e8 +0 -0
  35. data/spec/template/origin/objects/47/a05bbad3ae0061aa6dcdefd5a2b91ef878e547 +0 -0
  36. data/spec/template/origin/objects/4a/f7e0cf66fa7ca6f4c64dabaf9cb4a7e75e530a +0 -0
  37. data/spec/template/origin/objects/51/30b0045082c311949fbe05bebbd7d77d2651fe +0 -0
  38. data/spec/template/origin/objects/53/348549b5f62b3d7fe308e314450c8dafb24a20 +1 -0
  39. data/spec/template/origin/objects/53/75f6d2da8e15dc1b93b53b794cc1c1a4b0a562 +2 -0
  40. data/spec/template/origin/objects/60/49ef3b01a46738c640dad45d5ea27d21ca3148 +2 -0
  41. data/spec/template/origin/objects/6a/671e28d05e12f0eb3a84b6c0e850acb5baa043 +0 -0
  42. data/spec/template/origin/objects/73/0d2b5fb7b28275d54672b24a10f9ff416151d9 +0 -0
  43. data/spec/template/origin/objects/77/8c48ec250d87693b1285518be6d32cd83c0d0e +0 -0
  44. data/spec/template/origin/objects/7b/2e0052793a417262e6b0a7049e27106e8df6df +0 -0
  45. data/spec/template/origin/objects/88/e563ba0dd5f822c9edcdb8a5d03f37c0b51efb +0 -0
  46. data/spec/template/origin/objects/8c/1eed9b8b7a0df74f6e0e4665f87f464b224e4f +1 -0
  47. data/spec/template/origin/objects/8e/59fbefc7a107f6c489a2ef65705f0b1944f7f0 +0 -0
  48. data/spec/template/origin/objects/ae/23634551b381284d41cc67060322d082f7cce4 +3 -0
  49. data/spec/template/origin/objects/b4/2dce0a04152ceb67d8120b5fc06cf583809590 +0 -0
  50. data/spec/template/origin/objects/c4/305717087f3413b5e50ae0c8037968758bf74d +0 -0
  51. data/spec/template/origin/objects/ca/9f1a38464dc0a7d099b7199126df2040f1b38b +0 -0
  52. data/spec/template/origin/objects/ce/66c4be9f1659f4621a0c709d9a87d2e6d464a2 +0 -0
  53. data/spec/template/origin/objects/d2/33cf6f04743aabaf4ea7ce546aed9a9758620f +1 -0
  54. data/spec/template/origin/objects/d3/f64a65197f61743cbe291f8c4dbaf09dbfb902 +2 -0
  55. data/spec/template/origin/objects/dd/1f38ef8037b85682079063d8c577c7b9f402bd +0 -0
  56. data/spec/template/origin/objects/df/8a312e41f9319aa4e73264d32ff65496867b37 +0 -0
  57. data/spec/template/origin/objects/e3/240e1f3328432e1708a2181d0b2e92bbb2b20d +1 -0
  58. data/spec/template/origin/objects/e8/4eaf06f50ed3b33e6846109436606668886c48 +0 -0
  59. data/spec/template/origin/objects/e8/b14aa4019584baf1ad3ab974503999fd170ce0 +0 -0
  60. data/spec/template/origin/objects/ed/ff0b85a5f8532df0bd6753d0942f4b7c0ede55 +0 -0
  61. data/spec/template/origin/refs/notes/reviews/USER/krakens +1 -0
  62. data/spec/template/origin/refs/notes/reviews/user24601/ninja-basic +1 -0
  63. metadata +87 -23
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
 
@@ -58,7 +59,7 @@ describe GitTopic do
58
59
  f.puts %Q{
59
60
  I have some general comments, mostly relating to the quality of our
60
61
  zombie-control policies. Basically, they're not working.
61
- }.cleanup
62
+ }.unindent
62
63
  end
63
64
  end
64
65
 
@@ -72,16 +73,16 @@ describe GitTopic do
72
73
  # destroy z
73
74
  # end
74
75
  # This should take care of our issues with zombies.
75
- }.cleanup
76
+ }.unindent
76
77
  end
77
78
  GitTopic.should_receive( :invoke_git_editor ).once
78
79
  GitTopic.should_receive(
79
80
  :git_author_name_short
80
81
  ).once.and_return( "Spec 123" )
81
82
 
82
- File.exists?(
83
+ old_review = File.read(
83
84
  "../origin/refs/notes/reviews/#{@user}/krakens"
84
- ).should == false
85
+ )
85
86
 
86
87
  lambda do
87
88
  GitTopic.work_on 'krakens'
@@ -95,9 +96,10 @@ describe GitTopic do
95
96
  GitTopic.done
96
97
  end.should_not raise_error
97
98
 
98
- File.exists?(
99
+ new_review = File.read(
99
100
  "../origin/refs/notes/reviews/#{@user}/krakens"
100
- ).should == true
101
+ )
102
+ new_review.should_not == old_review
101
103
  end
102
104
 
103
105
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
 
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe GitTopic do
5
+
6
+ describe "logging" do
7
+ before :each do
8
+ use_repo 'in-progress'
9
+ @log_path = "#{@starting_dir}/tmp/home/.git_topic/log"
10
+ end
11
+
12
+
13
+ it "should log to $HOME/.git_topic/log" do
14
+ File.exists?( @log_path ).should be_false
15
+ with_argv( %w( work-on something origin/review/user24601/ninja-basic )) do
16
+ GitTopic.run
17
+ end
18
+ File.exists?( @log_path ).should be_true
19
+ end
20
+
21
+ it "should log complete commands" do
22
+ with_argv( %w( work-on something origin/review/user24601/ninja-basic )) do
23
+ GitTopic.run
24
+ end
25
+ File.exists?( @log_path ).should be_true
26
+ log = File.read @log_path
27
+
28
+ log.should =~ %r{work-on something origin/review/user24601/ninja-basic}
29
+ end
30
+
31
+ it "should log all git commands invoked" do
32
+ with_argv( %w( work-on something origin/review/user24601/ninja-basic )) do
33
+ GitTopic.run
34
+ end
35
+ File.exists?( @log_path ).should be_true
36
+ log = File.read @log_path
37
+
38
+ [
39
+ "git branch -r --no-color",
40
+ "git push origin HEAD:refs/heads/wip/#{@user}/something",
41
+ "git branch",
42
+ "git checkout -b wip/#{@user}/something origin/wip/#{@user}/something",
43
+ "git reset --hard origin/review/user24601/ninja-basic",
44
+ "git branch",
45
+ ].each do |cmd|
46
+ log.should =~ %r{#{cmd}}
47
+ end
48
+ end
49
+
50
+ it "should log all errors from git" do
51
+ with_argv( %w( work-on something totally/invalid/upstream )) do
52
+ GitTopic.run
53
+ end
54
+ File.exists?( @log_path ).should be_true
55
+ log = File.read @log_path
56
+
57
+ [
58
+ "fatal: ambiguous argument 'totally/invalid/upstream': unknown revision",
59
+ ].each do |cmd|
60
+ log.should =~ %r{#{cmd}}
61
+ end
62
+ end
63
+
64
+ it "should not log if --no-log is specified" do
65
+ File.exists?( @log_path ).should be_false
66
+ with_argv( %w( --no-log work-on something origin/review/user24601/ninja-basic )) do
67
+ GitTopic.run
68
+ end
69
+ File.exists?( @log_path ).should be_false
70
+ end
71
+ end
72
+
73
+ end
74
+
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  RejectFirstComment = %Q{
@@ -63,7 +64,7 @@ describe GitTopic do
63
64
  f.puts %Q{
64
65
  I have some general comments, mostly relating to the quality of our
65
66
  zombie-control policies. Basically, they're not working.
66
- }.cleanup
67
+ }.unindent
67
68
  end
68
69
  end
69
70
 
@@ -77,7 +78,7 @@ describe GitTopic do
77
78
  # destroy z
78
79
  # end
79
80
  # This should take care of our issues with zombies.
80
- }.cleanup
81
+ }.unindent
81
82
  end
82
83
  GitTopic.should_receive( :invoke_git_editor ).once
83
84
  GitTopic.should_receive(
@@ -111,7 +112,7 @@ describe GitTopic do
111
112
  f.puts %Q{
112
113
  I have some general comments, mostly relating to the quality of our
113
114
  zombie-control policies. Basically, they're not working.
114
- }.cleanup
115
+ }.unindent
115
116
  end
116
117
  end
117
118
 
@@ -125,7 +126,7 @@ describe GitTopic do
125
126
  # destroy z
126
127
  # end
127
128
  # This should take care of our issues with zombies.
128
- }.cleanup
129
+ }.unindent
129
130
  end
130
131
  GitTopic.should_receive( :invoke_git_editor ).once
131
132
  GitTopic.should_receive(
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
 
@@ -62,7 +63,7 @@ describe GitTopic do
62
63
  system "git checkout master > /dev/null 2> /dev/null"
63
64
 
64
65
  git_branch.should == "master"
65
- lambda do
66
+ λ do
66
67
  GitTopic.review 'zombie-basic'
67
68
  end.should_not raise_error
68
69
  git_branch.should == "review/user24601/zombie-basic"
@@ -96,14 +97,61 @@ describe GitTopic do
96
97
 
97
98
  it "should handle fully-qualified topic args" do
98
99
  git_remote_branches.should include 'review/user24601/ninja-basic'
99
- lambda{ GitTopic.review( 'review/user24601/ninja-basic' )}.should_not raise_error
100
+ λ{ GitTopic.review( 'review/user24601/ninja-basic' )}.should_not raise_error
100
101
  git_branch.should == 'review/user24601/ninja-basic'
101
102
  git_branch_remote.should == 'origin'
102
103
  git_branch_merge.should == 'refs/heads/review/user24601/ninja-basic'
103
104
  end
104
105
 
105
106
  it "should error if an illegal topic is specified" do
106
- lambda{ GitTopic.review( 'fakeuser/faketopic' )}.should raise_error
107
+ λ{ GitTopic.review( 'fakeuser/faketopic' )}.should raise_error
108
+ end
109
+
110
+ describe "when the review branch is not rebased to master" do
111
+ it "should attempt to auto-rebase" do
112
+ git_head.should == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
113
+ system [
114
+ "git checkout --quiet master",
115
+ "echo 'content' > some_file",
116
+ "git add .",
117
+ "git commit --all -m 'force rebase' > /dev/null",
118
+ ].join( "&& ")
119
+
120
+ head = git_head
121
+ head.should_not == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
122
+
123
+ GitTopic.review 'ninja-basic'
124
+ git_head( '^' ).should == head
125
+ end
126
+
127
+ it "should inform the user when it has auto-rebased" do
128
+ system [
129
+ "git checkout --quiet master",
130
+ "echo 'content' > some_file",
131
+ "git add .",
132
+ "git commit --all -m 'force rebase' > /dev/null",
133
+ ].join( "&& ")
134
+ GitTopic.review 'ninja-basic'
135
+
136
+ @output.should =~ /rebase/
137
+ end
138
+
139
+ it "should issue a warning if auto-rebasing fails" do
140
+ git_head.should == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
141
+ system [
142
+ "git checkout --quiet master",
143
+ "echo 'conflicting content' > ninjas",
144
+ "git add .",
145
+ "git commit --all -m 'force failed rebase' > /dev/null",
146
+ ].join( "&& ")
147
+
148
+ head = git_head
149
+ head.should_not == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
150
+
151
+ λ do
152
+ GitTopic.review 'ninja-basic'
153
+ end.should raise_error
154
+ end
107
155
  end
108
156
  end
109
157
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
 
@@ -81,7 +82,7 @@ describe GitTopic do
81
82
  before( :each ) { use_repo 'in-progress' }
82
83
 
83
84
  it "should ask the user to #setup or configure no-whine" do
84
- with_argv( [] ) do
85
+ with_argv do
85
86
  GitTopic.run
86
87
  @err.should =~ /setup/
87
88
  end
@@ -99,7 +100,7 @@ describe GitTopic do
99
100
 
100
101
  system "git config --add remote.origin.fetch refs/notes/reviews/*:refs/notes/reviews/*"
101
102
 
102
- with_argv( [] ) do
103
+ with_argv do
103
104
  GitTopic.run
104
105
  @err.should =~ /setup/
105
106
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
 
@@ -17,8 +18,18 @@ describe GitTopic do
17
18
  @output.should_not be_nil
18
19
 
19
20
  @output.should_not =~ /^#\s*pirates\s*$/m
20
- @output.should =~ /^#\s*ninja-basic\s*$/m
21
- @output.should =~ /^#\s*zombie-basic\s*$/m
21
+ @output.should =~ /2 topics/m
22
+ @output.should =~ /^#\s*ninja-basic\s*/m
23
+ @output.should =~ /^#\s*zombie-basic\s*/m
24
+ end
25
+
26
+ it "should show the age of others' unreviewed branches" do
27
+
28
+ jul_12 = Date.parse( "12 July 2010" )
29
+ Date.should_receive(:today).at_least(:once).and_return jul_12
30
+ GitTopic.status
31
+
32
+ @output.should =~ /5 days/
22
33
  end
23
34
 
24
35
  it "should not show others' rejected topics" do
@@ -40,7 +40,7 @@ describe GitTopic do
40
40
  end
41
41
 
42
42
  it "should fail if no topic is given" do
43
- lambda { GitTopic.work_on( nil )}.should raise_error
43
+ λ { GitTopic.work_on( nil )}.should raise_error
44
44
  end
45
45
 
46
46
  it "should provide feedback to the user" do
@@ -68,14 +68,14 @@ describe GitTopic do
68
68
 
69
69
  it "should switch to (rather than create) an existing topic branch" do
70
70
  git_branches.should include( "wip/#{@user}/zombie-basic" )
71
- lambda{ GitTopic.work_on 'zombie-basic' }.should_not raise_error
71
+ λ{ GitTopic.work_on 'zombie-basic' }.should_not raise_error
72
72
 
73
73
  git_branch.should == "wip/#{@user}/zombie-basic"
74
74
  end
75
75
 
76
76
  it "should accept upstream as an argument" do
77
77
  git_remote_branches.should include( "review/#{@user}/pirates" )
78
- lambda do
78
+ λ do
79
79
  GitTopic.work_on 'pirates-etc',
80
80
  :upstream => "origin/review/#{@user}/pirates"
81
81
  end.should_not raise_error
@@ -84,6 +84,48 @@ describe GitTopic do
84
84
  git_head.should == 'c0838ed2ee8f2e83c8bda859fc5e332b92f0a5a3'
85
85
  end
86
86
 
87
+ describe "--continue flag" do
88
+ describe "when one has an as-yet unaccepted review branch" do
89
+ it "should set <upstream> to the latest such branch" do
90
+ λ do
91
+ GitTopic.work_on 'pirates-etc'
92
+ dirty_branch!
93
+ system "git add . && git commit -a -m 'arrrrr' > /dev/null 2> /dev/null"
94
+ GitTopic.done
95
+ end.should_not raise_error
96
+
97
+ head = git_remote "origin/review/#{@user}/pirates-etc"
98
+ head.should_not == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
99
+
100
+ GitTopic.work_on 'yet-more-pirates',
101
+ :continue => true
102
+
103
+ git_head.should == head
104
+ end
105
+ end
106
+
107
+ describe "when one has no pending review branches" do
108
+ before( :each ){ use_repo 'fresh' }
109
+
110
+ it "should have no effect" do
111
+ GitTopic.work_on 'yet-more-pirates',
112
+ :continue => true
113
+
114
+ git_head.should == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
115
+ end
116
+ end
117
+
118
+ describe "when an explicit <upstream> is also supplied" do
119
+ it "should fail with an error" do
120
+ λ do
121
+ GitTopic.work_on 'pirates-etc',
122
+ :continue => true,
123
+ :upstream => "origin/review/#{@user}/pirates"
124
+ end.should raise_error
125
+ end
126
+ end
127
+ end
128
+
87
129
  it "
88
130
  should use (and then destroy) the rejected branch for the topic, if one
89
131
  exists
@@ -95,6 +137,9 @@ describe GitTopic do
95
137
  git_remote_branches.should_not include( "rejected/#{@user}/krakens" )
96
138
  git_remote_branches.should include( "wip/#{@user}/krakens" )
97
139
  git_head.should == '44ffd9c9c8b52b201659e3ad318cdad6ec836b46'
140
+ git_remote(
141
+ "wip/#{@user}/krakens"
142
+ ).should == '44ffd9c9c8b52b201659e3ad318cdad6ec836b46'
98
143
  end
99
144
 
100
145
  it "
@@ -108,16 +153,31 @@ describe GitTopic do
108
153
  end
109
154
 
110
155
  it "
111
- should use (and then destroy) the review branch for the topic, if one
112
- exists
156
+ should not report the presence of comments, for comments that belong to
157
+ commits from an earlier topic branch of the same name
113
158
  ".oneline do
114
159
 
115
160
  git_remote_branches.should include( "rejected/#{@user}/krakens" )
116
- GitTopic.work_on 'krakens'
117
- git_branch.should == "wip/#{@user}/krakens"
161
+ refspecs = "origin/rejected/#{@user}/krakens:master :rejected/#{@user}/krakens"
162
+ system "git push origin #{refspecs} > /dev/null 2> /dev/null"
118
163
  git_remote_branches.should_not include( "rejected/#{@user}/krakens" )
119
- git_remote_branches.should include( "wip/#{@user}/krakens" )
120
- git_head.should == '44ffd9c9c8b52b201659e3ad318cdad6ec836b46'
164
+
165
+ GitTopic.work_on 'krakens'
166
+ git_head.should == '331d827fd47fb234af54e3a4bbf8c6705e9116cc'
167
+ @output.should_not =~ /comments/
168
+ end
169
+
170
+ it "
171
+ should use (and then destroy) the review branch for the topic, if one
172
+ exists
173
+ ".oneline do
174
+
175
+ git_remote_branches.should include( "review/#{@user}/pirates" )
176
+ GitTopic.work_on 'pirates'
177
+ git_branch.should == "wip/#{@user}/pirates"
178
+ git_remote_branches.should_not include( "review/#{@user}/pirates" )
179
+ git_remote_branches.should include( "wip/#{@user}/pirates" )
180
+ git_head.should == 'c0838ed2ee8f2e83c8bda859fc5e332b92f0a5a3'
121
181
  end
122
182
 
123
183
  end
data/spec/spec_helper.rb CHANGED
@@ -15,10 +15,10 @@ class << GitTopic
15
15
  ).each do |m|
16
16
 
17
17
  define_method( "#{m}_with_nocache" ) do
18
- rv = send( "#{m}_without_nocache" )
19
- GitTopic::Naming::ClassMethods.class_variable_set( "@@#{m}", nil )
20
- GitTopic::Git::ClassMethods.class_variable_set( "@@#{m}", nil )
21
- rv
18
+ send( "#{m}_without_nocache" ).tap do
19
+ GitTopic::Naming::ClassMethods.class_variable_set( "@@#{m}", nil )
20
+ GitTopic::Git::ClassMethods.class_variable_set( "@@#{m}", nil )
21
+ end
22
22
  end
23
23
  alias_method_chain m.to_sym, :nocache
24
24
  end
@@ -32,7 +32,7 @@ class << GitTopic
32
32
  end
33
33
  alias_method_chain :git, :implicit_capture
34
34
 
35
- def invoke_git_editor( file )
35
+ def invoke_git_editor file
36
36
  raise "
37
37
  invoke_git_editor invoked with (#{file}). If you expect this method to be
38
38
  called, mock or stub it.
@@ -41,6 +41,13 @@ class << GitTopic
41
41
 
42
42
  end
43
43
 
44
+ class << GitTopic::Logger
45
+ def logger_with_nocache
46
+ logger_without_nocache.tap{ @logger = nil }
47
+ end
48
+ alias_method_chain :logger, :nocache
49
+ end
50
+
44
51
 
45
52
  # Track original $stdout, $stderr write methods so we can “unmock” them for
46
53
  # debugging
@@ -63,6 +70,7 @@ class Object
63
70
  alias_method :write, :real_write
64
71
  end
65
72
 
73
+ $debugging = true
66
74
  require 'ruby-debug'
67
75
  debugger
68
76
  end
@@ -76,12 +84,14 @@ Rspec.configure do |c|
76
84
  c.before( :all ) do
77
85
  @starting_dir = Dir.pwd
78
86
  @user = ENV['USER'] || `whoami`
87
+ ENV['HOME'] = "#{@starting_dir}/tmp/home"
79
88
  end
80
89
 
81
90
  c.before( :each ) do
82
91
  # setup the directories
83
92
  FileUtils.rm_rf './tmp'
84
93
  FileUtils.mkdir './tmp'
94
+ FileUtils.mkdir './tmp/home'
85
95
 
86
96
  # Copy our repos into tmp
87
97
  %w(fresh in-progress).each do |d|
@@ -105,6 +115,10 @@ Rspec.configure do |c|
105
115
  FileUtils.mv ".git/refs/notes/reviews/USER",
106
116
  ".git/refs/notes/reviews/#{@user}"
107
117
  end
118
+ if File.exists? "./refs/notes/reviews/USER"
119
+ FileUtils.mv "./refs/notes/reviews/USER",
120
+ "./refs/notes/reviews/#{@user}"
121
+ end
108
122
  Dir.chdir @starting_dir
109
123
  end
110
124
  Dir.chdir "#{@starting_dir}/tmp"
@@ -127,7 +141,7 @@ end
127
141
  # helpers # {{{
128
142
 
129
143
  def use_repo( repo )
130
- Dir.chdir( repo )
144
+ Dir.chdir( "#{@starting_dir}/tmp/#{repo}" )
131
145
  # Exit if e.g. GIT_DIR is set
132
146
  raise "Spec error" unless git_dir == '.git'
133
147
  end
@@ -144,15 +158,19 @@ def git_branch
144
158
  current_branch[ 2..-1 ] unless current_branch.nil?
145
159
  end
146
160
 
147
- def git_head
148
- `git rev-parse HEAD`.chomp
161
+ def git_head suffix=nil
162
+ `git rev-parse HEAD#{suffix}`.chomp
163
+ end
164
+
165
+ def git_remote branch
166
+ `git rev-parse #{branch}`.chomp
149
167
  end
150
168
 
151
169
  def git_origin_master
152
170
  `git rev-parse origin/master`.chomp
153
171
  end
154
172
 
155
- def git_config( key )
173
+ def git_config key
156
174
  `git config #{key}`.chomp
157
175
  end
158
176
 
@@ -178,7 +196,7 @@ def git_remote_branches
178
196
  end
179
197
  end
180
198
 
181
- def git_notes_list( ref )
199
+ def git_notes_list ref
182
200
  `git notes --ref #{ref}`.split( "\n" )
183
201
  end
184
202
 
@@ -197,13 +215,14 @@ def dirty_branch!
197
215
  end
198
216
 
199
217
 
200
- def with_argv( val )
218
+ def with_argv *val
201
219
  restore = ARGV.dup
202
- ARGV.replace( val )
220
+ ARGV.replace( val.flatten )
203
221
  rv = yield
204
222
  ARGV.replace( restore )
205
223
  rv
206
224
  end
207
225
 
226
+
208
227
  # }}}
209
228