socialcast-git-extensions 3.1.5 → 3.1.6

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmExZmQyNTY0YjJlNWM0ZTg4NTI2OGE5ODZkNTE2NWZiNzAwMzBiYg==
5
+ data.tar.gz: !binary |-
6
+ YTM0ZWUzN2Y2NzFjZWQ3MWEzNmNlZjM2YjIxY2NmY2IzZjM1M2I3OA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzJkNWRiM2E5YzY4NDNjMGE0MjI5YTUyNTNjNGExMjhkMWM2ZmY3MjliNTQw
10
+ NTRlZjg2ODY3YTg5ODNiZTAwODBlMTdlY2UxYmY1MWQxN2I4YTU0MTQ1OTRm
11
+ NDhjMjFiYzIyNWFiYThhNzNmMjg0ZmQxMmY3ZTdkMmUwYWYxMTI=
12
+ data.tar.gz: !binary |-
13
+ MzRkZDAxYzk1YmZhNTAyOGVkNDc0ZTIzNjRlZWJlNTc5Zjk4ZWE1MmE4Zjkx
14
+ ZTJjN2Y5NjM4MjQwMTk3YWVjN2FmMjYwOTAzYzAzYzFiZTE0MTMxNjM4NzI5
15
+ N2RiZWEzZDcyMTU2NDFhNjU0ZTJlY2NhY2IyYTg0Njg1MDgxNjU=
data/README.rdoc CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  = Core Git Extensions
4
4
 
5
+ === Install
6
+ socialcast authenticate --domain (your domain)
7
+
5
8
  === Options
6
9
  * --quiet => supress posting message in Socialcast
7
10
 
data/config/scgitx.yml CHANGED
@@ -4,5 +4,9 @@ review_buddies:
4
4
  socialcast_username: VanMiranda
5
5
  buddy: wireframe
6
6
  wireframe:
7
- socialcast_username: RyanSonnek
7
+ socialcast_username: RyanSonnek
8
8
  buddy: vanm
9
+
10
+ base_branch: master
11
+ staging_branch: staging
12
+ prototype_branch: prototype
@@ -6,7 +6,9 @@ require 'socialcast-git-extensions/github'
6
6
 
7
7
  module Socialcast
8
8
  module Gitx
9
- BASE_BRANCH = 'master'
9
+ DEFAULT_BASE_BRANCH = 'master'
10
+ DEFAULT_STAGING_BRANCH = 'staging'
11
+ DEFAULT_PROTOTYPE_BRANCH = 'prototype'
10
12
 
11
13
  private
12
14
  # execute a shell command and raise an error if non-zero exit code is returned
@@ -56,21 +56,21 @@ module Socialcast
56
56
  say 'updating '
57
57
  say "#{branch} ", :green
58
58
  say "to have most recent changes from "
59
- say Socialcast::Gitx::BASE_BRANCH, :green
59
+ say base_branch, :green
60
60
 
61
61
  run_cmd "git pull origin #{branch}" rescue nil
62
- run_cmd "git pull origin #{Socialcast::Gitx::BASE_BRANCH}"
62
+ run_cmd "git pull origin #{base_branch}"
63
63
  run_cmd 'git push origin HEAD'
64
64
  end
65
65
 
66
66
  desc 'cleanup', 'Cleanup branches that have been merged into master from the repo'
67
67
  def cleanup
68
- run_cmd "git checkout #{Socialcast::Gitx::BASE_BRANCH}"
68
+ run_cmd "git checkout #{base_branch}"
69
69
  run_cmd "git pull"
70
70
  run_cmd 'git remote prune origin'
71
71
 
72
72
  say "Deleting branches that have been merged into "
73
- say Socialcast::Gitx::BASE_BRANCH, :green
73
+ say base_branch, :green
74
74
  branches(:merged => true, :remote => true).each do |branch|
75
75
  run_cmd "git push origin --delete #{branch}" unless aggregate_branch?(branch)
76
76
  end
@@ -98,7 +98,7 @@ module Socialcast
98
98
  end
99
99
  end
100
100
 
101
- run_cmd "git checkout #{Socialcast::Gitx::BASE_BRANCH}"
101
+ run_cmd "git checkout #{base_branch}"
102
102
  run_cmd 'git pull'
103
103
  run_cmd "git checkout -b #{branch_name}"
104
104
 
@@ -111,12 +111,12 @@ module Socialcast
111
111
  end
112
112
 
113
113
  desc 'integrate', 'integrate the current branch into one of the aggregate development branches'
114
- def integrate(target_branch = 'prototype')
114
+ def integrate(target_branch = prototype_branch)
115
115
  branch = current_branch
116
116
 
117
117
  update
118
118
  integrate_branch(branch, target_branch)
119
- integrate_branch(target_branch, 'prototype') if target_branch == 'staging'
119
+ integrate_branch(target_branch, prototype_branch) if target_branch == staging_branch
120
120
  run_cmd "git checkout #{branch}"
121
121
 
122
122
  post "#worklog integrating #{branch} into #{target_branch} #scgitx"
@@ -124,8 +124,8 @@ module Socialcast
124
124
 
125
125
  desc 'promote', '(DEPRECATED) promote the current branch into staging'
126
126
  def promote
127
- say 'DEPRECATED: Use `git integrate staging` instead', :red
128
- integrate 'staging'
127
+ say "DEPRECATED: Use `git integrate #{staging_branch}` instead", :red
128
+ integrate staging_branch
129
129
  end
130
130
 
131
131
  desc 'nuke', 'nuke the specified aggregate branch and reset it to a known good state'
@@ -158,14 +158,14 @@ module Socialcast
158
158
  return unless yes?("Release #{branch} to production? (y/n)", :green)
159
159
 
160
160
  update
161
- run_cmd "git checkout #{Socialcast::Gitx::BASE_BRANCH}"
162
- run_cmd "git pull origin #{Socialcast::Gitx::BASE_BRANCH}"
161
+ run_cmd "git checkout #{base_branch}"
162
+ run_cmd "git pull origin #{base_branch}"
163
163
  run_cmd "git pull . #{branch}"
164
164
  run_cmd "git push origin HEAD"
165
- integrate_branch('master', 'staging')
165
+ integrate_branch(base_branch, staging_branch)
166
166
  cleanup
167
167
 
168
- post "#worklog releasing #{branch} to production #scgitx"
168
+ post "#worklog releasing #{branch} to #{base_branch} #scgitx"
169
169
  end
170
170
 
171
171
  private
@@ -4,12 +4,9 @@ require 'pathname'
4
4
  module Socialcast
5
5
  module Gitx
6
6
  module Git
7
- AGGREGATE_BRANCHES = %w{ staging prototype }
8
- RESERVED_BRANCHES = %w{ HEAD master next_release } + AGGREGATE_BRANCHES
9
-
10
7
  private
11
8
  def assert_not_protected_branch!(branch, action)
12
- raise "Cannot #{action} reserved branch" if RESERVED_BRANCHES.include?(branch) || aggregate_branch?(branch)
9
+ raise "Cannot #{action} reserved branch" if reserved_branches.include?(branch) || aggregate_branch?(branch)
13
10
  end
14
11
 
15
12
  # lookup the current branch of the PWD
@@ -41,7 +38,7 @@ module Socialcast
41
38
  output.each do |branch|
42
39
  branch = branch.gsub(/\*/, '').strip.split(' ').first
43
40
  branch = branch.split('/').last if options[:remote]
44
- branches << branch unless RESERVED_BRANCHES.include?(branch)
41
+ branches << branch unless reserved_branches.include?(branch)
45
42
  end
46
43
  branches.uniq
47
44
  end
@@ -51,20 +48,20 @@ module Socialcast
51
48
  # returns list of branches that were removed
52
49
  def nuke_branch(branch, head_branch)
53
50
  return [] if branch == head_branch
54
- raise "Only aggregate branches are allowed to be reset: #{AGGREGATE_BRANCHES}" unless aggregate_branch?(branch)
51
+ raise "Only aggregate branches are allowed to be reset: #{aggregate_branches}" unless aggregate_branch?(branch)
55
52
  say "Resetting "
56
53
  say "#{branch} ", :green
57
54
  say "branch to "
58
55
  say head_branch, :green
59
56
 
60
- run_cmd "git checkout #{Socialcast::Gitx::BASE_BRANCH}"
57
+ run_cmd "git checkout #{base_branch}"
61
58
  refresh_branch_from_remote head_branch
62
59
  removed_branches = branches(:remote => true, :merged => "origin/#{branch}") - branches(:remote => true, :merged => "origin/#{head_branch}")
63
60
  run_cmd "git branch -D #{branch}" rescue nil
64
61
  run_cmd "git push origin --delete #{branch}" rescue nil
65
62
  run_cmd "git checkout -b #{branch}"
66
63
  share_branch branch
67
- run_cmd "git checkout #{Socialcast::Gitx::BASE_BRANCH}"
64
+ run_cmd "git checkout #{base_branch}"
68
65
 
69
66
  removed_branches
70
67
  end
@@ -83,7 +80,9 @@ module Socialcast
83
80
  # blow away the local aggregate branch to ensure pulling into most recent "clean" branch
84
81
  def integrate_branch(branch, destination_branch)
85
82
  assert_not_protected_branch!(branch, 'integrate') unless aggregate_branch?(destination_branch)
86
- raise "Only aggregate branches are allowed for integration: #{AGGREGATE_BRANCHES}" unless aggregate_branch?(destination_branch) || destination_branch == Socialcast::Gitx::BASE_BRANCH
83
+ unless aggregate_branch?(destination_branch) || [base_branch, Socialcast::Gitx::DEFAULT_BASE_BRANCH].include?(destination_branch)
84
+ raise "Only aggregate branches are allowed for integration: #{aggregate_branches}"
85
+ end
87
86
  say "Integrating "
88
87
  say "#{branch} ", :green
89
88
  say "into "
@@ -103,12 +102,12 @@ module Socialcast
103
102
  end
104
103
 
105
104
  def aggregate_branch?(branch)
106
- AGGREGATE_BRANCHES.include?(branch) || branch.starts_with?('last_known_good')
105
+ aggregate_branches.include?(branch) || branch.starts_with?('last_known_good')
107
106
  end
108
107
 
109
108
  # build a summary of changes
110
109
  def changelog_summary(branch)
111
- changes = `git diff --stat origin/#{Socialcast::Gitx::BASE_BRANCH}...#{branch}`.split("\n")
110
+ changes = `git diff --stat origin/#{base_branch}...#{branch}`.split("\n")
112
111
  stats = changes.pop
113
112
  if changes.length > 5
114
113
  dirs = changes.map do |file_change|
@@ -157,7 +156,7 @@ module Socialcast
157
156
  end
158
157
  end
159
158
  end
160
-
159
+
161
160
  # @returns a [Pathname] for the scgitx.yml Config File
162
161
  # from either ENV['SCGITX_CONFIG_PATH'] or default $PWD/config/scgitx.yml
163
162
  def config_file
@@ -169,6 +168,26 @@ module Socialcast
169
168
  def review_buddies
170
169
  config['review_buddies'] || {}
171
170
  end
171
+
172
+ def base_branch
173
+ config['base_branch'] || Socialcast::Gitx::DEFAULT_BASE_BRANCH
174
+ end
175
+
176
+ def staging_branch
177
+ config['staging_branch'] || Socialcast::Gitx::DEFAULT_STAGING_BRANCH
178
+ end
179
+
180
+ def prototype_branch
181
+ config['prototype_branch'] || Socialcast::Gitx::DEFAULT_PROTOTYPE_BRANCH
182
+ end
183
+
184
+ def aggregate_branches
185
+ @aggregate_branches ||= [staging_branch, prototype_branch]
186
+ end
187
+
188
+ def reserved_branches
189
+ @reserved_branches ||= %w{ HEAD next_release } + [base_branch] + aggregate_branches
190
+ end
172
191
  end
173
192
  end
174
193
  end
@@ -33,11 +33,11 @@ module Socialcast
33
33
  # returns the url of the created pull request
34
34
  # @see http://developer.github.com/v3/pulls/
35
35
  def create_pull_request(token, branch, repo, body)
36
- payload = {:title => branch, :base => Socialcast::Gitx::BASE_BRANCH, :head => branch, :body => body}.to_json
36
+ payload = {:title => branch, :base => base_branch, :head => branch, :body => body}.to_json
37
37
  say "Creating pull request for "
38
38
  say "#{branch} ", :green
39
39
  say "against "
40
- say "#{Socialcast::Gitx::BASE_BRANCH} ", :green
40
+ say "#{base_branch} ", :green
41
41
  say "in "
42
42
  say repo, :green
43
43
  response = RestClient::Request.new(:url => "https://api.github.com/repos/#{repo}/pulls", :method => "POST", :payload => payload, :headers => {:accept => :json, :content_type => :json, 'Authorization' => "token #{token}"}).execute
@@ -53,12 +53,12 @@ module Socialcast
53
53
  data = JSON.parse e.http_body
54
54
  say "Failed to create pull request: #{data['message']}", :red
55
55
  end
56
-
56
+
57
57
  # @returns [String] socialcast username to assign the review to
58
58
  # @returns [nil] when no buddy system configured or user not found
59
59
  def socialcast_review_buddy(current_user)
60
60
  review_requestor = review_buddies[current_user]
61
-
61
+
62
62
  if review_requestor && review_buddies[review_requestor['buddy']]
63
63
  review_buddies[review_requestor['buddy']]['socialcast_username']
64
64
  end
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module Gitx
3
- VERSION = "3.1.5"
3
+ VERSION = "3.1.6"
4
4
  end
5
5
  end
data/spec/cli_spec.rb CHANGED
@@ -57,6 +57,28 @@ describe Socialcast::Gitx::CLI do
57
57
  ]
58
58
  end
59
59
  end
60
+ context 'when target branch is ommitted with custom prototype branch' do
61
+ before do
62
+ Socialcast::Gitx::CLI.any_instance.stub(:prototype_branch).and_return('special-prototype')
63
+ Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog integrating FOO into special-prototype #scgitx")
64
+ Socialcast::Gitx::CLI.start ['integrate']
65
+ end
66
+ it 'should post message to socialcast' do end # see expectations
67
+ it 'should default to prototype' do
68
+ Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
69
+ "git pull origin FOO",
70
+ "git pull origin master",
71
+ "git push origin HEAD",
72
+ "git branch -D special-prototype",
73
+ "git fetch origin",
74
+ "git checkout special-prototype",
75
+ "git pull . FOO",
76
+ "git push origin HEAD",
77
+ "git checkout FOO",
78
+ "git checkout FOO"
79
+ ]
80
+ end
81
+ end
60
82
  context 'when target branch == prototype' do
61
83
  before do
62
84
  Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog integrating FOO into prototype #scgitx")
@@ -126,7 +148,7 @@ describe Socialcast::Gitx::CLI do
126
148
  end
127
149
  context 'when user confirms release' do
128
150
  before do
129
- Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog releasing FOO to production #scgitx")
151
+ Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog releasing FOO to master #scgitx")
130
152
  Socialcast::Gitx::CLI.any_instance.should_receive(:yes?).and_return(true)
131
153
  Socialcast::Gitx::CLI.start ['release']
132
154
  end
@@ -152,6 +174,36 @@ describe Socialcast::Gitx::CLI do
152
174
  ]
153
175
  end
154
176
  end
177
+
178
+ context 'with alternative base branch' do
179
+ before do
180
+ Socialcast::Gitx::CLI.any_instance.should_receive(:post).with("#worklog releasing FOO to special-master #scgitx")
181
+ Socialcast::Gitx::CLI.any_instance.should_receive(:yes?).and_return(true)
182
+ Socialcast::Gitx::CLI.any_instance.stub(:base_branch).and_return('special-master')
183
+ Socialcast::Gitx::CLI.start ['release']
184
+ end
185
+ it 'should post message to socialcast' do end # see expectations
186
+ it 'should run expected commands' do
187
+ Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
188
+ "git pull origin FOO",
189
+ "git pull origin special-master",
190
+ "git push origin HEAD",
191
+ "git checkout special-master",
192
+ "git pull origin special-master",
193
+ "git pull . FOO",
194
+ "git push origin HEAD",
195
+ "git branch -D staging",
196
+ "git fetch origin",
197
+ "git checkout staging",
198
+ "git pull . special-master",
199
+ "git push origin HEAD",
200
+ "git checkout special-master",
201
+ "git checkout special-master",
202
+ "git pull",
203
+ "git remote prune origin"
204
+ ]
205
+ end
206
+ end
155
207
  end
156
208
 
157
209
  describe '#nuke' do
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast-git-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
5
- prerelease:
4
+ version: 3.1.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Sonnek
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-10 00:00:00.000000000 Z
11
+ date: 2014-01-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: grit
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: socialcast
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rest-client
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: json_pure
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: thor
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - '='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - '='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: pry
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ! '>='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ! '>='
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: webmock
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ! '>='
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ! '>='
156
137
  - !ruby/object:Gem::Version
@@ -203,27 +184,26 @@ files:
203
184
  - spec/spec_helper.rb
204
185
  homepage: http://github.com/socialcast/socialcast-git-extensions
205
186
  licenses: []
187
+ metadata: {}
206
188
  post_install_message:
207
189
  rdoc_options: []
208
190
  require_paths:
209
191
  - lib
210
192
  required_ruby_version: !ruby/object:Gem::Requirement
211
- none: false
212
193
  requirements:
213
194
  - - ! '>='
214
195
  - !ruby/object:Gem::Version
215
196
  version: '0'
216
197
  required_rubygems_version: !ruby/object:Gem::Requirement
217
- none: false
218
198
  requirements:
219
199
  - - ! '>='
220
200
  - !ruby/object:Gem::Version
221
201
  version: '0'
222
202
  requirements: []
223
203
  rubyforge_project: socialcast-git-extensions
224
- rubygems_version: 1.8.24
204
+ rubygems_version: 2.1.11
225
205
  signing_key:
226
- specification_version: 3
206
+ specification_version: 4
227
207
  summary: git extension scripts for socialcast workflow
228
208
  test_files:
229
209
  - spec/cli_spec.rb