thegarage-gitx 2.10.0 → 2.10.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3ba4526a6cb6a7cfa24ec14119448eb93802865
4
- data.tar.gz: 5f98b2f487eb204dab8c060218580871d1873386
3
+ metadata.gz: c60254f8675c8326d671e96ac965f222eb007808
4
+ data.tar.gz: 398dd0103e3a51063e1ad5d9a88d06e6ca471569
5
5
  SHA512:
6
- metadata.gz: 9689ecc4716c330e747e607a2d629d7f0613c52ad025c326d04aefcd33b5055bc16c450725c85af802754f5c6ef40a30b569087f72f85ccf824f057558e2ef7f
7
- data.tar.gz: 0f5df20623851c98ead0d71f225dcb013c49ee86661fc9267d1b88154b8075ddd226b90c1484e4cb71b991e4592accb1bdd37c8a7d77ab1d88e9d4575c9cea69
6
+ metadata.gz: 91de6e1d04a921889e24c80f80a39bad98c8ba7069c7781ac889870458967b6c163ad75059bd3ff823343a923418ea6a3e49d75a30ec13a49f7d8e2fd80829b5
7
+ data.tar.gz: e7d2fcdb382ba1fa9ba2562ced9b591c826e4a2ef22b40750fec4703a8e3748c7f71515d0ae7e6414711337ff2c4d4404f1ac0bf7d67368e3f1318a588408d1b
@@ -10,22 +10,27 @@ module Thegarage
10
10
  class ReviewCommand < BaseCommand
11
11
  include Thegarage::Gitx::Github
12
12
 
13
- BUMP_COMMENT_TEMPLATE = <<-EOS.dedent
14
- [gitx] review bump :tada:
15
-
16
- ### Changelog Summary
13
+ BUMP_COMMENT_PREFIX = '[gitx] review bump :tada:'
14
+ BUMP_COMMENT_FOOTER = <<-EOS.dedent
15
+ # Bump comments should include:
16
+ # * summary of what changed
17
+ #
18
+ # This footer will automatically be stripped from the created comment
17
19
  EOS
18
- APPROVAL_COMMENT_TEMPLATE = <<-EOS.dedent
19
- [gitx] review approved :shipit:
20
-
21
- ### Feedback
22
-
23
- ### Follow-up Items
20
+ APPROVAL_COMMENT_PREFIX = '[gitx] review approved :shipit:'
21
+ APPROVAL_COMMENT_FOOTER = <<-EOS.dedent
22
+ # Approval comments can include:
23
+ # * feedback
24
+ # * post-release follow-up items
25
+ #
26
+ # This footer will automatically be stripped from the created comment
24
27
  EOS
25
- REJECTION_COMMENT_TEMPLATE = <<-EOS.dedent
26
- [gitx] review rejected
27
-
28
- ### Feedback
28
+ REJECTION_COMMENT_PREFIX = '[gitx] review rejected'
29
+ REJECTION_COMMENT_FOOTER = <<-EOS.dedent
30
+ # Rejection comments should include:
31
+ # * feedback for fixes required before approved
32
+ #
33
+ # This footer will automatically be stripped from the created comment
29
34
  EOS
30
35
 
31
36
  desc "review", "Create or update a pull request on github"
@@ -65,29 +70,25 @@ module Thegarage
65
70
  end
66
71
 
67
72
  def bump_pull_request(pull_request)
68
- comment = get_editor_input(BUMP_COMMENT_TEMPLATE)
69
- github_client.add_comment(github_slug, pull_request.number, comment)
70
-
73
+ comment = comment_from_template(pull_request, BUMP_COMMENT_PREFIX, BUMP_COMMENT_FOOTER)
71
74
  set_review_status('pending', 'Peer review in progress')
72
75
  end
73
76
 
74
77
  def reject_pull_request(pull_request)
