circleci-bundle-update-pr 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 810482472816d5a97508a3427b3c62ef710ef073a045537a109578fe5f42e03f
4
- data.tar.gz: 500887eca1eac3aafa52596c61ad1e6e432c6d99030b38903762609e34b54b51
3
+ metadata.gz: 5742711f4f6b0cb19eec3d8f4573c3430866ea6a3158e3ff7675d20eba860b6b
4
+ data.tar.gz: 2c14e2e0ccea86e3164592e7555f82c23895ceb70bf784e3eebe3e50f6d057d4
5
5
  SHA512:
6
- metadata.gz: 1c38298e4625d5bd50a9eae298ad118a3424ee7268ad242fac66518cded716a1c9d45ae98e2ba5dc12a2b6a20f6edc7c676dfad9ac9d383b5f41503d1d5e14b5
7
- data.tar.gz: 45e87d4710a167a0495368b3939247c539be87d7f69852fc230ecb1e20bb147be7ef6d895f8e82d09a2c73ca297adef7db698e073dc8418aa31d0293a6a2128a
6
+ metadata.gz: 4d20182cb0e5bc6a4e53dbd37059096d2c956e93a06995f5eb65609c1e424316414f88427d02c86676af23f7970b3eb3148641ca1bd29b50ba49f5b957f87e0a
7
+ data.tar.gz: 567daa514b62b47983f9d5877facfa9c5ce3a3d349b2af25671bd7f6c38ec09133840bd4dee63ebed5e7ba5eb6020b71984afed510a4ce447dab3545b79f1ed9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circleci-bundle-update-pr (1.10.0)
4
+ circleci-bundle-update-pr (1.11.0)
5
5
  compare_linker (>= 1.4.0)
6
6
  octokit
7
7
 
@@ -102,10 +102,14 @@ By default, it works only on master branch, but you can also explicitly specify
102
102
  $ circleci-bundle-update-pr <git username> <git email address> master develop topic
103
103
  ```
104
104
 
105
- You can assign the PR to any users.
105
+ You can also add the following options:
106
106
 
107
107
  ```
108
- $ circleci-bundle-update-pr <git username> <git email address> -a alice,bob,carol
108
+ $ circleci-bundle-update-pr -h
109
+ Usage: circleci-bundle-update-pr [options]
110
+ -a, --assignees alice,bob,carol Assign the PR to them
111
+ -r, --reviewers alice,bob,carol Request PR review to them
112
+ -l, --labels "In Review, Update" Add labels to the PR
109
113
  ```
110
114
 
111
115
  ## Contributing
data/README.md CHANGED
@@ -109,10 +109,14 @@ By default, it works only on master branch, but you can also explicitly specify
109
109
  $ circleci-bundle-update-pr <git username> <git email address> master develop topic
110
110
  ```
111
111
 
112
- You can assign the PR to any users.
112
+ You can also add the following options:
113
113
 
114
114
  ```
115
- $ circleci-bundle-update-pr <git username> <git email address> -a alice,bob,carol
115
+ $ circleci-bundle-update-pr -h
116
+ Usage: circleci-bundle-update-pr [options]
117
+ -a, --assignees alice,bob,carol Assign the PR to them
118
+ -r, --reviewers alice,bob,carol Request PR review to them
119
+ -l, --labels "In Review, Update" Add labels to the PR
116
120
  ```
117
121
 
118
122
  ## Contributing
@@ -5,7 +5,9 @@ require 'optparse'
5
5
 
6
6
  opt = OptionParser.new
7
7
  options = { assignees: [] }
8
- opt.on('-a', '--assignees alice,bob,carol', Array, 'Assign the PR to them') { |v| options[:assignees] = v }
8
+ opt.on('-a', '--assignees alice,bob,carol', Array, 'Assign the PR to them') { |v| options[:assignees] = v.map(&:strip) }
9
+ opt.on('-r', '--reviewers alice,bob,carol', Array, 'Request PR review to them') { |v| options[:reviewers] = v.map(&:strip) }
10
+ opt.on('-l', '--labels "In Review, Update"', Array, 'Add labels to the PR') { |v| options[:labels] = v.map(&:strip) }
9
11
  opt.parse!(ARGV)
10
12
 
11
13
  Circleci::Bundle::Update::Pr.create_if_needed(
@@ -13,4 +15,6 @@ Circleci::Bundle::Update::Pr.create_if_needed(
13
15
  git_email: ARGV.shift,
14
16
  git_branches: ARGV.empty? ? ["master"] : ARGV,
15
17
  assignees: options[:assignees],
18
+ reviewers: options[:reviewers],
19
+ labels: options[:labels],
16
20
  )
@@ -6,7 +6,8 @@ module Circleci
6
6
  module Bundle
7
7
  module Update
8
8
  module Pr
9
- def self.create_if_needed(git_username: nil, git_email: nil, git_branches: ["master"], assignees: [])
9
+ def self.create_if_needed(git_username: nil, git_email: nil, git_branches: ["master"],
10
+ assignees: nil, reviewers: nil, labels: nil)
10
11
  raise_if_env_unvalid!
11
12
  return unless need?(git_branches)
12
13
  repo_full_name = "#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
@@ -18,8 +19,10 @@ module Circleci
18
19
 
19
20
  create_branch(git_username, git_email, branch, repo_full_name)
20
21
  pull_request = create_pull_request(repo_full_name, branch, now)
21
- add_comment_of_compare_linker(repo_full_name, pull_request[:number])
22
- add_assignees(repo_full_name, pull_request[:number], assignees) unless assignees.empty?
22
+ update_pull_request_body(repo_full_name, pull_request[:number])
23
+ add_assignees(repo_full_name, pull_request[:number], assignees) if assignees
24
+ request_review(repo_full_name, pull_request[:number], reviewers) if reviewers
25
+ add_labels(repo_full_name, pull_request[:number], labels) if labels
23
26
  end
24
27
 
25
28
  def self.need?(git_branches)
@@ -46,32 +49,42 @@ module Circleci
46
49
  def self.create_pull_request(repo_full_name, branch, now)
47
50
  title = "bundle update at #{now.strftime('%Y-%m-%d %H:%M:%S %Z')}"
48
51
  build_url = URI.parse ENV['CIRCLE_BUILD_URL']
49
- body = "auto generated by [CircleCI of #{ENV['CIRCLE_PROJECT_REPONAME']}](https://#{build_url.host}/gh/#{repo_full_name})"
50
- client.create_pull_request(repo_full_name, ENV['CIRCLE_BRANCH'], branch, title, body)
52
+ client.create_pull_request(repo_full_name, ENV['CIRCLE_BRANCH'], branch, title)
51
53
  end
52
54
  private_class_method :create_pull_request
53
55
 
54
- def self.add_comment_of_compare_linker(repo_full_name, pr_number)
56
+ def self.update_pull_request_body(repo_full_name, pr_number)
55
57
  ENV["OCTOKIT_ACCESS_TOKEN"] = ENV["GITHUB_ACCESS_TOKEN"]
56
58
  compare_linker = CompareLinker.new(repo_full_name, pr_number)
57
59
  compare_linker.formatter = CompareLinker::Formatter::Markdown.new
58
60
 
59
- comment = <<-EOC
61
+ body = <<-EOB
60
62
  **Updated RubyGems:**
61
63
 
62
64
  #{compare_linker.make_compare_links.to_a.join("\n")}
63
65
 
64
- Powered by [compare_linker](https://rubygems.org/gems/compare_linker)
65
- EOC
66
- compare_linker.add_comment(repo_full_name, pr_number, comment)
66
+ Powered by [circleci-bundle-update-pr](https://rubygems.org/gems/circleci-bundle-update-pr)
67
+ EOB
68
+
69
+ client.update_pull_request(repo_full_name, pr_number, body: body)
67
70
  end
68
- private_class_method :add_comment_of_compare_linker
71
+ private_class_method :update_pull_request_body
69
72
 
70
73
  def self.add_assignees(repo_full_name, pr_number, assignees)
71
74
  client.add_assignees(repo_full_name, pr_number, assignees)
72
75
  end
73
76
  private_class_method :add_assignees
74
77
 
78
+ def self.request_review(repo_full_name, pr_number, reviewers)
79
+ client.request_pull_request_review(repo_full_name, pr_number, reviewers)
80
+ end
81
+ private_class_method :request_review
82
+
83
+ def self.add_labels(repo_full_name, pr_number, labels)
84
+ client.add_labels_to_an_issue(repo_full_name, pr_number, labels)
85
+ end
86
+ private_class_method :add_labels
87
+
75
88
  def self.client
76
89
  if enterprise?
77
90
  Octokit::Client.new(access_token: ENV['ENTERPRISE_OCTOKIT_ACCESS_TOKEN'],
@@ -2,7 +2,7 @@ module Circleci
2
2
  module Bundle
3
3
  module Update
4
4
  module Pr
5
- VERSION = "1.10.0"
5
+ VERSION = "1.11.0"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circleci-bundle-update-pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Masuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-24 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit