socialcast-git-extensions 3.0.9 → 3.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.
@@ -35,12 +35,15 @@ module Socialcast
|
|
35
35
|
branch = current_branch
|
36
36
|
repo = current_repo
|
37
37
|
url = create_pull_request token, branch, repo, description
|
38
|
+
say "Pull request created: #{url}"
|
38
39
|
|
39
40
|
short_description = description.split("\n").first(5).join("\n")
|
40
|
-
review_message = ["
|
41
|
+
review_message = ["#reviewrequest for #{branch} #scgitx", "/cc @SocialcastDevelopers", short_description, changelog_summary(branch)].join("\n\n")
|
41
42
|
post review_message, :url => url, :message_type => 'review_request'
|
42
43
|
end
|
43
44
|
|
45
|
+
# TODO: use --no-edit to skip merge messages
|
46
|
+
# TODO: use pull --rebase to skip merge commit
|
44
47
|
desc 'update', 'Update the current branch with latest changes from the remote feature branch and master'
|
45
48
|
def update
|
46
49
|
branch = current_branch
|
@@ -64,7 +67,7 @@ module Socialcast
|
|
64
67
|
say "Deleting branches that have been merged into "
|
65
68
|
say Socialcast::Gitx::BASE_BRANCH, :green
|
66
69
|
branches(:merged => true, :remote => true).each do |branch|
|
67
|
-
run_cmd "
|
70
|
+
run_cmd "git push origin --delete #{branch}" unless aggregate_branch?(branch)
|
68
71
|
end
|
69
72
|
branches(:merged => true).each do |branch|
|
70
73
|
run_cmd "git branch -d #{branch}" unless aggregate_branch?(branch)
|
@@ -73,8 +76,7 @@ module Socialcast
|
|
73
76
|
|
74
77
|
desc 'track', 'set the current branch to track the remote branch with the same name'
|
75
78
|
def track
|
76
|
-
|
77
|
-
run_cmd "git branch --set-upstream #{branch} origin/#{branch}"
|
79
|
+
track_branch current_branch
|
78
80
|
end
|
79
81
|
|
80
82
|
desc 'start', 'start a new git branch with latest changes from master'
|
@@ -100,7 +102,7 @@ module Socialcast
|
|
100
102
|
|
101
103
|
desc 'share', 'Share the current branch in the remote repository'
|
102
104
|
def share
|
103
|
-
|
105
|
+
share_branch current_branch
|
104
106
|
end
|
105
107
|
|
106
108
|
desc 'integrate', 'integrate the current branch into one of the aggregate development branches'
|
@@ -129,11 +131,12 @@ module Socialcast
|
|
129
131
|
good_branch = default_good_branch if good_branch.length == 0
|
130
132
|
good_branch = "last_known_good_#{good_branch}" unless good_branch.starts_with?('last_known_good_')
|
131
133
|
|
132
|
-
removed_branches =
|
133
|
-
|
134
|
+
removed_branches = nuke_branch(bad_branch, good_branch)
|
135
|
+
nuke_branch("last_known_good_#{bad_branch}", good_branch)
|
134
136
|
|
135
137
|
message_parts = []
|
136
138
|
message_parts << "#worklog resetting #{bad_branch} branch to #{good_branch} #scgitx"
|
139
|
+
message_parts << "/cc @SocialcastDevelopers"
|
137
140
|
if removed_branches.any?
|
138
141
|
message_parts << ""
|
139
142
|
message_parts << "the following branches were affected:"
|
@@ -42,7 +42,7 @@ module Socialcast
|
|
42
42
|
# reset the specified branch to the same set of commits as the destination branch
|
43
43
|
# reverts commits on aggregate branches back to a known good state
|
44
44
|
# returns list of branches that were removed
|
45
|
-
def
|
45
|
+
def nuke_branch(branch, head_branch)
|
46
46
|
return [] if branch == head_branch
|
47
47
|
raise "Only aggregate branches are allowed to be reset: #{AGGREGATE_BRANCHES}" unless aggregate_branch?(branch)
|
48
48
|
say "Resetting "
|
@@ -56,12 +56,22 @@ module Socialcast
|
|
56
56
|
run_cmd "git branch -D #{branch}" rescue nil
|
57
57
|
run_cmd "git push origin --delete #{branch}" rescue nil
|
58
58
|
run_cmd "git checkout -b #{branch}"
|
59
|
-
|
59
|
+
share_branch branch
|
60
60
|
run_cmd "git checkout #{Socialcast::Gitx::BASE_BRANCH}"
|
61
61
|
|
62
62
|
removed_branches
|
63
63
|
end
|
64
64
|
|
65
|
+
# share the local branch in the remote repo
|
66
|
+
def share_branch(branch)
|
67
|
+
run_cmd "git push origin #{branch}"
|
68
|
+
track_branch branch
|
69
|
+
end
|
70
|
+
|
71
|
+
def track_branch(branch)
|
72
|
+
run_cmd "git branch --set-upstream #{branch} origin/#{branch}"
|
73
|
+
end
|
74
|
+
|
65
75
|
# integrate a branch into a destination aggregate branch
|
66
76
|
# blow away the local aggregate branch to ensure pulling into most recent "clean" branch
|
67
77
|
def integrate_branch(branch, destination_branch)
|
@@ -81,8 +91,8 @@ module Socialcast
|
|
81
91
|
# nuke local branch and pull fresh version from remote repo
|
82
92
|
def refresh_branch_from_remote(destination_branch)
|
83
93
|
run_cmd "git branch -D #{destination_branch}" rescue nil
|
94
|
+
run_cmd "git fetch origin"
|
84
95
|
run_cmd "git checkout #{destination_branch}"
|
85
|
-
run_cmd "git pull origin #{destination_branch}"
|
86
96
|
end
|
87
97
|
|
88
98
|
def aggregate_branch?(branch)
|
@@ -15,7 +15,6 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "socialcast-git-extensions"
|
16
16
|
|
17
17
|
s.add_runtime_dependency(%q<grit>, [">= 0"])
|
18
|
-
s.add_runtime_dependency(%q<git_remote_branch>, [">= 0"])
|
19
18
|
s.add_runtime_dependency(%q<socialcast>, [">= 1.1.4"])
|
20
19
|
s.add_runtime_dependency(%q<rest-client>, [">= 1.4.0"])
|
21
20
|
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
data/spec/cli_spec.rb
CHANGED
@@ -47,8 +47,8 @@ describe Socialcast::Gitx::CLI do
|
|
47
47
|
"git pull origin master",
|
48
48
|
"git push origin HEAD",
|
49
49
|
"git branch -D prototype",
|
50
|
+
"git fetch origin",
|
50
51
|
"git checkout prototype",
|
51
|
-
"git pull origin prototype",
|
52
52
|
"git pull . FOO",
|
53
53
|
"git push origin HEAD",
|
54
54
|
"git checkout FOO",
|
@@ -68,8 +68,8 @@ describe Socialcast::Gitx::CLI do
|
|
68
68
|
"git pull origin master",
|
69
69
|
"git push origin HEAD",
|
70
70
|
"git branch -D prototype",
|
71
|
+
"git fetch origin",
|
71
72
|
"git checkout prototype",
|
72
|
-
"git pull origin prototype",
|
73
73
|
"git pull . FOO",
|
74
74
|
"git push origin HEAD",
|
75
75
|
"git checkout FOO",
|
@@ -89,14 +89,14 @@ describe Socialcast::Gitx::CLI do
|
|
89
89
|
"git pull origin master",
|
90
90
|
"git push origin HEAD",
|
91
91
|
"git branch -D staging",
|
92
|
+
"git fetch origin",
|
92
93
|
"git checkout staging",
|
93
|
-
"git pull origin staging",
|
94
94
|
"git pull . FOO",
|
95
95
|
"git push origin HEAD",
|
96
96
|
"git checkout FOO",
|
97
97
|
"git branch -D prototype",
|
98
|
+
"git fetch origin",
|
98
99
|
"git checkout prototype",
|
99
|
-
"git pull origin prototype",
|
100
100
|
"git pull . staging",
|
101
101
|
"git push origin HEAD",
|
102
102
|
"git checkout staging",
|
@@ -140,8 +140,8 @@ describe Socialcast::Gitx::CLI do
|
|
140
140
|
"git pull . FOO",
|
141
141
|
"git push origin HEAD",
|
142
142
|
"git branch -D staging",
|
143
|
+
"git fetch origin",
|
143
144
|
"git checkout staging",
|
144
|
-
"git pull origin staging",
|
145
145
|
"git pull . master",
|
146
146
|
"git push origin HEAD",
|
147
147
|
"git checkout master",
|
@@ -159,7 +159,7 @@ describe Socialcast::Gitx::CLI do
|
|
159
159
|
prototype_branches = %w( dev-foo dev-bar )
|
160
160
|
master_branches = %w( dev-foo )
|
161
161
|
Socialcast::Gitx::CLI.any_instance.should_receive(:branches).and_return(prototype_branches, master_branches, prototype_branches, master_branches)
|
162
|
-
Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog resetting prototype branch to last_known_good_master #scgitx\n\nthe following branches were affected:\n* dev-bar")
|
162
|
+
Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog resetting prototype branch to last_known_good_master #scgitx\n/cc @SocialcastDevelopers\n\nthe following branches were affected:\n* dev-bar")
|
163
163
|
Socialcast::Gitx::CLI.start ['nuke', 'prototype', '--destination', 'master']
|
164
164
|
end
|
165
165
|
it 'should publish message into socialcast' do end # see expectations
|
@@ -167,21 +167,23 @@ describe Socialcast::Gitx::CLI do
|
|
167
167
|
Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
|
168
168
|
"git checkout master",
|
169
169
|
"git branch -D last_known_good_master",
|
170
|
+
"git fetch origin",
|
170
171
|
"git checkout last_known_good_master",
|
171
|
-
"git pull origin last_known_good_master",
|
172
172
|
"git branch -D prototype",
|
173
173
|
"git push origin --delete prototype",
|
174
174
|
"git checkout -b prototype",
|
175
|
-
"
|
175
|
+
"git push origin prototype",
|
176
|
+
"git branch --set-upstream prototype origin/prototype",
|
176
177
|
"git checkout master",
|
177
178
|
"git checkout master",
|
178
179
|
"git branch -D last_known_good_master",
|
180
|
+
"git fetch origin",
|
179
181
|
"git checkout last_known_good_master",
|
180
|
-
"git pull origin last_known_good_master",
|
181
182
|
"git branch -D last_known_good_prototype",
|
182
183
|
"git push origin --delete last_known_good_prototype",
|
183
184
|
"git checkout -b last_known_good_prototype",
|
184
|
-
"
|
185
|
+
"git push origin last_known_good_prototype",
|
186
|
+
"git branch --set-upstream last_known_good_prototype origin/last_known_good_prototype",
|
185
187
|
"git checkout master"
|
186
188
|
]
|
187
189
|
end
|
@@ -194,12 +196,13 @@ describe Socialcast::Gitx::CLI do
|
|
194
196
|
Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
|
195
197
|
"git checkout master",
|
196
198
|
"git branch -D last_known_good_staging",
|
199
|
+
"git fetch origin",
|
197
200
|
"git checkout last_known_good_staging",
|
198
|
-
"git pull origin last_known_good_staging",
|
199
201
|
"git branch -D staging",
|
200
202
|
"git push origin --delete staging",
|
201
203
|
"git checkout -b staging",
|
202
|
-
"
|
204
|
+
"git push origin staging",
|
205
|
+
"git branch --set-upstream staging origin/staging",
|
203
206
|
"git checkout master"
|
204
207
|
]
|
205
208
|
end
|
@@ -213,12 +216,13 @@ describe Socialcast::Gitx::CLI do
|
|
213
216
|
Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
|
214
217
|
"git checkout master",
|
215
218
|
"git branch -D last_known_good_prototype",
|
219
|
+
"git fetch origin",
|
216
220
|
"git checkout last_known_good_prototype",
|
217
|
-
"git pull origin last_known_good_prototype",
|
218
221
|
"git branch -D prototype",
|
219
222
|
"git push origin --delete prototype",
|
220
223
|
"git checkout -b prototype",
|
221
|
-
"
|
224
|
+
"git push origin prototype",
|
225
|
+
"git branch --set-upstream prototype origin/prototype",
|
222
226
|
"git checkout master"
|
223
227
|
]
|
224
228
|
end
|
@@ -232,21 +236,23 @@ describe Socialcast::Gitx::CLI do
|
|
232
236
|
Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
|
233
237
|
"git checkout master",
|
234
238
|
"git branch -D last_known_good_master",
|
239
|
+
"git fetch origin",
|
235
240
|
"git checkout last_known_good_master",
|
236
|
-
"git pull origin last_known_good_master",
|
237
241
|
"git branch -D prototype",
|
238
242
|
"git push origin --delete prototype",
|
239
243
|
"git checkout -b prototype",
|
240
|
-
"
|
244
|
+
"git push origin prototype",
|
245
|
+
"git branch --set-upstream prototype origin/prototype",
|
241
246
|
"git checkout master",
|
242
247
|
"git checkout master",
|
243
248
|
"git branch -D last_known_good_master",
|
249
|
+
"git fetch origin",
|
244
250
|
"git checkout last_known_good_master",
|
245
|
-
"git pull origin last_known_good_master",
|
246
251
|
"git branch -D last_known_good_prototype",
|
247
252
|
"git push origin --delete last_known_good_prototype",
|
248
253
|
"git checkout -b last_known_good_prototype",
|
249
|
-
"
|
254
|
+
"git push origin last_known_good_prototype",
|
255
|
+
"git branch --set-upstream last_known_good_prototype origin/last_known_good_prototype",
|
250
256
|
"git checkout master"
|
251
257
|
]
|
252
258
|
end
|
@@ -267,7 +273,7 @@ describe Socialcast::Gitx::CLI do
|
|
267
273
|
stub_request(:post, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls").
|
268
274
|
to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1"}), :headers => {})
|
269
275
|
|
270
|
-
Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("
|
276
|
+
Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#reviewrequest for FOO #scgitx\n\n/cc @SocialcastDevelopers\n\ntesting\n\n", :url => 'http://github.com/repo/project/pulls/1', :message_type => 'review_request')
|
271
277
|
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing']
|
272
278
|
end
|
273
279
|
it 'should create github pull request' do end # see expectations
|
@@ -292,14 +298,14 @@ describe Socialcast::Gitx::CLI do
|
|
292
298
|
"git pull origin master",
|
293
299
|
"git push origin HEAD",
|
294
300
|
"git branch -D staging",
|
301
|
+
"git fetch origin",
|
295
302
|
"git checkout staging",
|
296
|
-
"git pull origin staging",
|
297
303
|
"git pull . FOO",
|
298
304
|
"git push origin HEAD",
|
299
305
|
"git checkout FOO",
|
300
306
|
"git branch -D prototype",
|
307
|
+
"git fetch origin",
|
301
308
|
"git checkout prototype",
|
302
|
-
"git pull origin prototype",
|
303
309
|
"git pull . staging",
|
304
310
|
"git push origin HEAD",
|
305
311
|
"git checkout staging",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialcast-git-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: git_remote_branch
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: socialcast
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
214
|
version: '0'
|
231
215
|
segments:
|
232
216
|
- 0
|
233
|
-
hash:
|
217
|
+
hash: -204662035920604822
|
234
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
219
|
none: false
|
236
220
|
requirements:
|
@@ -239,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
223
|
version: '0'
|
240
224
|
segments:
|
241
225
|
- 0
|
242
|
-
hash:
|
226
|
+
hash: -204662035920604822
|
243
227
|
requirements: []
|
244
228
|
rubyforge_project: socialcast-git-extensions
|
245
229
|
rubygems_version: 1.8.24
|