git-process 1.0.11 → 1.1.0

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 (54) hide show
  1. data/CHANGELOG.md +37 -9
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +17 -17
  4. data/README.md +14 -7
  5. data/bin/git-new-fb +10 -2
  6. data/bin/git-pull-request +30 -6
  7. data/bin/git-sync +5 -2
  8. data/bin/git-to-master +62 -11
  9. data/git-process.gemspec +15 -15
  10. data/lib/git-process/abstract_error_builder.rb +0 -3
  11. data/lib/git-process/changed_file_helper.rb +30 -24
  12. data/lib/git-process/git_abstract_merge_error_builder.rb +31 -11
  13. data/lib/git-process/git_branch.rb +5 -0
  14. data/lib/git-process/git_config.rb +153 -0
  15. data/lib/git-process/git_lib.rb +212 -164
  16. data/lib/git-process/git_logger.rb +84 -0
  17. data/lib/git-process/git_merge_error.rb +3 -14
  18. data/lib/git-process/git_process.rb +44 -73
  19. data/lib/git-process/git_process_options.rb +6 -6
  20. data/lib/git-process/git_rebase_error.rb +4 -13
  21. data/lib/git-process/git_remote.rb +254 -0
  22. data/lib/git-process/github_configuration.rb +298 -0
  23. data/lib/git-process/github_pull_request.rb +65 -27
  24. data/lib/git-process/new_fb.rb +14 -4
  25. data/lib/git-process/parked_changes_error.rb +1 -1
  26. data/lib/git-process/pull_request.rb +100 -13
  27. data/lib/git-process/pull_request_error.rb +25 -0
  28. data/lib/git-process/rebase_to_master.rb +47 -27
  29. data/lib/git-process/sync.rb +48 -33
  30. data/lib/git-process/uncommitted_changes_error.rb +1 -1
  31. data/lib/git-process/version.rb +2 -2
  32. data/spec/GitRepoHelper.rb +48 -25
  33. data/spec/changed_file_helper_spec.rb +39 -58
  34. data/spec/git_abstract_merge_error_builder_spec.rb +42 -33
  35. data/spec/git_branch_spec.rb +30 -30
  36. data/spec/git_config_spec.rb +45 -0
  37. data/spec/git_lib_spec.rb +103 -122
  38. data/spec/git_logger_spec.rb +66 -0
  39. data/spec/git_process_spec.rb +81 -81
  40. data/spec/git_remote_spec.rb +188 -0
  41. data/spec/git_status_spec.rb +36 -36
  42. data/spec/github_configuration_spec.rb +152 -0
  43. data/spec/github_pull_request_spec.rb +39 -35
  44. data/spec/github_test_helper.rb +49 -0
  45. data/spec/new_fb_spec.rb +65 -24
  46. data/spec/pull_request_helper.rb +94 -0
  47. data/spec/pull_request_spec.rb +128 -0
  48. data/spec/rebase_to_master_spec.rb +241 -145
  49. data/spec/spec_helper.rb +20 -0
  50. data/spec/sync_spec.rb +115 -109
  51. metadata +34 -20
  52. data/lib/git-process/github_client.rb +0 -83
  53. data/lib/git-process/github_service.rb +0 -174
  54. data/spec/github_service_spec.rb +0 -211
@@ -0,0 +1,45 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ require 'FileHelpers'
14
+ require 'git-process/git_lib'
15
+ require 'git-process/git_config'
16
+ include GitProc
17
+
18
+ describe GitConfig do
19
+
20
+ def tmpdir
21
+ @tmpdir ||= Dir.mktmpdir
22
+ end
23
+
24
+
25
+ after(:each) do
26
+ rm_rf(tmpdir)
27
+ end
28
+
29
+
30
+ it 'should retrieve values by []' do
31
+ lib = GitLib.new(tmpdir, :log_level => Logger::ERROR)
32
+ lib.command(:config, %w(somevalue.subvalue here))
33
+ config = GitConfig.new(lib)
34
+ config['somevalue.subvalue'].should == 'here'
35
+ end
36
+
37
+
38
+ it "should set values by []" do
39
+ lib = GitLib.new(tmpdir, :log_level => Logger::ERROR)
40
+ config = GitConfig.new(lib)
41
+ config['somevalue.subvalue'] = 'there'
42
+ lib.command(:config, %w(--get somevalue.subvalue)).should == 'there'
43
+ end
44
+
45
+ end
data/spec/git_lib_spec.rb CHANGED
@@ -1,56 +1,41 @@
1
1
  require 'git-process/git_lib'
