socialcast-git-extensions 3.0.0.pre2 → 3.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,9 +1,43 @@
1
1
  = socialcast-git-extensions
2
2
 
3
- Description goes here.
3
+ = Core Git Extensions
4
+
5
+ === Options
6
+ * --quiet => supress posting message in Socialcast
7
+
8
+ == git start <new_branch_name (optional)>
9
+
10
+ update local repository with latest upstream changes and create a new feature branch
11
+
12
+ == git update
13
+
14
+ update the local feature branch with latest remote changes plus upstream released changes.
15
+
16
+ == git integrate <aggregate_branch_name (optional, default: prototype)>
17
+
18
+ integrate the current feature branch into an aggregate branch (ex: prototype, staging)
19
+
20
+ == git reviewrequest
21
+
22
+ create a pull request on github for peer review of the current branch.
23
+
24
+ == git release
25
+
26
+ release the current feature branch to master
27
+
28
+ = Extra Git Extensions
29
+
30
+ == git cleanup
31
+
32
+ delete released branches after they have been merged into master.
33
+
34
+ == git nuke <aggregate_branch_name>
35
+
36
+ reset an aggregate branch (ex: prototype, staging) back to a known good state.
37
+
4
38
 
5
39
  == Note on Patches/Pull Requests
6
-
40
+
7
41
  * Fork the project.
8
42
  * Make your feature addition or bug fix.
9
43
  * Add tests for it. This is important so I don't break it in a
@@ -14,4 +48,4 @@ Description goes here.
14
48
 
15
49
  == Copyright
16
50
 
17
- Copyright (c) 2010 Ryan Sonnek. See LICENSE for details.
51
+ Copyright (c) 2010 Socialcast, Inc. See LICENSE for details.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:cleanup, ARGV)
4
+ Socialcast::Gitx::CLI.start (['cleanup'] + ARGV)
data/bin/git-integrate CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:integrate, ARGV)
4
+ Socialcast::Gitx::CLI.start (['integrate'] + ARGV)
data/bin/git-nuke CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:nuke, ARGV)
4
+ Socialcast::Gitx::CLI.start (['nuke'] + ARGV)
data/bin/git-release CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:release)
4
+ Socialcast::Gitx::CLI.start (['release'] + ARGV)
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:reviewrequest, ARGV)
4
+ Socialcast::Gitx::CLI.start (['reviewrequest'] + ARGV)
data/bin/git-share CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:share, ARGV)
4
+ Socialcast::Gitx::CLI.start (['share'] + ARGV)
data/bin/git-start CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:start, ARGV)
4
+ Socialcast::Gitx::CLI.start (['start'] + ARGV)
data/bin/git-track CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions', 'cli.rb')
4
- script = Socialcast::Gitx::CLI.new
5
- script.invoke(:track, ARGV)
4
+ Socialcast::Gitx::CLI.start (['track'] + ARGV)
@@ -41,7 +41,7 @@ module Socialcast
41
41
  post review_message, {:url => url, :message_type => 'review_request'}
42
42
  end
43
43
 
44
- desc 'update', 'Update the current branch with latest upstream changes'
44
+ desc 'update', 'Update the current branch with latest changes from the remote feature branch and master'
45
45
  def update
46
46
  branch = current_branch
47
47
 
@@ -98,7 +98,7 @@ module Socialcast
98
98
  post "#worklog starting work on #{branch_name} #scgitx"
99
99
  end
100
100
 
101
- desc 'share', 'publish the current branch for peer review'
101
+ desc 'share', 'Share the current branch in the remote repository'
102
102
  def share
103
103
  run_cmd "grb publish #{current_branch}"
104
104
  end
@@ -118,8 +118,9 @@ module Socialcast
118
118
  desc 'nuke', 'nuke the specified aggregate branch and reset it to a known good state'
119
119
  method_option :destination, :type => :string, :aliases => '-d', :desc => 'destination branch to reset to'
120
120
  def nuke(bad_branch)
121
- good_branch = options[:destination] || ask("What branch do you want to reset #{bad_branch} to? (default: #{Socialcast::Gitx::BASE_BRANCH})")
122
- good_branch = Socialcast::Gitx::BASE_BRANCH if good_branch.length == 0
121
+ default_good_branch = "last_known_good_#{bad_branch}"
122
+ good_branch = options[:destination] || ask("What branch do you want to reset #{bad_branch} to? (default: #{default_good_branch})")
123
+ good_branch = default_good_branch if good_branch.length == 0
123
124
  good_branch = "last_known_good_#{good_branch}" unless good_branch.starts_with?('last_known_good_')
124
125
  removed_branches = reset_branch(bad_branch, good_branch)
125
126
  reset_branch("last_known_good_#{bad_branch}", good_branch) unless "last_known_good_#{bad_branch}" == good_branch
@@ -53,7 +53,7 @@ module Socialcast
53
53
  run_cmd "git pull"
54
54
  removed_branches = branches(:remote => true, :merged => "origin/#{branch}") - branches(:remote => true, :merged => "origin/#{head_branch}")
55
55
  run_cmd "git branch -D #{branch}" rescue nil
56
- run_cmd "git push origin :#{branch}" rescue nil
56
+ run_cmd "git push origin --delete #{branch}" rescue nil
57
57
  run_cmd "git checkout -b #{branch}"
58
58
  run_cmd "grb publish #{branch}"
59
59
  run_cmd "git checkout #{head_branch}"
@@ -24,8 +24,7 @@ module Socialcast
24
24
  Socialcast.credentials = credentials.merge(:scgitx_token => token)
25
25
  token
26
26
  rescue RestClient::Exception => e
27
- data = JSON.parse e.http_body
28
- say "Failed to obtain OAuth authorization token: #{data['message']}"
27
+ process_error e
29
28
  throw e
30
29
  end
31
30
 
@@ -42,10 +41,14 @@ module Socialcast
42
41
  data = JSON.parse response.body
43
42
  url = data['html_url']
44
43
  rescue RestClient::Exception => e
45
- data = JSON.parse e.http_body
46
- say "Failed to create pull request: #{data['message']}"
44
+ process_error e
47
45
  throw e
48
46
  end
47
+
48
+ def process_error(e)
49
+ data = JSON.parse e.http_body
50
+ say "Failed to create pull request: #{data['message']}", :red
51
+ end
49
52
  end
50
53
  end
51
54
  end
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module Gitx
3
- VERSION = "3.0.0.pre2"
3
+ VERSION = "3.0.0.pre4"
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ module Socialcast
11
11
  private
12
12
  # execute a shell command and raise an error if non-zero exit code is returned
13
13
  def run_cmd(cmd)
14
- say "\n> "
14
+ say "\n$ "
15
15
  say cmd.gsub("'", ''), :red
16
16
  raise "#{cmd} failed" unless system cmd
17
17
  end
data/spec/cli_spec.rb CHANGED
@@ -21,8 +21,7 @@ describe Socialcast::Gitx::CLI do
21
21
 
22
22
  describe '#update' do
23
23
  before do
24
- @script = Socialcast::Gitx::CLI.new
25
- @script.invoke :update
24
+ Socialcast::Gitx::CLI.start ['update']
26
25
  end
27
26
  it 'should run expected commands' do
28
27
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -37,8 +36,7 @@ describe Socialcast::Gitx::CLI do
37
36
  describe '#integrate' do
38
37
  context 'when target branch is ommitted' do
39
38
  before do
40
- @script = Socialcast::Gitx::CLI.new
41
- @script.invoke :integrate
39
+ Socialcast::Gitx::CLI.start ['integrate']
42
40
  end
43
41
  it 'should default to prototype' do
44
42
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -57,8 +55,7 @@ describe Socialcast::Gitx::CLI do
57
55
  end
58
56
  context 'when target branch == prototype' do
59
57
  before do
60
- @script = Socialcast::Gitx::CLI.new
61
- @script.invoke :integrate, ['prototype']
58
+ Socialcast::Gitx::CLI.start ['integrate', 'prototype']
62
59
  end
63
60
  it 'should run expected commands' do
64
61
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -77,8 +74,7 @@ describe Socialcast::Gitx::CLI do
77
74
  end
78
75
  context 'when target branch == staging' do
79
76
  before do
80
- @script = Socialcast::Gitx::CLI.new
81
- @script.invoke :integrate, ['staging']
77
+ Socialcast::Gitx::CLI.start ['integrate', 'staging']
82
78
  end
83
79
  it 'should run expected commands' do
84
80
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -102,8 +98,9 @@ describe Socialcast::Gitx::CLI do
102
98
  end
103
99
  context 'when target branch != staging || prototype' do
104
100
  it 'should raise an error' do
105
- @script = Socialcast::Gitx::CLI.new
106
- lambda { @script.invoke :integrate, ['asdfasdf'] }.should raise_error(/Only aggregate branches are allowed for integration/)
101
+ lambda {
102
+ Socialcast::Gitx::CLI.start ['integrate', 'asdfasdfasdf']
103
+ }.should raise_error(/Only aggregate branches are allowed for integration/)
107
104
  end
108
105
  end
109
106
  end
@@ -112,8 +109,7 @@ describe Socialcast::Gitx::CLI do
112
109
  context 'when user rejects release' do
113
110
  before do
114
111
  Socialcast::Gitx::CLI.any_instance.should_receive(:yes?).and_return(false)
115
- @script = Socialcast::Gitx::CLI.new
116
- @script.invoke :release
112
+ Socialcast::Gitx::CLI.start ['release']
117
113
  end
118
114
  it 'should run no commands' do
119
115
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == []
@@ -122,8 +118,7 @@ describe Socialcast::Gitx::CLI do
122
118
  context 'when user confirms release' do
