socialcast-git-extensions 3.0.0.pre4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/git-promote +4 -0
- data/bin/git-update +1 -2
- data/lib/socialcast-git-extensions/cli.rb +6 -40
- data/lib/socialcast-git-extensions/git.rb +42 -3
- data/lib/socialcast-git-extensions/version.rb +1 -1
- data/spec/cli_spec.rb +32 -7
- metadata +11 -6
data/bin/git-promote
ADDED
data/bin/git-update
CHANGED
@@ -115,6 +115,12 @@ module Socialcast
|
|
115
115
|
post "#worklog integrating #{branch} into #{target_branch} #scgitx"
|
116
116
|
end
|
117
117
|
|
118
|
+
desc 'promote', '(DEPRECATED) promote the current branch into staging'
|
119
|
+
def promote
|
120
|
+
say 'DEPRECATED: Use `git integrate staging` instead', :red
|
121
|
+
integrate 'staging'
|
122
|
+
end
|
123
|
+
|
118
124
|
desc 'nuke', 'nuke the specified aggregate branch and reset it to a known good state'
|
119
125
|
method_option :destination, :type => :string, :aliases => '-d', :desc => 'destination branch to reset to'
|
120
126
|
def nuke(bad_branch)
|
@@ -146,46 +152,6 @@ module Socialcast
|
|
146
152
|
|
147
153
|
private
|
148
154
|
|
149
|
-
# build a summary of changes
|
150
|
-
def changelog_summary(branch)
|
151
|
-
changes = `git diff --stat origin/#{Socialcast::Gitx::BASE_BRANCH}...#{branch}`.split("\n")
|
152
|
-
stats = changes.pop
|
153
|
-
if changes.length > 5
|
154
|
-
dirs = changes.map do |file_change|
|
155
|
-
filename = "#{file_change.split.first}"
|
156
|
-
dir = filename.gsub(/\/[^\/]+$/, '')
|
157
|
-
dir
|
158
|
-
end
|
159
|
-
dir_counts = Hash.new(0)
|
160
|
-
dirs.each {|dir| dir_counts[dir] += 1 }
|
161
|
-
changes = dir_counts.to_a.sort_by {|k,v| v}.reverse.first(5).map {|k,v| "#{k} (#{v} file#{'s' if v > 1})"}
|
162
|
-
end
|
163
|
-
(changes + [stats]).join("\n")
|
164
|
-
end
|
165
|
-
|
166
|
-
# launch configured editor to retreive message/string
|
167
|
-
def editor_input(initial_text = '')
|
168
|
-
require 'tempfile'
|
169
|
-
Tempfile.open('reviewrequest.md') do |f|
|
170
|
-
f << initial_text
|
171
|
-
f.flush
|
172
|
-
|
173
|
-
editor = ENV['EDITOR'] || 'vi'
|
174
|
-
flags = case editor
|
175
|
-
when 'mate', 'emacs'
|
176
|
-
'-w'
|
177
|
-
when 'mvim'
|
178
|
-
'-f'
|
179
|
-
else
|
180
|
-
''
|
181
|
-
end
|
182
|
-
pid = fork { exec "#{editor} #{flags} #{f.path}" }
|
183
|
-
Process.waitpid(pid)
|
184
|
-
description = File.read(f.path)
|
185
|
-
description.gsub(/^\#.*/, '').chomp.strip
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
155
|
# post a message in socialcast
|
190
156
|
# skip sharing message if CLI quiet option is present
|
191
157
|
def post(message, params = {})
|
@@ -3,7 +3,8 @@ require 'grit'
|
|
3
3
|
module Socialcast
|
4
4
|
module Gitx
|
5
5
|
module Git
|
6
|
-
|
6
|
+
AGGREGATE_BRANCHES = %w{ staging prototype }
|
7
|
+
RESERVED_BRANCHES = %w{ HEAD master next_release } + AGGREGATE_BRANCHES
|
7
8
|
|
8
9
|
private
|
9
10
|
def assert_not_protected_branch!(branch, action)
|
@@ -38,7 +39,6 @@ module Socialcast
|
|
38
39
|
branches.uniq
|
39
40
|
end
|
40
41
|
|
41
|
-
AGGREGATE_BRANCHES = %w{ staging prototype }
|
42
42
|
# reset the specified branch to the same set of commits as the destination branch
|
43
43
|
# used to revert commits on aggregate branches back to a known good state
|
44
44
|
def reset_branch(branch, head_branch)
|
@@ -77,10 +77,49 @@ module Socialcast
|
|
77
77
|
run_cmd "git checkout #{branch}"
|
78
78
|
end
|
79
79
|
|
80
|
-
private
|
81
80
|
def aggregate_branch?(branch)
|
82
81
|
AGGREGATE_BRANCHES.include?(branch) || branch.starts_with?('last_known_good')
|
83
82
|
end
|
83
|
+
|
84
|
+
# build a summary of changes
|
85
|
+
def changelog_summary(branch)
|
86
|
+
changes = `git diff --stat origin/#{Socialcast::Gitx::BASE_BRANCH}...#{branch}`.split("\n")
|
87
|
+
stats = changes.pop
|
88
|
+
if changes.length > 5
|
89
|
+
dirs = changes.map do |file_change|
|
90
|
+
filename = "#{file_change.split.first}"
|
91
|
+
dir = filename.gsub(/\/[^\/]+$/, '')
|
92
|
+
dir
|
93
|
+
end
|
94
|
+
dir_counts = Hash.new(0)
|
95
|
+
dirs.each {|dir| dir_counts[dir] += 1 }
|
96
|
+
changes = dir_counts.to_a.sort_by {|k,v| v}.reverse.first(5).map {|k,v| "#{k} (#{v} file#{'s' if v > 1})"}
|
97
|
+
end
|
98
|
+
(changes + [stats]).join("\n")
|
99
|
+
end
|
100
|
+
|
101
|
+
# launch configured editor to retreive message/string
|
102
|
+
def editor_input(initial_text = '')
|
103
|
+
require 'tempfile'
|
104
|
+
Tempfile.open('reviewrequest.md') do |f|
|
105
|
+
f << initial_text
|
106
|
+
f.flush
|
107
|
+
|
108
|
+
editor = ENV['EDITOR'] || 'vi'
|
109
|
+
flags = case editor
|
110
|
+
when 'mate', 'emacs'
|
111
|
+
'-w'
|
112
|
+
when 'mvim'
|
113
|
+
'-f'
|
114
|
+
else
|
115
|
+
''
|
116
|
+
end
|
117
|
+
pid = fork { exec "#{editor} #{flags} #{f.path}" }
|
118
|
+
Process.waitpid(pid)
|
119
|
+
description = File.read(f.path)
|
120
|
+
description.gsub(/^\#.*/, '').chomp.strip
|
121
|
+
end
|
122
|
+
end
|
84
123
|
end
|
85
124
|
end
|
86
125
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -76,7 +76,7 @@ describe Socialcast::Gitx::CLI do
|
|
76
76
|
before do
|
77
77
|
Socialcast::Gitx::CLI.start ['integrate', 'staging']
|
78
78
|
end
|
79
|
-
it 'should run expected commands' do
|
79
|
+
it 'should also integrate into prototype and run expected commands' do
|
80
80
|
Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
|
81
81
|
"git pull origin FOO",
|
82
82
|
"git pull origin master",
|
@@ -163,14 +163,14 @@ describe Socialcast::Gitx::CLI do
|
|
163
163
|
"git checkout last_known_good_master",
|
164
164
|
"git pull",
|
165
165
|
"git branch -D prototype",
|
166
|
-
"git push origin
|
166
|
+
"git push origin --delete prototype",
|
167
167
|
"git checkout -b prototype",
|
168
168
|
"grb publish prototype",
|
169
169
|
"git checkout last_known_good_master",
|
170
170
|
"git checkout last_known_good_master",
|
171
171
|
"git pull",
|
172
172
|
"git branch -D last_known_good_prototype",
|
173
|
-
"git push origin
|
173
|
+
"git push origin --delete last_known_good_prototype",
|
174
174
|
"git checkout -b last_known_good_prototype",
|
175
175
|
"grb publish last_known_good_prototype",
|
176
176
|
"git checkout last_known_good_master"
|
@@ -186,7 +186,7 @@ describe Socialcast::Gitx::CLI do
|
|
186
186
|
"git checkout last_known_good_staging",
|
187
187
|
"git pull",
|
188
188
|
"git branch -D staging",
|
189
|
-
"git push origin
|
189
|
+
"git push origin --delete staging",
|
190
190
|
"git checkout -b staging",
|
191
191
|
"grb publish staging",
|
192
192
|
"git checkout last_known_good_staging"
|
@@ -203,7 +203,7 @@ describe Socialcast::Gitx::CLI do
|
|
203
203
|
"git checkout last_known_good_prototype",
|
204
204
|
"git pull",
|
205
205
|
"git branch -D prototype",
|
206
|
-
"git push origin
|
206
|
+
"git push origin --delete prototype",
|
207
207
|
"git checkout -b prototype",
|
208
208
|
"grb publish prototype",
|
209
209
|
"git checkout last_known_good_prototype"
|
@@ -220,14 +220,14 @@ describe Socialcast::Gitx::CLI do
|
|
220
220
|
"git checkout last_known_good_master",
|
221
221
|
"git pull",
|
222
222
|
"git branch -D prototype",
|
223
|
-
"git push origin
|
223
|
+
"git push origin --delete prototype",
|
224
224
|
"git checkout -b prototype",
|
225
225
|
"grb publish prototype",
|
226
226
|
"git checkout last_known_good_master",
|
227
227
|
"git checkout last_known_good_master",
|
228
228
|
"git pull",
|
229
229
|
"git branch -D last_known_good_prototype",
|
230
|
-
"git push origin
|
230
|
+
"git push origin --delete last_known_good_prototype",
|
231
231
|
"git checkout -b last_known_good_prototype",
|
232
232
|
"grb publish last_known_good_prototype",
|
233
233
|
"git checkout last_known_good_master"
|
@@ -243,4 +243,29 @@ describe Socialcast::Gitx::CLI do
|
|
243
243
|
end
|
244
244
|
end
|
245
245
|
end
|
246
|
+
|
247
|
+
describe '#promote' do
|
248
|
+
before do
|
249
|
+
Socialcast::Gitx::CLI.start ['promote']
|
250
|
+
end
|
251
|
+
it 'should integrate into staging' do
|
252
|
+
Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
|
253
|
+
"git pull origin FOO",
|
254
|
+
"git pull origin master",
|
255
|
+
"git push origin HEAD",
|
256
|
+
"git remote prune origin",
|
257
|
+
"git remote prune origin",
|
258
|
+
"git checkout staging",
|
259
|
+
"git pull . FOO",
|
260
|
+
"git push origin HEAD",
|
261
|
+
"git checkout FOO",
|
262
|
+
"git remote prune origin",
|
263
|
+
"git checkout prototype",
|
264
|
+
"git pull . staging",
|
265
|
+
"git push origin HEAD",
|
266
|
+
"git checkout staging",
|
267
|
+
"git checkout FOO"
|
268
|
+
]
|
269
|
+
end
|
270
|
+
end
|
246
271
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialcast-git-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Sonnek
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
@@ -178,6 +178,7 @@ executables:
|
|
178
178
|
- git-cleanup
|
179
179
|
- git-integrate
|
180
180
|
- git-nuke
|
181
|
+
- git-promote
|
181
182
|
- git-release
|
182
183
|
- git-reviewrequest
|
183
184
|
- git-share
|
@@ -198,6 +199,7 @@ files:
|
|
198
199
|
- bin/git-cleanup
|
199
200
|
- bin/git-integrate
|
200
201
|
- bin/git-nuke
|
202
|
+
- bin/git-promote
|
201
203
|
- bin/git-release
|
202
204
|
- bin/git-reviewrequest
|
203
205
|
- bin/git-share
|
@@ -228,13 +230,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
230
|
version: '0'
|
229
231
|
segments:
|
230
232
|
- 0
|
231
|
-
hash:
|
233
|
+
hash: -1464484862352811039
|
232
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
235
|
none: false
|
234
236
|
requirements:
|
235
|
-
- - ! '
|
237
|
+
- - ! '>='
|
236
238
|
- !ruby/object:Gem::Version
|
237
|
-
version:
|
239
|
+
version: '0'
|
240
|
+
segments:
|
241
|
+
- 0
|
242
|
+
hash: -1464484862352811039
|
238
243
|
requirements: []
|
239
244
|
rubyforge_project: socialcast-git-extensions
|
240
245
|
rubygems_version: 1.8.24
|