2
2
  require 'GitRepoHelper'
3
+ include GitProc
3
4
 
4
- describe GitProc::GitLib do
5
-
6
- class GLStub
7
- include GitProc::GitLib
8
-
9
-
10
- def initialize(workdir, log_level)
11
- @logger = Logger.new(STDOUT)
12
- @logger.level = log_level || Logger::WARN
13
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
14
- f = Logger::Formatter.new
15
- @logger.formatter = proc do |_, _, _, msg|
16
- "#{msg}\n"
17
- end
18
-
19
- @workdir = workdir
20
- if workdir
21
- if File.directory?(File.join(workdir, '.git'))
22
- logger.debug { "Opening existing repository at #{workdir}" }
23
- else
24
- logger.info { "Initializing new repository at #{workdir}" }
25
- command(:init)
26
- end
27
- end
28
- end
29
5
 
6
+ describe GitLib, :git_repo_helper do
7
+
8
+
9
+ def log_level
10
+ Logger::ERROR
11
+ end
30
12
 
31
- def workdir
32
- @workdir
33
- end
34
13
 
14
+ describe 'workdir' do
35
15
 
36
- def logger
37
- @logger
16
+ it 'should use the passed in directory when the top level is a git workdir' do
17
+ dir = Dir.mktmpdir
18
+ mkdir_p "#{dir}/.git"
19
+ gitlib = GitLib.new(dir, :log_level => Logger::ERROR)
20
+ gitlib.workdir.should == dir
38
21
  end
39
- end
40
22
 
41
23
 
42
- def gitlib
43
- gitprocess
44
- end
24
+ it "should find the parent git workdir" do
25
+ topdir = Dir.mktmpdir
26
+ mkdir_p "#{topdir}/.git"
27
+ dir = "#{topdir}/a/b/c/d/e/f/g"
28
+ mkdir_p dir
29
+ gitlib = GitLib.new(dir, :log_level => Logger::ERROR)
30
+ gitlib.workdir.should == topdir
31
+ end
45
32
 
33
+ end
46
34
 
47
- describe "branches" do
48
- include GitRepoHelper
49
35
 
50
- it "list all the branches" do
51
- create_files(%w(.gitignore))
52
- gitlib.commit('initial')
36
+ describe 'branches' do
53
37
 
38
+ it 'list all the branches' do
54
39
  gitlib.branch('ba', :base_branch => 'master')
55
40
  gitlib.branch('bb', :base_branch => 'master')
56
41
  gitlib.branch('origin/master', :base_branch => 'master')
@@ -61,133 +46,129 @@ describe GitProc::GitLib do
61
46
  end
62
47
 
63
48
 
64
- describe "branch" do
65
- attr_reader :lib
66
-
67
- before(:each) do
68
- @lib = GLStub.new(nil, nil)
49
+ describe 'fetch' do
50
+
51
+ it 'parse the list of changes' do
52
+ output = '''
53
+ remote: Counting objects: 1028, done.
54
+ remote: Compressing objects: 100% (301/301), done.
55
+ remote: Total 699 (delta 306), reused 654 (delta 273)
56
+ Receiving objects: 100% (699/699), 600.68 KiB | 686 KiB/s, done.
57
+ Resolving deltas: 100% (306/306), completed with 84 local objects.
58
+ From remote.system.com:tuser/test-proj
59
+ 8e667e0..19ecc91 SITE_TOUR_MODAL -> origin/SITE_TOUR_MODAL
60
+ + cea75d7...d656188 WEBCMS-2014 -> origin/WEBCMS-2014 (forced update)
61
+ * [new branch] WEBCMS-2047 -> origin/WEBCMS-2047
62
+ ca9e80e..d383005 WEBCMS-2157 -> origin/WEBCMS-2157
63
+ 77b5d5c..f485c7f WEBCMS-2159 -> origin/WEBCMS-2159
64
+ * [new branch] WEBCMS-2166 -> origin/WEBCMS-2166
65
+ c648f2a..86ee15e WEBCMS-2167 -> origin/WEBCMS-2167
66
+ * [new tag] RELEASE_1.0.1.53 -> RELEASE_1.0.1.53
67
+ * [new tag] RELEASE_1.0.1.54 -> RELEASE_1.0.1.54
68
+ x [deleted] (none) -> origin/WEBCMS-4650-resi-breadcrumbs
69
+ * [new branch] WEBCMS-2169 -> origin/WEBCMS-2169
70
+ * [new branch] base-carousel -> origin/base-carousel
71
+ 1de9c437..7546667 develop -> origin/develop
72
+ 90e8d75..23ae7d1 new-ui-smoketest -> origin/new-ui-smoketest
73
+ * [new branch] webcms-2023 -> origin/webcms-2023
74
+ b9797f8..dd24a9f webcms-2135 -> origin/webcms-2135
75
+ * [new branch] webcms-831-faq-web-service -> origin/webcms-831-faq-web-service
76
+ x [deleted] (none) -> origin/webcms-1315-masthead
77
+ '''
78
+ changes = gitlib.fetch_changes(output)
79
+
80
+ changes[:new_branch].size().should == 6
81
+ changes[:new_tag].size().should == 2
82
+ changes[:deleted].size().should == 2
83
+ changes[:force_updated].size().should == 1
84
+ changes[:updated].size().should == 7
85
+
86
+ empty_changes = gitlib.fetch_changes('')
87
+
88
+ empty_changes[:new_branch].size().should == 0
89
+ empty_changes[:new_tag].size().should == 0
90
+ empty_changes[:deleted].size().should == 0
91
+ empty_changes[:force_updated].size().should == 0
92
+ empty_changes[:updated].size().should == 0
69
93
  end
70
94
 
95
+ end
96
+
97
+
98
+ describe "branch" do
71
99
 
72
100
  it "should create a branch with default base" do
73
- lib.stub(:command).with(:branch, %w(test_branch master))
74
- lib.branch('test_branch')
101
+ gitlib.stub(:command).with(:branch, %w(test_branch master))
102
+ gitlib.branch('test_branch')
75
103
  end
76
104
 
77
105
 
78
106
  it "should create a branch with explicit base" do
79
- lib.stub(:command).with(:branch, %w(test_branch other_branch))
80
- lib.branch('test_branch', :base_branch => 'other_branch')
107
+ gitlib.should_receive(:command).with(:branch, %w(test_branch other_branch))
108
+ gitlib.branch('test_branch', :base_branch => 'other_branch')
81
109
  end
82
110
 
83
111
 
84
- it "should delete a branch without force" do
85
- lib.stub(:command).with(:branch, %w(-d test_branch))
86
- lib.branch('test_branch', :delete => true)
112
+ it 'should delete a branch without force' do
113
+ gitlib.should_receive(:command).with(:branch, %w(-d test_branch))
114
+ gitlib.branch('test_branch', :delete => true)
87
115
  end
88
116
 
89
117
 
90
- it "should delete a branch with force" do
91
- lib.stub(:command).with(:branch, %w(-D test_branch))
92
- lib.branch('test_branch', :delete => true, :force => true)
118
+ it 'should delete a branch with force' do
119
+ gitlib.should_receive(:command).with(:branch, %w(-D test_branch))
120
+ gitlib.branch('test_branch', :delete => true, :force => true)
93
121
  end
94
122
 
95
- end
96
-
97
-
98
- describe "push" do
99
- attr_reader :lib
100
123
 
101
- before(:each) do
102
- @lib = GLStub.new(nil, nil)
124
+ it "should rename a branch" do
125
+ gitlib.should_receive(:command).with(:branch, %w(-m test_branch new_branch))
126
+ gitlib.branch('test_branch', :rename => 'new_branch')
103
127
  end