75
- comment = get_editor_input(REJECTION_COMMENT_TEMPLATE)
76
- github_client.add_comment(github_slug, pull_request.number, comment)
77
-
78
+ comment = comment_from_template(pull_request, REJECTION_COMMENT_PREFIX, REJECTION_COMMENT_FOOTER)
78
79
  set_review_status('failure', 'Peer review rejected')
79
80
  end
80
81
 
81
82
  def approve_pull_request(pull_request)
82
- comment = get_editor_input(APPROVAL_COMMENT_TEMPLATE)
83
- github_client.add_comment(github_slug, pull_request.number, comment)
84
-
83
+ comment = comment_from_template(pull_request, APPROVAL_COMMENT_PREFIX, APPROVAL_COMMENT_FOOTER)
85
84
  set_review_status('success', 'Peer review approved')
86
85
  end
87
86
 
88
- def get_editor_input(template)
89
- text = ask_editor(template, repo.config['core.editor'])
90
- text = text.chomp.strip
87
+ def comment_from_template(pull_request, prefix, footer)
88
+ text = ask_editor("\n\n#{footer}", repo.config['core.editor'])
89
+ comment = [prefix, text].join("\n\n")
90
+ comment = comment.gsub(footer, '').chomp.strip
91
+ github_client.add_comment(github_slug, pull_request.number, comment)
91
92
  end
92
93
 
93
94
  def set_review_status(state, description)
@@ -18,7 +18,7 @@ class Thor
18
18
  # see http://rdoc.info/github/visionmedia/commander/master/Commander/UI.ask_editor
19
19
  def ask_editor(initial_text = '', editor = nil)
20
20
  editor ||= ENV['EDITOR'] || 'vi'
21
- Tempfile.open('reviewrequest.md') do |f|
21
+ Tempfile.open('comment.md') do |f|
22
22
  f << initial_text
23
23
  f.flush
24
24
 
@@ -1,5 +1,5 @@
1
1
  module Thegarage
2
2
  module Gitx
3
- VERSION = '2.10.0'
3
+ VERSION = '2.10.1'
4
4
  end
5
5
  end
@@ -138,7 +138,7 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
138
138
  end
139
139
  it 'posts comment to github' do
140
140
  expect(WebMock).to have_requested(:post, "https://api.github.com/repos/thegarage/thegarage-gitx/issues/10/comments").
141
- with(body: {body: 'comment description'})
141
+ with(body: {body: "[gitx] review bump :tada:\n\ncomment description"})
142
142
  end
143
143
  it 'creates pending build status for latest commit' do
144
144
  expect(WebMock).to have_requested(:post, 'https://api.github.com/repos/thegarage/thegarage-gitx/statuses/e12da4').
@@ -165,7 +165,7 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
165
165
  end
166
166
  it 'posts comment to github' do
167
167
  expect(WebMock).to have_requested(:post, "https://api.github.com/repos/thegarage/thegarage-gitx/issues/10/comments").
168
- with(body: {body: 'comment body'})
168
+ with(body: {body: "[gitx] review rejected\n\ncomment body"})
169
169
  end
170
170
  it 'creates failure build status for latest commit' do
171
171
  expect(WebMock).to have_requested(:post, 'https://api.github.com/repos/thegarage/thegarage-gitx/statuses/e12da4').
@@ -192,7 +192,7 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
192
192
  end
193
193
  it 'posts comment to github' do
194
194
  expect(WebMock).to have_requested(:post, "https://api.github.com/repos/thegarage/thegarage-gitx/issues/10/comments").
195
- with(body: {body: 'comment body'})
195
+ with(body: {body: "[gitx] review approved :shipit:\n\ncomment body"})
196
196
  end
197
197
  it 'creates success build status for latest commit' do
198
198
  expect(WebMock).to have_requested(:post, 'https://api.github.com/repos/thegarage/thegarage-gitx/statuses/e12da4').
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thegarage-gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged