git-process 0.9.1.pre3 → 0.9.2

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 (57) hide show
  1. data/CHANGELOG.md +0 -0
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +2 -0
  4. data/README.md +27 -9
  5. data/bin/git-new-fb +42 -13
  6. data/bin/git-pull-request +79 -13
  7. data/bin/git-sync +47 -13
  8. data/bin/git-to-master +56 -13
  9. data/git-process.gemspec +1 -1
  10. data/lib/git-process/{abstract-error-builder.rb → abstract_error_builder.rb} +13 -3
  11. data/lib/git-process/{git-abstract-merge-error-builder.rb → git_abstract_merge_error_builder.rb} +15 -5
  12. data/lib/git-process/{git-branch.rb → git_branch.rb} +13 -1
  13. data/lib/git-process/git_branches.rb +72 -0
  14. data/lib/git-process/{git-lib.rb → git_lib.rb} +82 -70
  15. data/lib/git-process/git_merge_error.rb +38 -0
  16. data/lib/git-process/git_process.rb +124 -0
  17. data/lib/git-process/git_process_error.rb +18 -0
  18. data/lib/git-process/git_process_options.rb +101 -0
  19. data/lib/git-process/git_rebase_error.rb +38 -0
  20. data/lib/git-process/{git-status.rb → git_status.rb} +13 -1
  21. data/lib/git-process/{github-client.rb → github_client.rb} +13 -1
  22. data/lib/git-process/github_pull_request.rb +107 -0
  23. data/lib/git-process/{github-service.rb → github_service.rb} +39 -21
  24. data/lib/git-process/new_fb.rb +40 -0
  25. data/lib/git-process/parked_changes_error.rb +40 -0
  26. data/lib/git-process/pull_request.rb +61 -0
  27. data/lib/git-process/rebase_to_master.rb +110 -0
  28. data/lib/git-process/sync.rb +63 -0
  29. data/lib/git-process/uncommitted_changes_error.rb +23 -0
  30. data/lib/git-process/version.rb +19 -9
  31. data/spec/GitRepoHelper.rb +35 -21
  32. data/spec/{git-abstract-merge-error-builder_spec.rb → git_abstract_merge_error_builder_spec.rb} +3 -3
  33. data/spec/{git-lib_spec.rb → git_lib_spec.rb} +79 -16
  34. data/spec/git_process_spec.rb +36 -0
  35. data/spec/{git-status_spec.rb → git_status_spec.rb} +28 -29
  36. data/spec/github_pull_request_spec.rb +91 -0
  37. data/spec/{github-service_spec.rb → github_service_spec.rb} +1 -1
  38. data/spec/new_fb_spec.rb +80 -0
  39. data/spec/rebase_to_master_spec.rb +314 -0
  40. data/spec/spec_helper.rb +1 -1
  41. data/spec/sync_spec.rb +149 -0
  42. metadata +46 -43
  43. data/lib/git-process/git-branches.rb +0 -53
  44. data/lib/git-process/git-merge-error.rb +0 -31
  45. data/lib/git-process/git-new-fb-options.rb +0 -34
  46. data/lib/git-process/git-process-error.rb +0 -10
  47. data/lib/git-process/git-process-options.rb +0 -82
  48. data/lib/git-process/git-process.rb +0 -194
  49. data/lib/git-process/git-pull-request-options.rb +0 -42
  50. data/lib/git-process/git-rebase-error.rb +0 -31
  51. data/lib/git-process/git-sync-options.rb +0 -34
  52. data/lib/git-process/git-to-master-options.rb +0 -18
  53. data/lib/git-process/parked-changes-error.rb +0 -32
  54. data/lib/git-process/pull-request.rb +0 -38
  55. data/lib/git-process/uncommitted-changes-error.rb +0 -15
  56. data/spec/git-process_spec.rb +0 -328
  57. data/spec/pull-request_spec.rb +0 -57
@@ -1,328 +0,0 @@
1
- require 'git-process'
2
- require 'GitRepoHelper'
3
-
4
- describe Git::Process do
5
- include GitRepoHelper
6
-
7
- before(:each) do
8
- create_files(['.gitignore'])
9
- gitlib.commit('initial')
10
- end
11
-
12
-
13
- after(:each) do
14
- rm_rf(tmpdir)
15
- end
16
-
17
-
18
- describe "rebase to master" do
19
-
20
- def log_level
21
- Logger::ERROR
22
- end
23
-
24
-
25
- it "should work easily for a simple rebase" do
26
- gitlib.checkout('fb', :new_branch => 'master')
27
- change_file_and_commit('a', '')
28
-
29
- commit_count.should == 2
30
-
31
- gitlib.checkout('master')
32
- change_file_and_commit('b', '')
33
-
34
- gitlib.checkout('fb')
35
-
36
- gitprocess.rebase_to_master
37
-
38
- commit_count.should == 3
39
- end
40
-
41
-
42
- it "should work for a rebase after a rerere merge" do
43
- # Make sure rerere is enabled
44
- gitlib.rerere_enabled(true, false)
45
- gitlib.rerere_autoupdate(false, false)
46
-
47
- # Create the file to conflict on
48
- change_file_and_commit('a', '')
49
-
50
- # In the new branch, give it a new value
51
- gitlib.checkout('fb', :new_branch => 'master') do
52
- change_file_and_commit('a', 'hello')
53
- end
54
-
55
- # Change the value as well in the origional branch
56
- gitlib.checkout('master') do
57
- change_file_and_commit('a', 'goodbye')
58
- end
59
-
60
- # Merge in the new branch; don't error-out because will auto-fix.
61
- gitlib.checkout('fb') do
62
- gitlib.merge('master') rescue
63
- change_file_and_commit('a', 'merged')
64
- end
65
-
66
- # Make another change on master
67
- gitlib.checkout('master') do
68
- change_file_and_commit('b', '')
69
- end
70
-
71
- # Go back to the branch and try to rebase
72
- gitlib.checkout('fb')
73
-
74
- begin
75
- gitprocess.rebase_to_master
76
- raise "Should have raised RebaseError"
77
- rescue Git::Process::RebaseError => exp
78
- exp.resolved_files.should == ['a']
79
- exp.unresolved_files.should == []
80
-
81
- exp.commands.length.should == 3
82
- exp.commands[0].should match /^# Verify/
83
- exp.commands[1].should == 'git add a'
84
- exp.commands[2].should == 'git rebase --continue'
85
- end
86
- end
87
-
88
- end
89
-
90
-
91
- describe "remove current feature branch" do
92
-
93
- def log_level
94
- Logger::ERROR
95
- end
96
-
97
-
98
- describe "when handling the parking branch" do
99
-
100
- it "should create it based on origin/master" do
101
- gitlib.branch('fb', :base_branch => 'master')
102
- clone('fb') do |gl|
103
- gp = Git::Process.new(nil, gl)
104
- gp.remove_feature_branch
105
- gl.branches.current.name.should == '_parking_'
106
- end
107
- end
108
-
109
-
110
- it "should move it to the new origin/master if it already exists and is clean" do
111
- gitlib.branch('origin/master', :base_branch => 'master')
112
- gitlib.branch('_parking_', :base_branch => 'origin/master')
113
- change_file_and_commit('a', '') # still on 'master'
114
-
115
- gitlib.checkout('fb', :new_branch => 'origin/master')
116
-
117
- gitprocess.remove_feature_branch
118
-
119
- gitlib.branches.current.name.should == '_parking_'
120
- end
121
-
122
-
123
- it "should move it to the new origin/master if it already exists and changes are part of the current branch" do
124
- gitlib.branch('origin/master', :base_branch => 'master')
125
-
126
- gitlib.checkout('_parking_', :new_branch => 'origin/master') do
127
- change_file_and_commit('a', '')
128
- end
129
-
130
- gitlib.branch('fb', :base_branch => '_parking_')
131
-
132
- gitlib.checkout('origin/master') do
133
- gitlib.merge('fb')
134
- end
135
-
136
- gitlib.checkout('fb')
137
-
138
- gitprocess.remove_feature_branch
139
- gitlib.branches.current.name.should == '_parking_'
140
- end
141
-
142
-
143
- it "should move it out of the way if it has unaccounted changes on it" do
144
- gitlib.branch('origin/master', :base_branch => 'master')
145
- gitlib.checkout('_parking_', :new_branch => 'origin/master')
146
- change_file_and_commit('a', '')
147
- gitlib.checkout('fb', :new_branch => 'origin/master')
148
-
149
- gitlib.branches.include?('_parking_OLD_').should be_false
150
- gitprocess.remove_feature_branch
151
- gitlib.branches.include?('_parking_OLD_').should be_true
152
- gitlib.branches.current.name.should == '_parking_'
153
- end
154
-
155
- end
156
-
157
-
158
- it "should delete the old local branch when it has been merged into origin/master" do
159
- gitlib.branch('origin/master', :base_branch => 'master')
160
- change_file_and_commit('a', '') # still on 'master'
161
-
162
- gitlib.checkout('fb', :new_branch => 'origin/master')
163
- gitlib.branches.include?('fb').should be_true
164
- gitprocess.remove_feature_branch
165
- gitlib.branches.include?('fb').should be_false
166
- gitlib.branches.current.name.should == '_parking_'
167
- end
168
-
169
-
170
- it "should raise an error when the local branch has not been merged into origin/master" do
171
- gitlib.branch('origin/master', :base_branch => 'master')
172
- gitlib.checkout('fb', :new_branch => 'origin/master')
173
- change_file_and_commit('a', '') # on 'fb'
174
-
175
- gitlib.branches.include?('fb').should be_true
176
- expect {gitprocess.remove_feature_branch}.should raise_error Git::Process::GitProcessError
177
- end
178
-
179
-
180
- it "should delete the old remote branch" do
181
- change_file_and_commit('a', '')
182
-
183
- gitlib.branch('fb', :base_branch => 'master')
184
-
185
- clone('fb') do |gl|
186
- gl.branches.include?('origin/fb').should be_true
187
- Git::Process.new(nil, gl).remove_feature_branch
188
- gl.branches.include?('origin/fb').should be_false
189
- gitlib.branches.include?('fb').should be_false
190
- gl.branches.current.name.should == '_parking_'
191
- end
192
- end
193
-
194
-
195
- describe "when used while on _parking_" do
196
-
197
- it 'should fail #rebase_to_master' do
198
- gitlib.checkout('_parking_', :new_branch => 'master')
199
- change_file_and_commit('a', '')
200
-
201
- expect {gitprocess.rebase_to_master}.should raise_error Git::Process::ParkedChangesError
202
- end
203
-
204
-
205
- it 'should fail #sync_with_server' do
206
- gitlib.checkout('_parking_', :new_branch => 'master')
207
- change_file_and_commit('a', '')
208
-
209
- expect {gitprocess.sync_with_server(false, false)}.should raise_error Git::Process::ParkedChangesError
210
- end
211
-
212
- end
213
-
214
- end
215
-
216
-
217
- describe "#new_feature_branch" do
218
-
219
- def log_level
220
- Logger::ERROR
221
- end
222
-
223
-
224
- it "should create the named branch against origin/master" do
225
- gitlib.branch('origin/master', :base_branch => 'master')
226
-
227
- new_branch = gitprocess.new_feature_branch('test_branch')
228
-
229
- new_branch.name.should == 'test_branch'
230
- new_branch.sha.should == gitlib.branches['origin/master'].sha
231
- end
232
-
233
-
234
- it "should bring committed changes on _parking_ over to the new branch" do
235
- gitlib.branch('origin/master', :base_branch => 'master')
236
- gitlib.checkout('_parking_', :new_branch => 'master')
237
- change_file_and_commit('a', '')
238
- change_file_and_commit('b', '')
239
-
240
- new_branch = gitprocess.new_feature_branch('test_branch')
241
-
242
- new_branch.name.should == 'test_branch'
243
- Dir.chdir(gitlib.workdir) do |dir|
244
- File.exists?('a').should be_true
245
- File.exists?('b').should be_true
246
- end
247
-
248
- gitlib.branches.parking.should be_nil
249
- end
250
-
251
-
252
- it "should bring new/uncommitted changes on _parking_ over to the new branch" do
253
- gitlib.branch('origin/master', :base_branch => 'master')
254
- gitlib.checkout('_parking_', :new_branch => 'master')
255
- change_file_and_commit('a', '')
256
- change_file_and_add('b', '')
257
- change_file('c', '')
258
-
259
- new_branch = gitprocess.new_feature_branch('test_branch')
260
-
261
- new_branch.name.should == 'test_branch'
262
- Dir.chdir(gitlib.workdir) do |dir|
263
- File.exists?('a').should be_true
264
- File.exists?('b').should be_true
265
- File.exists?('c').should be_true
266
- end
267
-
268
- gitlib.branches.parking.should be_nil
269
- end
270
-
271
- end
272
-
273
-
274
- describe "#sync_with_server" do
275
-
276
- def log_level
277
- Logger::ERROR
278
- end
279
-
280
-
281
- it "should work when pushing with fast-forward" do
282
- change_file_and_commit('a', '')
283
-
284
- gitlib.branch('fb', :base_branch => 'master')
285
-
286
- clone('fb') do |gl|
287
- change_file_and_commit('a', 'hello', gl)
288
- gl.branches.include?('origin/fb').should be_true
289
- Git::Process.new(nil, gl).sync_with_server(false, false)
290
- gl.branches.include?('origin/fb').should be_true
291
- gitlib.branches.include?('fb').should be_true
292
- end
293
- end
294
-
295
-
296
- it "should fail when pushing with non-fast-forward and no force" do
297
- change_file_and_commit('a', '')
298
-
299
- gitlib.branch('fb', :base_branch => 'master')
300
-
301
- clone('fb') do |gl|
302
- gitlib.checkout('fb') do
303
- change_file_and_commit('a', 'hello', gitlib)
304
- end
305
-
306
- expect {Git::Process.new(nil, gl).sync_with_server(false, false)}.should raise_error Git::GitExecuteError
307
- end
308
- end
309
-
310
-
311
- it "should work when pushing with non-fast-forward and force" do
312
- change_file_and_commit('a', '')
313
-
314
- gitlib.branch('fb', :base_branch => 'master')
315
-
316
- clone('fb') do |gl|
317
- gitlib.checkout('fb') do
318
- change_file_and_commit('a', 'hello', gitlib)
319
- end
320
-
321
- # expect {Git::Process.new(nil, gl).sync_with_server(false, true)}.should_not raise_error Git::GitExecuteError
322
- Git::Process.new(nil, gl).sync_with_server(false, true)
323
- end
324
- end
325
-
326
- end
327
-
328
- end
@@ -1,57 +0,0 @@
1
- require 'pull-request'
2
- require 'webmock/rspec'
3
- require 'json'
4
- require 'octokit'
5
- require 'tempfile'
6
- require 'GitRepoHelper'
7
-
8
-
9
- describe GitHub::PullRequest do
10
- include GitRepoHelper
11
-
12
- def lib
13
- unless @lib
14
- @lib = double('lib')
15
- @lib.stub(:logger).and_return(logger)
16
- end
17
- @lib
18
- end
19
-
20
-
21
- def test_token
22
- 'hfgkdjfgksjhdfkls'
23
- end
24
-
25
-
26
- def pull_request
27
- @pr ||= GitHub::PullRequest.new(lib, 'test_repo', :user => 'test_user')
28
- end
29
-
30
-
31
- before(:each) do
32
- lib.stub(:config).with('gitProcess.github.authToken').and_return(test_token)
33
- lib.stub(:config).with('remote.origin.url').and_return('git@github.com:jdigger/git-process.git')
34
- end
35
-
36
-
37
- it "should return a pull request for a good request" do
38
- stub_request(:post, "https://api.github.com/repos/test_repo/pulls?access_token=#{test_token}").
39
- to_return(:status => 200, :body => JSON({:number => 1, :state => 'open'}))
40
-
41
- pull_request.create('test_base', 'test_head', 'test title', 'test body')[:state].should == 'open'
42
- end
43
-
44
-
45
- it "should handle asking for a duplicate pull request" do
46
- # trying to create the request should return "HTTP 422: Unprocessable Entity" because it already exists
47
- stub_request(:post, "https://api.github.com/repos/test_repo/pulls?access_token=#{test_token}").
48
- to_return(:status => 422)
49
-
50
- # listing all existing pull requests should contain the current branch
51
- stub_request(:get, /test_repo\/pulls\?access_token=/).
52
- to_return(:status => 200, :body => JSON([{:html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}]))
53
-
54
- pull_request.create('test_base', 'test_head', 'test title', 'test body')[:html_url].should == 'test_url'
55
- end
56
-
57
- end