123
119
  before do
124
120
  Socialcast::Gitx::CLI.any_instance.should_receive(:yes?).and_return(true)
125
- @script = Socialcast::Gitx::CLI.new
126
- @script.invoke :release
121
+ Socialcast::Gitx::CLI.start ['release']
127
122
  end
128
123
  it 'should run expected commands' do
129
124
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -161,8 +156,7 @@ describe Socialcast::Gitx::CLI do
161
156
  describe '#nuke' do
162
157
  context 'when target branch == prototype and --destination == master' do
163
158
  before do
164
- @script = Socialcast::Gitx::CLI.new
165
- @script.invoke :nuke, ['prototype'], {:destination => 'master'}
159
+ Socialcast::Gitx::CLI.start ['nuke', 'prototype', '--destination', 'master']
166
160
  end
167
161
  it 'should run expected commands' do
168
162
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -185,8 +179,7 @@ describe Socialcast::Gitx::CLI do
185
179
  end
186
180
  context 'when target branch == staging and --destination == last_known_good_staging' do
187
181
  before do
188
- @script = Socialcast::Gitx::CLI.new
189
- @script.invoke :nuke, ['staging'], {:destination => 'last_known_good_staging'}
182
+ Socialcast::Gitx::CLI.start ['nuke', 'staging', '--destination', 'last_known_good_staging']
190
183
  end
191
184
  it 'should run expected commands' do
192
185
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -196,40 +189,31 @@ describe Socialcast::Gitx::CLI do
196
189
  "git push origin :staging",
197
190
  "git checkout -b staging",
198
191
  "grb publish staging",
199
- "git checkout last_known_good_staging",
192
+ "git checkout last_known_good_staging"
200
193
  ]
201
194
  end
202
195
  end
203
196
  context 'when target branch == prototype and destination prompt == nil' do
204
197
  before do
205
198
  Socialcast::Gitx::CLI.any_instance.should_receive(:ask).and_return('')
206
- @script = Socialcast::Gitx::CLI.new
207
- @script.invoke :nuke, ['prototype']
199
+ Socialcast::Gitx::CLI.start ['nuke', 'prototype']
208
200
  end
209
- it 'defaults to master and should run expected commands' do
201
+ it 'defaults to last_known_good_prototype and should run expected commands' do
210
202
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
211
- "git checkout last_known_good_master",
203
+ "git checkout last_known_good_prototype",
212
204
  "git pull",
213
205
  "git branch -D prototype",
214
206
  "git push origin :prototype",
215
207
  "git checkout -b prototype",
216
208
  "grb publish prototype",
217
- "git checkout last_known_good_master",
218
- "git checkout last_known_good_master",
219
- "git pull",
220
- "git branch -D last_known_good_prototype",
221
- "git push origin :last_known_good_prototype",
222
- "git checkout -b last_known_good_prototype",
223
- "grb publish last_known_good_prototype",
224
- "git checkout last_known_good_master"
209
+ "git checkout last_known_good_prototype"
225
210
  ]
226
211
  end
227
212
  end
228
213
  context 'when target branch == prototype and destination prompt = master' do
229
214
  before do
230
215
  Socialcast::Gitx::CLI.any_instance.should_receive(:ask).and_return('master')
231
- @script = Socialcast::Gitx::CLI.new
232
- @script.invoke :nuke, ['prototype']
216
+ Socialcast::Gitx::CLI.start ['nuke', 'prototype']
233
217
  end
234
218
  it 'should run expected commands' do
235
219
  Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
@@ -254,8 +238,7 @@ describe Socialcast::Gitx::CLI do
254
238
  it 'should raise error' do
255
239
  lambda {
256
240
  Socialcast::Gitx::CLI.any_instance.should_receive(:ask).and_return('master')
257
- @script = Socialcast::Gitx::CLI.new
258
- @script.invoke :nuke, ['asdfasdf']
241
+ Socialcast::Gitx::CLI.start ['nuke', 'asdfasdf']
259
242
  }.should raise_error /Only aggregate branches are allowed to be reset/
260
243
  end
261
244
  end
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.0.pre2
4
+ version: 3.0.0.pre4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -175,7 +175,7 @@ description: GIT it done!
175
175
  email:
176
176
  - ryan@socialcast.com
177
177
  executables:
178
- - cleanup
178
+ - git-cleanup
179
179
  - git-integrate
180
180
  - git-nuke
181
181
  - git-release
@@ -195,7 +195,7 @@ files:
195
195
  - LICENSE
196
196
  - README.rdoc
197
197
  - Rakefile
198
- - bin/cleanup
198
+ - bin/git-cleanup
199
199
  - bin/git-integrate
200
200
  - bin/git-nuke
201
201
  - bin/git-release
@@ -228,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  segments:
230
230
  - 0
231
- hash: -4402162274573639000
231
+ hash: 3452558432038293622
232
232
  required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  none: false
234
234
  requirements: