socialcast-git-extensions 3.1.14 → 3.1.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -30,7 +30,7 @@ Find pull requests on github including a given commit
30
30
  create a pull request on github for peer review of the current branch.
31
31
 
32
32
  ### Optional:
33
- Specify a Review Buddy mapping that will reference the local Github username and @mention a pre-assigned review buddy in the Socialcast Review Request message. Specify the mapping by creating a Configuration YML file relative to the Repo Root: config/scgitx.yml with the following format:
33
+ Specify a Review Buddy mapping that will reference the local Github username and @mention a pre-assigned review buddy in the Socialcast Review Request message. Specify the mapping by creating a .scgitx YML file relative to the Repo Root: config/scgitx.yml with the following format:
34
34
 
35
35
  ```yaml
36
36
  review_buddies:
@@ -44,6 +44,21 @@ review_buddies:
44
44
 
45
45
  In this example, when Emily runs `git reviewrequest` from her local machine, @BobDavis will receive an @mention in Socialcast notifying him to review her branch. If Bob runs the command, Emily will receive a notice in Socialcast.
46
46
 
47
+ Additionally you can specify a specialty reviewer, such that you can
48
+ notify individuals in your organization with a specific skill set. Like Security, or API's
49
+
50
+ ``` yaml
51
+ specialty_reviewers:
52
+ a:
53
+ label: API
54
+ command: (a)pi
55
+ socialcast_username: JohnSmith
56
+ s:
57
+ label: Security
58
+ command: (s)ecurity
59
+ socialcast_username: KellyWilliams
60
+ ```
61
+
47
62
  ## git release
48
63
 
49
64
  release the current feature branch to master
data/config/scgitx.yml CHANGED
@@ -1,11 +1,21 @@
1
1
  # Map github usernames to Socialcast usernames and assign review buddies
2
2
  review_buddies:
3
- vanm:
4
- socialcast_username: VanMiranda
5
- buddy: wireframe
6
- wireframe:
7
- socialcast_username: RyanSonnek
8
- buddy: vanm
3
+ janesmith:
4
+ socialcast_username: JaneSmith
5
+ buddy: johndoe
6
+ johndoe:
7
+ socialcast_username: JohnDoe
8
+ buddy: janesmith
9
+
10
+ specialty_reviewers:
11
+ a:
12
+ label: API
13
+ command: (a)pi
14
+ socialcast_username: JohnSmith
15
+ s:
16
+ label: Security
17
+ command: (s)ecurity
18
+ socialcast_username: KellyWilliams
9
19
 
10
20
  base_branch: master
11
21
  staging_branch: staging
@@ -11,11 +11,13 @@ module Socialcast
11
11
  DEFAULT_PROTOTYPE_BRANCH = 'prototype'
12
12
 
13
13
  private
14
+
14
15
  # execute a shell command and raise an error if non-zero exit code is returned
15
16
  def run_cmd(cmd)
16
17
  say "\n$ "
17
18
  say cmd.gsub("'", ''), :red
18
19
  raise "#{cmd} failed" unless system cmd
19
20
  end
21
+
20
22
  end
21
23
  end
@@ -1,8 +1,9 @@
1
- require "thor"
1
+ require 'thor'
2
2
  require 'rest_client'
3
3
  require 'socialcast-git-extensions'
4
4
  require 'socialcast'
5
5
  require 'socialcast/command_line/message'
6
+ require 'highline/import'
6
7
 
7
8
  module Socialcast
8
9
  module Gitx
@@ -28,8 +29,10 @@ module Socialcast
28
29
 
29
30
  desc "reviewrequest", "Create a pull request on github"
30
31
  method_option :description, :type => :string, :aliases => '-d', :desc => 'pull request description'
32
+ method_option :additional_reviewers, :type => :string, :aliases => '-a', :desc => 'add additional reviewers to mention automatically, and skips the prompt'
33
+ method_option :skip_additional_reviewers, :type => :string, :aliases => '-s', :desc => 'Skips adding additional reviewers'
31
34
  # @see http://developer.github.com/v3/pulls/
32
- def reviewrequest
35
+ def reviewrequest(*additional_reviewers)
33
36
  token = authorization_token
34
37
 
35
38
  update
@@ -38,6 +41,23 @@ module Socialcast
38
41
  "Assigned to @#{buddy}"
39
42
  end
40
43
 
44
+ if !specialty_reviewers.empty? && !options.key?('skip_additional_reviewers')
45
+ additional_reviewers = options[:additional_reviewers] || additional_reviewers
46
+
47
+ if additional_reviewers.empty?
48
+ prompt_text = "#{specialty_reviewers.map { |_,v| v['command'] }.join(", ")} or (or hit enter to continue): "
49
+ additional_reviewers = $terminal.ask("Notify additional people? #{prompt_text} ")
50
+ end
51
+
52
+ additional_reviewers = additional_reviewers.is_a?(String) ? additional_reviewers.split(" ") : additional_reviewers
53
+
54
+ (specialty_reviewers.keys & additional_reviewers).each do |command|
55
+ reviewer = specialty_reviewers[command]
56
+ review_mention = review_mention || ''
57
+ review_mention += "\nAssigned additionally to @#{reviewer['socialcast_username']} for #{reviewer['label']} review"
58
+ end
59
+ end
60
+
41
61
  assignee = github_review_buddy(current_user)
42
62
 
43
63
  description = options[:description] || editor_input(PULL_REQUEST_DESCRIPTION)
@@ -107,14 +127,13 @@ module Socialcast
107
127
  desc 'start', 'start a new git branch with latest changes from master'
108
128
  def start(branch_name = nil)
109
129
  unless branch_name
110
- example_branch = %w{ api-fix-invalid-auth desktop-cleanup-avatar-markup share-form-add-edit-link }.sort_by { rand }.first
130
+ example_branch = %w{ cpr-3922-api-fix-invalid-auth red-212-desktop-cleanup-avatar-markup red-3212-share-form-add-edit-link }.sample
111
131
  repo = Grit::Repo.new(Dir.pwd)
112
132
  remote_branches = repo.remotes.collect {|b| b.name.split('/').last }
113
- until branch_name = ask("What would you like to name your branch? (ex: #{example_branch})") {|q|
114
- q.validate = Proc.new { |branch|
115
- branch =~ /^[A-Za-z0-9\-_]+$/ && !remote_branches.include?(branch)
116
- }
117
- }
133
+ ## Explicitly use Highline.ask
134
+ branch_name = $terminal.ask("What would you like to name your branch? (ex: #{example_branch})") do |q|
135
+ q.validate = lambda { |branch| branch =~ /^[A-Za-z0-9\-_]+$/ && !remote_branches.include?(branch) }
136
+ q.responses[:not_valid] = "This branch name is either already taken, or is not a valid branch name"
118
137
  end
119
138
  end
120
139
 
@@ -196,8 +215,8 @@ module Socialcast
196
215
  return if options[:quiet]
197
216
  ActiveResource::Base.logger = Logger.new(STDOUT) if options[:trace]
198
217
  Socialcast::CommandLine::Message.configure_from_credentials
199
- Socialcast::CommandLine::Message.create params.merge(:body => message)
200
- say "Message has been posted"
218
+ response = Socialcast::CommandLine::Message.create params.merge(:body => message)
219
+ say "Message has been posted: #{response.permalink_url}"
201
220
  end
202
221
  end
203
222
  end
@@ -173,6 +173,10 @@ module Socialcast
173
173
  config['review_buddies'] || {}
174
174
  end
175
175
 
176
+ def specialty_reviewers
177
+ config['specialty_reviewers'] || {}
178
+ end
179
+
176
180
  def base_branch
177
181
  ENV['BASE_BRANCH'] || config['base_branch'] || Socialcast::Gitx::DEFAULT_BASE_BRANCH
178
182
  end
File without changes
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module Gitx
3
- VERSION = "3.1.14"
3
+ VERSION = "3.1.15"
4
4
  end
5
5
  end
data/spec/cli_spec.rb CHANGED
@@ -14,11 +14,11 @@ describe Socialcast::Gitx::CLI do
14
14
  end
15
15
 
16
16
  def stub_message(message_body, params = {})
17
- json_body = { :message => { :body => message_body }.merge(params) }
17
+ json_body = { :message => { :body => message_body }.merge!(params) }
18
18
 
19
19
  stub_request(:post, "https://testuser:testpassword@testdomain/api/messages.json")
20
- .with(json_body)
21
- .to_return(:status => 200)
20
+ .with(:body => json_body)
21
+ .to_return(:status => 200, :body => '', :headers => {})
22
22
  end
23
23
 
24
24
  before do
@@ -274,7 +274,7 @@ describe Socialcast::Gitx::CLI do
274
274
 
275
275
  context 'with alternative base branch via environment variable overriding base branch in config' do
276
276
  before do
277
- stub_message "#worklog integrating FOO to special-master #scgitx"
277
+ stub_message "#worklog releasing FOO to special-master #scgitx"
278
278
 
279
279
  Socialcast::Gitx::CLI.any_instance.should_receive(:yes?).and_return(true)
280
280
  Socialcast::Gitx::CLI.any_instance.stub(:config).and_return({ 'base_branch' => 'extra-special-master' })
@@ -347,7 +347,7 @@ describe Socialcast::Gitx::CLI do
347
347
  end
348
348
  context 'when target branch == staging and --destination == last_known_good_staging' do
349
349
  before do
350
- stub_message "#worklog resetting staging branch to last_known_good_staging #scgitx\\n/cc @SocialcastDevelopers"
350
+ stub_message "#worklog resetting staging branch to last_known_good_staging #scgitx\n/cc @SocialcastDevelopers"
351
351
 
352
352
  Socialcast::Gitx::CLI.start ['nuke', 'staging', '--destination', 'last_known_good_staging']
353
353
  end
@@ -511,7 +511,7 @@ describe Socialcast::Gitx::CLI do
511
511
  to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1"}), :headers => {})
512
512
 
513
513
  stub_message "#reviewrequest for FOO #scgitx\n\n/cc @SocialcastDevelopers\n\ntesting\n\n", :url => 'http://github.com/repo/project/pulls/1', :message_type => 'review_request'
514
- Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing']
514
+ Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
515
515
  end
516
516
  it 'should create github pull request' do end # see expectations
517
517
  it 'should post socialcast message' do end # see expectations
@@ -529,21 +529,33 @@ describe Socialcast::Gitx::CLI do
529
529
  before do
530
530
  stub_request(:post, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls").
531
531
  to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://github.com/repos/repo/project/issues/1"}), :headers => {})
532
-
533
532
  stub_request(:patch, "http://github.com/repos/repo/project/issues/1").to_return(:status => 200)
534
-
535
- # The Review Buddy should be @mentioned in the message
536
- stub_message "#reviewrequest for FOO #scgitx\n\n/cc @SocialcastDevelopers\n\nAssigned to @VanMiranda\n\ntesting\n\n", :url => 'http://github.com/repo/project/pulls/1', :message_type => 'review_request'
537
- Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing']
538
533
  end
539
- it 'should create github pull request' do end # see expectations
540
- it 'should post socialcast message' do end # see expectations
541
- it 'should run expected commands' do
542
- Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
543
- "git pull origin FOO",
544
- "git pull origin master",
545
- "git push origin HEAD"
546
- ]
534
+ context 'and additional reviewers are specified' do
535
+ let(:message_body) { "#reviewrequest for FOO #scgitx\n\n/cc @SocialcastDevelopers\n\n\nAssigned additionally to @JohnSmith for API review\n\ntesting\n\n" }
536
+ before do
537
+ # The Review Buddy should be @mentioned in the message
538
+ stub_message message_body, :url => 'http://github.com/repo/project/pulls/1', :message_type => 'review_request'
539
+ Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-a', 'a']
540
+ end
541
+ it 'should create github pull request' do end # see expectations
542
+ it 'should post socialcast message' do end # see expectations
543
+ it 'should run expected commands' do
544
+ Socialcast::Gitx::CLI.stubbed_executed_commands.should == [
545
+ "git pull origin FOO",
546
+ "git pull origin master",
547
+ "git push origin HEAD"
548
+ ]
549
+ end
550
+ end
551
+ context 'and additional reviewers are not specified' do
552
+ let(:message_body) { "#reviewrequest for FOO #scgitx\n\n/cc @SocialcastDevelopers\n\ntesting\n\n" }
553
+ before do
554
+ # The Review Buddy should be @mentioned in the message
555
+ stub_message message_body, :url => 'http://github.com/repo/project/pulls/1', :message_type => 'review_request'
556
+ Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
557
+ end
558
+ it 'should create github pull request' do end # see expectations
547
559
  end
548
560
  end
549
561
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'ostruct'
2
3
  require 'bundler/setup'
3
4
  require 'rspec/mocks'
4
5
  require 'webmock/rspec'
@@ -10,6 +11,11 @@ require 'socialcast-git-extensions/cli'
10
11
  RSpec.configure do |config|
11
12
  config.mock_with :rspec
12
13
 
14
+ config.before do
15
+ ## Needed because object does not have permalink url until after it has been posted
16
+ Socialcast::CommandLine::Message.any_instance.stub(:permalink_url).and_return('http://demo.socialcast.com/messages/123')
17
+ end
18
+
13
19
  def capture_with_status(stream)
14
20
  exit_status = 0
15
21
  begin
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast-git-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.14
4
+ version: 3.1.15
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ryan Sonnek
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: json_pure
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: grit
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: socialcast
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rest-client
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: thor
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ! '>='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ! '>='
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rake
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - '='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - '='
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rspec
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: pry
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ! '>='
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ! '>='
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: webmock
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ! '>='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ! '>='
137
156
  - !ruby/object:Gem::Version
@@ -180,6 +199,7 @@ files:
180
199
  - lib/socialcast-git-extensions/cli.rb
181
200
  - lib/socialcast-git-extensions/git.rb
182
201
  - lib/socialcast-git-extensions/github.rb
202
+ - lib/socialcast-git-extensions/highline.rb
183
203
  - lib/socialcast-git-extensions/string_ext.rb
184
204
  - lib/socialcast-git-extensions/version.rb
185
205
  - socialcast-git-extensions.gemspec
@@ -187,26 +207,27 @@ files:
187
207
  - spec/spec_helper.rb
188
208
  homepage: http://github.com/socialcast/socialcast-git-extensions
189
209
  licenses: []
190
- metadata: {}
191
210
  post_install_message:
192
211
  rdoc_options: []
193
212
  require_paths:
194
213
  - lib
195
214
  required_ruby_version: !ruby/object:Gem::Requirement
215
+ none: false
196
216
  requirements:
197
217
  - - ! '>='
198
218
  - !ruby/object:Gem::Version
199
219
  version: '0'
200
220
  required_rubygems_version: !ruby/object:Gem::Requirement
221
+ none: false
201
222
  requirements:
202
223
  - - ! '>='
203
224
  - !ruby/object:Gem::Version
204
225
  version: '0'
205
226
  requirements: []
206
227
  rubyforge_project: socialcast-git-extensions
207
- rubygems_version: 2.2.1
228
+ rubygems_version: 1.8.23
208
229
  signing_key:
209
- specification_version: 4
230
+ specification_version: 3
210
231
  summary: git extension scripts for socialcast workflow
211
232
  test_files:
212
233
  - spec/cli_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NTQ3OGZmMzFiMjI0MTM4Y2ZjOTMzYzNlMzMxMGY2NzlmMDJhYTI1NA==
5
- data.tar.gz: !binary |-
6
- MTM3NzkyNzA1NTdhMGFmMzVmNDVhNGM4MTdkODI2ZDI4Y2E2YjA0MA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- YjY0YzAxNDFhNjBiYmJiNmFjOWY0ZTg3MDI1NjEwMDVhNTczY2VjZmM0NmNh
10
- OWE5OTY1ZDlmMjYxNWU4YjMxMGI2Y2Y3N2E2NDg3MWUwZjUzODk3NjU1YTU0
11
- YmQ5MDQ5YWExZGRlOTIyNzRjMjkwODRlYzU2MjRkYWZmMzBjYjI=
12
- data.tar.gz: !binary |-
13
- OGFjMDFkNTMwZmE5MDM2MDRiNTMxMjk0YWFhMGYxNGU0ODFiM2E2MTY5NTI5
14
- ZDhhNmI4YmRlODY0Njk0YTEyMmZkYjk1YWVkYzFiMjk2ZDczNWI1ZDVmMGMx
15
- MTI3NmJjNWJkYWVmZmZhMTkxODYxMWM0OWYyMTFmYTgxZWZiOTk=