104
128
 
129
+ end
105
130
 
106
- def log_level
107
- Logger::ERROR
108
- end
109
131
 
132
+ describe "push" do
110
133
 
111
134
  it "should push local branch to remote" do
112
- lib.should_receive(:command).with(:push, %w(remote local_branch:test_branch))
135
+ gitlib.should_receive(:command).with(:push, %w(remote local_branch:test_branch))
113
136
 
114
- lib.push('remote', 'local_branch', 'test_branch')
137
+ gitlib.push('remote', 'local_branch', 'test_branch')
115
138
  end
116
139
 
117
140
 
118
141
  it "should push current branch to remote" do
119
- lib.stub(:command).with(:branch, %w(-a --no-color)).and_return("* my_branch\n")
120
- lib.should_receive(:command).with(:push, %w(remote my_branch:my_branch))
142
+ gitlib.stub(:command).with(:branch, %w(-a --no-color)).and_return("* my_branch\n")
143
+ gitlib.should_receive(:command).with(:push, %w(remote my_branch:my_branch))
121
144
 
122
- lib.push('remote', 'my_branch', nil)
145
+ gitlib.push('remote', 'my_branch', nil)
123
146
  end
124
147
 
125
148
 
126
149
  it "should remove named branch on remote" do
127
- lib.stub(:remote_name).and_return('remote')
128
- lib.stub(:config).and_return('master')
129
- lib.should_receive(:command).with(:push, %w(remote --delete my_branch))
150
+ gitlib.remote.stub(:name).and_return('remote_server')
151
+ gitlib.config.stub(:master_branch).and_return('master')
152
+ gitlib.should_receive(:command).with(:push, %w(remote_server --delete my_branch))
130
153
 
131
- lib.push('remote', 'my_branch', nil, :delete => true)
154
+ gitlib.push('remote_server', 'my_branch', nil, :delete => true)
132
155
  end
133
156
 
134
157
 
135
158
  it "should remove current branch on remote" do
136
- lib.stub(:remote_name).and_return('remote')
137
- lib.stub(:config).and_return('master')
138
- lib.should_receive(:command).with(:push, %w(remote --delete my_branch))
159
+ gitlib.remote.stub(:name).and_return('remote_server')
160
+ gitlib.config.stub(:master_branch).and_return('master')
161
+ gitlib.should_receive(:command).with(:push, %w(remote_server --delete my_branch))
139
162
 
140
- lib.push('remote', nil, nil, :delete => 'my_branch')
163
+ gitlib.push('remote_server', nil, nil, :delete => 'my_branch')
141
164
  end
142
165
 
143
166
 
144
167
  it "should not remove integration branch on remote" do
145
- lib.stub(:remote_name).and_return('remote')
146
- lib.stub(:config).and_return('master')
147
-
148
- expect { lib.push('remote', nil, nil, :delete => 'master') }.should raise_error GitProc::GitProcessError
149
- end
150
-
151
- end
152
-
153
-
154
- describe "#remote_name" do
155
- include GitRepoHelper
156
-
157
-
158
- def log_level
159
- Logger::ERROR
160
- end
161
-
162
-
163
- it "should work with origin" do
164
- change_file_and_commit('a', '')
165
-
166
- clone('master', 'origin') do |gl|
167
- gl.remote_name.should == 'origin'
168
- gl.branches.include?('origin/master').should be_true
169
- end
170
- end
171
-
172
-
173
- it "should work with a different remote name" do
174
- change_file_and_commit('a', '')
175
-
176
- clone('master', 'a_remote') do |gl|
177
- gl.remote_name.should == 'a_remote'
178
- gl.branches.include?('a_remote/master').should be_true
179
- end
180
- end
181
-
182
-
183
- it "should work with an overridden remote name" do
184
- change_file_and_commit('a', '')
185
-
186
- clone('master', 'a_remote') do |gl|
187
- gl.config('gitProcess.remoteName', 'something_else')
168
+ gitlib.remote.stub(:name).and_return('remote_server')
169
+ gitlib.config.stub(:master_branch).and_return('master')
188
170
 
189
- gl.remote_name.should == 'something_else'
190
- end
171
+ expect { gitlib.push('remote_server', nil, nil, :delete => 'master') }.to raise_error GitProcessError
191
172
  end
192
173
 
193
174
  end
@@ -0,0 +1,66 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ require 'git-process/git_logger'
14
+ include GitProc
15
+
16
+ describe GitLogger do
17
+
18
+ it 'should log info blocks' do
19
+ val = false
20
+ GitLogger.new(GitLogger::INFO, nil).info { val = true }
21
+ val.should == true
22
+ end
23
+
24
+
25
+ it 'should not log info blocks by default' do
26
+ val = false
27
+ GitLogger.new(nil, nil).info { val = true }
28
+ val.should == false
29
+ end
30
+
31
+
32
+ it 'should log warn blocks' do
33
+ val = false
34
+ GitLogger.new(GitLogger::WARN, nil).warn { val = true }
35
+ val.should == true
36
+ end
37
+
38
+
39
+ it "should log warn blocks by default" do
40
+ val = false
41
+ GitLogger.new(nil, nil).warn { val = true }
42
+ val.should == true
43
+ end
44
+
45
+
46
+ it "should log error blocks" do
47
+ val = false
48
+ GitLogger.new(GitLogger::ERROR, nil).error { val = true }
49
+ val.should == true
50
+ end
51
+
52
+
53
+ it "should log error blocks by default" do
54
+ val = false
55
+ GitLogger.new.error { val = true }
56
+ val.should == true
57
+ end
58
+
59
+
60
+ it 'should log debug blocks' do
61
+ val = false
62
+ GitLogger.new(GitLogger::DEBUG, nil).debug { val = true }
63
+ val.should == true
64
+ end
65
+
66
+ end
@@ -13,37 +13,19 @@ describe GitProc::Process do
13
13
 
14
14
  before(:each) do
15
15
  create_files(%w(.gitignore))
16
- gitprocess.commit('initial')
16
+ gitlib.commit('initial')
17
17
  end
18
18
 
19
19
 
20
20
  after(:each) do
21
- rm_rf(tmpdir)
21
+ rm_rf(gitlib.workdir)
22
22
  end
23
23
 
24
24
 
25
- describe "workdir" do
25
+ describe 'run lifecycle' do
26
26
 
27
- it "should use the passed in directory when the top level is a git workdir" do
28
- proc = GitProc::Process.new(tmpdir)
29
- proc.workdir.should == tmpdir
30
- end
31
-
32
-
33
- it "should find the parent git workdir" do
34
- dir = "#{tmpdir}/a/b/c/d/e/f/g"
35
- mkdir_p dir
36
- proc = GitProc::Process.new(dir)
37
- proc.workdir.should == tmpdir
38
- end
39
-
40
- end
41
-
42
-
43
- describe "run lifecycle" do
44
-
45
- it "should call the standard hooks" do
46
- proc = GitProc::Process.new(tmpdir)
27
+ it 'should call the standard hooks' do
28
+ proc = GitProc::Process.new(gitlib)
47
29
  proc.should_receive(:verify_preconditions)
48
30
  proc.should_receive(:runner)
49
31
  proc.should_receive(:cleanup)
@@ -54,7 +36,7 @@ describe GitProc::Process do
54
36
 
55
37
 
56
38
  it "should call 'cleanup' even if there's an error" do
57
- proc = GitProc::Process.new(tmpdir)
39
+ proc = GitProc::Process.new(gitlib)
58
40
  proc.should_receive(:verify_preconditions)
59
41
  proc.should_receive(:runner).and_raise(GitProc::GitProcessError.new("Error!"))
60
42
  proc.should_receive(:cleanup)
@@ -70,137 +52,155 @@ describe GitProc::Process do
70
52
  describe "validate local integration branch" do
71
53
 
72
54
  it "should use remove the int-branch if not on it and not blocked" do
73
- gp = clone('master')
74
- gp.checkout('fb', :new_branch => 'master')
55
+ clone_repo('master') do |gl|
56
+ gl.checkout('fb', :new_branch => 'master')
75
57
 
76
- gp.stub(:ask_about_removing_master).and_return(true)
58
+ gp = GitProc::Process.new(gl)
59
+ gp.stub(:ask_about_removing_master).and_return(true)
77
60
 
78
- gp.verify_preconditions
61
+ gp.verify_preconditions
79
62
 
80
- gp.branches.include?('master').should be_false
63
+ gl.branches.include?('master').should be_false
64
+ end
81
65
  end
82
66
 
83
67
 
84
68
  it "should ask use remove the int-branch if not on it and not blocked" do
85
- gp = clone('master')
86
- gp.checkout('fb', :new_branch => 'master')
69
+ clone_repo('master') do |gl|
70
+ gl.checkout('fb', :new_branch => 'master')
87
71
 
88
- gp.should_receive(:ask_about_removing_master).and_return(true)
72
+ gp = GitProc::Process.new(gl)
73
+ gp.should_receive(:ask_about_removing_master).and_return(true)
89
74
 
90
- gp.verify_preconditions
75
+ gp.verify_preconditions
91
76
 
92
- gp.branches.include?('master').should be_false
77
+ gl.branches.include?('master').should be_false
78
+ end
93
79
  end
94
80
 
95
81
 
96
82
  it "should ask use remove the int-branch if not on it and not blocked and not remove if answered no" do
97
- gp = clone('master')
98
- gp.checkout('fb', :new_branch => 'master')
83
+ clone_repo('master') do |gl|
84
+ gl.checkout('fb', :new_branch => 'master')
99
85
 
100
- gp.should_receive(:ask_about_removing_master).and_return(false)
86
+ gp = GitProc::Process.new(gl)
87
+ gp.should_receive(:ask_about_removing_master).and_return(false)
101
88
 
102
- gp.verify_preconditions
89
+ gp.verify_preconditions
103
90
 
104
- gp.branches.include?('master').should be_true
91
+ gl.branches.include?('master').should be_true
92
+ end
105
93
  end
106
94
 
107
95
 
108
96
  it "should not remove the int-branch if on it" do
109
- gp = clone('master')
110
-
111
- gp.verify_preconditions
97
+ clone_repo('master') do |gl|
98
+ gp = GitProc::Process.new(gl)
99
+ gp.verify_preconditions
112
100
 
113
- gp.branches.include?('master').should be_true
101
+ gl.branches.include?('master').should be_true
102
+ end
114
103
  end
115
104
 
116
105
 
117
106
  it "should not remove the int-branch if blocked" do
118
- gp = clone('master')
119
- gp.config('gitProcess.keepLocalIntegrationBranch', 'true')
120
- gp.checkout('fb', :new_branch => 'master')
107
+ clone_repo('master') do |gl|
108
+ gl.config['gitProcess.keepLocalIntegrationBranch'] = 'true'
109
+ gl.checkout('fb', :new_branch => 'master')
121
110
 
122
- gp.verify_preconditions
111
+ gp = GitProc::Process.new(gl)
112
+ gp.verify_preconditions
123
113
 
124
- gp.branches.include?('master').should be_true
114
+ gl.branches.include?('master').should be_true
115
+ end
125
116
  end
126
117
 
127
118
 
128
119
  describe "local vs remote branch status" do
129
120
 
130
121
  before(:each) do
131
- change_file_and_commit('a.txt', 'a content', gitprocess)
132
- change_file_and_commit('b.txt', 'b content', gitprocess)
122
+ change_file_and_commit('a.txt', 'a content', gitlib)
123
+ change_file_and_commit('b.txt', 'b content', gitlib)
133
124
  end
134
125
 
135
126
 
136
127
  it "should not remove if both have changes" do
137
- gp = clone('master')
128
+ clone_repo('master') do |gl|
129
+ change_file_and_commit('c.txt', 'c on origin/master', gitlib)
130
+ change_file_and_commit('d.txt', 'd on master', gl)
138
131
 
139
- change_file_and_commit('c.txt', 'c on origin/master', gitprocess)
140
- change_file_and_commit('d.txt', 'd on master', gp)
132
+ gl.checkout('fb', :new_branch => 'master')
141
133
 
142
- gp.checkout('fb', :new_branch => 'master')
134
+ gl.fetch
143
135
 
144
- gp.fetch
145
- gp.verify_preconditions
136
+ gp = GitProc::Process.new(gl)
137
+ gp.verify_preconditions
146
138
 
147
- gp.branches.include?('master').should be_true
139
+ gl.branches.include?('master').should be_true
140
+ end
148
141
  end
149
142
 
150
143
 
151
144
  it "should remove if server changed but not local" do
152
- gp = clone('master')
153
- gp.stub(:ask_about_removing_master).and_return(true)
145
+ clone_repo('master') do |gl|
146
+ gp = GitProc::Process.new(gl)
147
+ gp.stub(:ask_about_removing_master).and_return(true)
154
148
 
155
- change_file_and_commit('c.txt', 'c on origin/master', gitprocess)
149
+ change_file_and_commit('c.txt', 'c on origin/master', gitlib)
156
150
 
157
- gp.checkout('fb', :new_branch => 'master')
151
+ gl.checkout('fb', :new_branch => 'master')
158
152
 
159
- gp.fetch
160
- gp.verify_preconditions
153
+ gl.fetch
161
154
 
162
- gp.branches.include?('master').should be_false
155
+ gp.verify_preconditions
156
+
157
+ gl.branches.include?('master').should be_false
158
+ end
163
159
  end
164
160
 
165
161
 
166
162
  it "should not remove if server did not change but local did" do
167
- gp = clone('master')
163
+ clone_repo('master') do |gl|
164
+ change_file_and_commit('c.txt', 'c on master', gl)
168
165
 
169
- change_file_and_commit('c.txt', 'c on master', gp)
166
+ gl.checkout('fb', :new_branch => 'master')
170
167
 
171
- gp.checkout('fb', :new_branch => 'master')
168
+ gl.fetch
172
169
 
173
- gp.fetch
174
- gp.verify_preconditions
170
+ gp = GitProc::Process.new(gl)
171
+ gp.verify_preconditions
175
172
 
176
- gp.branches.include?('master').should be_true
173
+ gl.branches.include?('master').should be_true
174
+ end
177
175
  end
178
176
 
179
177
 
180
178
  it "should remove if server and local are the same" do
181
- change_file_and_commit('c.txt', 'c on origin/master', gitprocess)
179
+ change_file_and_commit('c.txt', 'c on origin/master', gitlib)
182
180
 
183
- gp = clone('master')
181
+ clone_repo('master') do |gl|
182
+ gl.checkout('fb', :new_branch => 'master')
183
+ gp = GitProc::Process.new(gl)
184
+ gp.stub(:ask_about_removing_master).and_return(true)
184
185
 
185
- gp.checkout('fb', :new_branch => 'master')
186
- gp.stub(:ask_about_removing_master).and_return(true)
187
-
188
- gp.fetch
189
- gp.verify_preconditions
186
+ gl.fetch
187
+ gp.verify_preconditions
190
188
 
191
- gp.branches.include?('master').should be_false
189
+ gl.branches.include?('master').should be_false
190
+ end
192
191
  end
193
192
 
194
193
  end
195
194
 
196
195
 
197
196
  it "should not remove the int-branch if not a clone" do
198
- gitprocess.config('gitProcess.keepLocalIntegrationBranch', 'false')
199
- gitprocess.checkout('fb', :new_branch => 'master')
197
+ gitlib.config['gitProcess.keepLocalIntegrationBranch'] = 'false'
198
+ gitlib.checkout('fb', :new_branch => 'master')
200
199
 
200
+ gitprocess = GitProc::Process.new(gitlib)
201
201
  gitprocess.verify_preconditions
202
202
 
203
- gitprocess.branches.include?('master').should be_true
203
+ gitlib.branches.include?('master').should be_true
204
204
  end
205
205
 
206
206
  end