git-pr-release 2.2.0 → 2.4.0

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
  SHA256:
3
- metadata.gz: 8a0c2d1ded6d8e250d8cafcce83e7148ebaf274a1afb92ce5b4b5469a29e3cec
4
- data.tar.gz: 26eb1888e585695c2f2cdd0154b59d61ff80c2781c423b175227e7156aadd9d8
3
+ metadata.gz: 9e376b7fffae49f44aebc877ed835158b11fdcc74cb6ef59f9226b638c9e4d31
4
+ data.tar.gz: cb97fbbffc5be83f438384a02902ba05c6c12327d787d9df93d93f6b5c11c61c
5
5
  SHA512:
6
- metadata.gz: e25446387c28b266051d6e1d40b6dd8b553ba5d84f174bf32804c70f96e9591e3fdbb9b00a74ccb45364de68a7d33fed0a65d00ab68ec696528320b0321a1fac
7
- data.tar.gz: 9d5cf6118e614100257bc7959357da6206e9f40f6bb07c7cc010e66be5c7d30f32e7629aee92b3cbac5e85780e0add3da4334e9267c5a0b42ed761b9c87ab476
6
+ metadata.gz: bd00f29dcbb0690b1a607ab34a110d51e8b44f25c0f51e834a99a8034062147277fe07d50ee12248494a37e10c1eb2196c3960a3bf7253072be988f3f9cce49b
7
+ data.tar.gz: b18a60610527e86b6ef83bb744d197460bd5e90f2ddc7e35ad8d6502ae633834b2f21a66b41f2f5f174d1ff27401c70743500bcfca715d3024631a8affe69637
@@ -0,0 +1,24 @@
1
+ name: Release new version to RubyGems.org
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-slim
9
+
10
+ permissions:
11
+ contents: write
12
+ id-token: write
13
+
14
+ steps:
15
+ - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
16
+ with:
17
+ persist-credentials: false
18
+
19
+ - uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
20
+ with:
21
+ bundler-cache: true
22
+ ruby-version: ruby
23
+
24
+ - uses: rubygems/release-gem@1c162a739e8b4cb21a676e97b087e8268d8fc40b # v1.1.2
@@ -11,23 +11,24 @@ on:
11
11
  jobs:
12
12
  test:
13
13
  runs-on: ubuntu-latest
14
- container: ${{ matrix.ruby }}
15
14
  strategy:
16
15
  fail-fast: false
17
16
  matrix:
18
17
  ruby:
19
- - ruby:2.6
20
- - ruby:2.7
21
- - ruby:3.0
22
- - rubylang/ruby:master-nightly-bionic
23
- include:
24
- - ruby: rubylang/ruby:master-nightly-bionic
25
- allow_failures: "true"
18
+ - "3.1"
19
+ - "3.2"
20
+ - "3.3"
21
+ - "3.4"
22
+ - head
26
23
 
27
24
  steps:
28
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v4
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
29
30
  - name: Cache vendor/bundle
30
- uses: actions/cache@v2
31
+ uses: actions/cache@v4
31
32
  with:
32
33
  path: vendor/bundle
33
34
  key: v1-gem-${{ runner.os }}-${{ matrix.ruby }}-${{ github.sha }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # git-pr-release
2
2
 
3
+ ## v2.4.0 (2025-12-16)
4
+
5
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v2.3.0...v2.4.0)
6
+
7
+ * (#112) Add release workflow using trusted publishing (@ohbarye)
8
+ * (#110) Support `pr-release.assign-pr-author` and `pr-release.request-pr-author-review` options (@moznion)
9
+
10
+ ## v2.3.0 (2025-12-15)
11
+
12
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v2.2.0...v2.3.0)
13
+
14
+ * (#108) Support multiple PR assignees (@toshimaru)
15
+ * (#107) Update CI matrix (@onk)
16
+ * (#106) Use setup-ruby instead of container-based setup (@onk)
17
+ * (#100) Allow big bang release PR (@secobaka)
18
+ * (#95) Bump actions/cache from v2 to v4 (@ytkg)
19
+ * (#94) Bump actions/checkout from v2 to v4 (@ytkg)
20
+ * (#91) Test against Ruby v3.1 and Ruby v3.2 (@toshimaru)
21
+ * (#90) updated docs to include --squashed flag (@petercorrea)
22
+
3
23
  ## v2.2.0 (2022-08-17)
4
24
 
5
25
  [full changelog](https://github.com/x-motemen/git-pr-release/compare/v2.1.2...v2.2.0)
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- git-pr-release <a href="http://badge.fury.io/rb/git-pr-release"><img src="https://badge.fury.io/rb/git-pr-release@2x.png" alt="Gem Version" height="18"></a>
2
- ==============
1
+ # git-pr-release <a href="http://badge.fury.io/rb/git-pr-release"><img src="https://badge.fury.io/rb/git-pr-release@2x.png" alt="Gem Version" height="18"></a>
3
2
 
4
3
  Creates a "release pull request", whose body consists of features list or
5
4
  pull requests that are to be released into production. It's especially useful for QA and
@@ -11,13 +10,26 @@ pull request.
11
10
 
12
11
  Suitable for branching strategy like below (similar to git-flow):
13
12
 
14
- * Feature branches are first merged into "staging" (or release, development)
15
- branch.
16
- * Then the staging branch is merged into "production" branch, which is for
17
- production release.
13
+ - Feature branches are first merged into "staging" (or release, development)
14
+ branch.
15
+ - Then the staging branch is merged into "production" branch, which is for
16
+ production release.
18
17
 
19
- Configuration
20
- -------------
18
+ ## Usage
19
+
20
+ `git-pr-release`: default
21
+
22
+ `git-pr-release --squashed`: include PRs containing squashed commits.
23
+
24
+ `git-pr-release --overwrite-description`: generate a fresh PR description.
25
+
26
+ `git-pr-release -n` | `git-pr-release --dry-run`: perform a dry run; does not update PR.
27
+
28
+ `git-pr-release --no-fetch`: Do not fetch from remote repo before determining target PRs (CI friendly).
29
+
30
+ `git-pr-release --json`: Show data of target PRs in JSON format.
31
+
32
+ ## Configuration
21
33
 
22
34
  All configuration are taken using `git config`. You can write these variables
23
35
  in file `.git-pr-release` (instead of `.git/config` or `~/.gitconfig`) to share project-wise configuration to other
@@ -84,6 +96,28 @@ You can specify this value by `GIT_PR_RELEASE_MENTION` environment variable.
84
96
 
85
97
  If not specified, the mention will be the PR assignee
86
98
 
99
+ ### `pr-release.assign-pr-author`
100
+
101
+ Whether to assign the related users of the merged pull requests to the release pull request.
102
+ Accepted values: `true` | `false`
103
+
104
+ You can specify this value by `GIT_PR_RELEASE_ASSIGN_PR_AUTHOR` environment variable.
105
+
106
+ If not specified, no assignees will be added.
107
+
108
+ Note: The user selection follows the same logic as `pr-release.mention`. If `mention` is set to `author`, the PR author will be assigned. Otherwise, the PR assignee will be used (falling back to the author if no assignee exists).
109
+
110
+ ### `pr-release.request-pr-author-review`
111
+
112
+ Whether to request review from the related users of the merged pull requests on the release pull request.
113
+ Accepted values: `true` | `false`
114
+
115
+ You can specify this value by `GIT_PR_RELEASE_REQUEST_PR_AUTHOR_REVIEW` environment variable.
116
+
117
+ If not specified, no review requests will be made.
118
+
119
+ Note: The user selection follows the same logic as `pr-release.mention`. If `mention` is set to `author`, the PR author will be requested for review. Otherwise, the PR assignee will be used (falling back to the author if no assignee exists).
120
+
87
121
  ### `pr-release.ssl-no-verify`
88
122
 
89
123
  Whether to verify SSL certificate or not.
@@ -95,14 +129,12 @@ You can specify this value by `GIT_PR_RELEASE_SSL_NO_VERIFY` to `1`.
95
129
 
96
130
  If not specified, verify SSL certificate always.
97
131
 
98
- Errors and exit statuses
99
- ------------------------
132
+ ## Errors and exit statuses
100
133
 
101
134
  ### No pull requests to be released
102
135
 
103
136
  exit status is 1.
104
137
 
105
- Author
106
- ------
138
+ ## Author
107
139
 
108
140
  motemen <motemen@gmail.com>, original in-house version written by @hitode909.
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "git-pr-release"
7
- spec.version = '2.2.0'
7
+ spec.version = '2.4.0'
8
8
  spec.authors = ["motemen"]
9
9
  spec.email = ["motemen@gmail.com"]
10
10
  spec.summary = 'Creates a release pull request'
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'colorize'
23
23
  spec.add_dependency 'diff-lcs'
24
24
 
25
+ spec.add_development_dependency 'rake'
25
26
  spec.add_development_dependency 'rspec'
26
27
  spec.add_development_dependency 'timecop'
27
28
  spec.add_development_dependency 'webmock'
@@ -6,7 +6,7 @@ module Git
6
6
  module Release
7
7
  class CLI
8
8
  include Git::Pr::Release::Util
9
- attr_reader :repository, :production_branch, :staging_branch, :template_path, :labels
9
+ attr_reader :repository, :production_branch, :staging_branch, :template_path, :labels, :assign_pr_author, :request_pr_author_review
10
10
 
11
11
  def self.start
12
12
  result = self.new.start
@@ -82,11 +82,19 @@ module Git
82
82
  _labels = ENV.fetch('GIT_PR_RELEASE_LABELS') { git_config('labels') }
83
83
  @labels = _labels && _labels.split(/\s*,\s*/) || []
84
84
 
85
+ _assign_pr_author = ENV.fetch('GIT_PR_RELEASE_ASSIGN_PR_AUTHOR') { git_config('assign-pr-author') }
86
+ @assign_pr_author = %w[true 1].include?(_assign_pr_author)
87
+
88
+ _request_pr_author_review = ENV.fetch('GIT_PR_RELEASE_REQUEST_PR_AUTHOR_REVIEW') { git_config('request-pr-author-review') }
89
+ @request_pr_author_review = %w[true 1].include?(_request_pr_author_review)
90
+
85
91
  say "Repository: #{repository}", :debug
86
92
  say "Production branch: #{production_branch}", :debug
87
93
  say "Staging branch: #{staging_branch}", :debug
88
94
  say "Template path: #{template_path}", :debug
89
95
  say "Labels #{labels}", :debug
96
+ say "Assign PR author: #{assign_pr_author}", :debug
97
+ say "Request PR author review: #{request_pr_author_review}", :debug
90
98
  end
91
99
 
92
100
  def fetch_merged_prs
@@ -212,7 +220,7 @@ module Git
212
220
  return
213
221
  end
214
222
 
215
- update_release_pr(release_pr, pr_title, pr_body)
223
+ update_release_pr(release_pr, pr_title, pr_body, merged_prs)
216
224
 
217
225
  say "#{create_mode ? 'Created' : 'Updated'} pull request: #{release_pr.rels[:html].href}", :notice
218
226
  dump_result_as_json( release_pr, merged_prs, changed_files ) if @json
@@ -238,7 +246,7 @@ module Git
238
246
  [pr_title, merge_pr_body(old_body, new_body)]
239
247
  end
240
248
 
241
- def update_release_pr(release_pr, pr_title, pr_body)
249
+ def update_release_pr(release_pr, pr_title, pr_body, merged_prs)
242
250
  say 'Pull request body:', :debug
243
251
  say pr_body, :debug
244
252
 
@@ -251,6 +259,24 @@ module Git
251
259
  repository, release_pr.number, labels
252
260
  )
253
261
  end
262
+
263
+ if assign_pr_author
264
+ assignees = merged_prs.map { |pr| PullRequest.new(pr).target_user_login_names }.flatten.compact.uniq
265
+ unless assignees.empty?
266
+ client.add_assignees(
267
+ repository, release_pr.number, assignees
268
+ )
269
+ end
270
+ end
271
+
272
+ if request_pr_author_review
273
+ reviewers = merged_prs.map { |pr| PullRequest.new(pr).target_user_login_names }.flatten.compact.uniq
274
+ unless reviewers.empty?
275
+ client.request_pull_request_review(
276
+ repository, release_pr.number, reviewers:
277
+ )
278
+ end
279
+ end
254
280
  end
255
281
 
256
282
  # Fetch PR files of specified pull_request
@@ -27,14 +27,25 @@ module Git
27
27
  end
28
28
 
29
29
  def mention
30
- mention = case PullRequest.mention_type
31
- when 'author'
32
- pr.user ? "@#{pr.user.login}" : nil
33
- else
34
- pr.assignee ? "@#{pr.assignee.login}" : pr.user ? "@#{pr.user.login}" : nil
35
- end
36
-
37
- mention ? " #{mention}" : ""
30
+ mention = target_user_login_names.map { |login_name| "@#{login_name}" }.join(" ")
31
+ mention.empty? ? "" : " #{mention}"
32
+ end
33
+
34
+ def target_user_login_names
35
+ case PullRequest.mention_type
36
+ when 'author'
37
+ pr.user ? [pr.user.login] : []
38
+ else
39
+ if pr.assignees&.any? && pr.assignees.length > 1
40
+ pr.assignees.map(&:login)
41
+ elsif pr.assignee
42
+ [pr.assignee.login]
43
+ elsif pr.user
44
+ [pr.user.login]
45
+ else
46
+ []
47
+ end
48
+ end
38
49
  end
39
50
 
40
51
  def self.mention_type
@@ -157,7 +157,7 @@ ERB
157
157
  merged_body = pr_body_lines.join("\n")
158
158
  check_status.each { |issue_number, check_value|
159
159
  say "Update pull-request checkbox \##{issue_number} to #{check_value}.", :trace
160
- merged_body.gsub! /^- \[ \] \##{issue_number}/, "- [#{check_value}] \##{issue_number}"
160
+ merged_body.gsub! /^- \[ \] \##{issue_number}\b/, "- [#{check_value}] \##{issue_number}"
161
161
  }
162
162
 
163
163
  merged_body
@@ -0,0 +1,404 @@
1
+ ---
2
+ :url: https://api.github.com/repos/motemen/git-pr-release/pulls/7
3
+ :id: 16585507
4
+ :node_id: MDExOlB1bGxSZXF1ZXN0MTY1ODU1MDc=
5
+ :html_url: https://github.com/motemen/git-pr-release/pull/7
6
+ :diff_url: https://github.com/motemen/git-pr-release/pull/7.diff
7
+ :patch_url: https://github.com/motemen/git-pr-release/pull/7.patch
8
+ :issue_url: https://api.github.com/repos/motemen/git-pr-release/issues/7
9
+ :number: 7
10
+ :state: closed
11
+ :locked: false
12
+ :title: Support multiple assignees
13
+ :user:
14
+ :login: hakobe
15
+ :id: 6882
16
+ :node_id: MDQ6VXNlcjY4ODI=
17
+ :avatar_url: https://avatars0.githubusercontent.com/u/6882?v=4
18
+ :gravatar_id: ''
19
+ :url: https://api.github.com/users/hakobe
20
+ :html_url: https://github.com/hakobe
21
+ :followers_url: https://api.github.com/users/hakobe/followers
22
+ :following_url: https://api.github.com/users/hakobe/following{/other_user}
23
+ :gists_url: https://api.github.com/users/hakobe/gists{/gist_id}
24
+ :starred_url: https://api.github.com/users/hakobe/starred{/owner}{/repo}
25
+ :subscriptions_url: https://api.github.com/users/hakobe/subscriptions
26
+ :organizations_url: https://api.github.com/users/hakobe/orgs
27
+ :repos_url: https://api.github.com/users/hakobe/repos
28
+ :events_url: https://api.github.com/users/hakobe/events{/privacy}
29
+ :received_events_url: https://api.github.com/users/hakobe/received_events
30
+ :type: User
31
+ :site_admin: false
32
+ :body: 'This PR adds support for multiple assignees in git-pr-release.
33
+
34
+ '
35
+ :created_at: 2014-06-02 06:55:44.000000000 Z
36
+ :updated_at: 2014-06-21 05:22:22.000000000 Z
37
+ :closed_at: 2014-06-02 08:02:02.000000000 Z
38
+ :merged_at: 2014-06-02 08:02:02.000000000 Z
39
+ :merge_commit_sha: c66dfa90eed853507ae0e2876df3cb4dc7ce5286
40
+ :assignee:
41
+ :login: hakobe
42
+ :id: 6882
43
+ :node_id: MDQ6VXNlcjY4ODI=
44
+ :avatar_url: https://avatars0.githubusercontent.com/u/6882?v=4
45
+ :gravatar_id: ''
46
+ :url: https://api.github.com/users/hakobe
47
+ :html_url: https://github.com/hakobe
48
+ :followers_url: https://api.github.com/users/hakobe/followers
49
+ :following_url: https://api.github.com/users/hakobe/following{/other_user}
50
+ :gists_url: https://api.github.com/users/hakobe/gists{/gist_id}
51
+ :starred_url: https://api.github.com/users/hakobe/starred{/owner}{/repo}
52
+ :subscriptions_url: https://api.github.com/users/hakobe/subscriptions
53
+ :organizations_url: https://api.github.com/users/hakobe/orgs
54
+ :repos_url: https://api.github.com/users/hakobe/repos
55
+ :events_url: https://api.github.com/users/hakobe/events{/privacy}
56
+ :received_events_url: https://api.github.com/users/hakobe/received_events
57
+ :type: User
58
+ :site_admin: false
59
+ :assignees:
60
+ - :login: hakobe
61
+ :id: 6882
62
+ :node_id: MDQ6VXNlcjY4ODI=
63
+ :avatar_url: https://avatars0.githubusercontent.com/u/6882?v=4
64
+ :gravatar_id: ''
65
+ :url: https://api.github.com/users/hakobe
66
+ :html_url: https://github.com/hakobe
67
+ :followers_url: https://api.github.com/users/hakobe/followers
68
+ :following_url: https://api.github.com/users/hakobe/following{/other_user}
69
+ :gists_url: https://api.github.com/users/hakobe/gists{/gist_id}
70
+ :starred_url: https://api.github.com/users/hakobe/starred{/owner}{/repo}
71
+ :subscriptions_url: https://api.github.com/users/hakobe/subscriptions
72
+ :organizations_url: https://api.github.com/users/hakobe/orgs
73
+ :repos_url: https://api.github.com/users/hakobe/repos
74
+ :events_url: https://api.github.com/users/hakobe/events{/privacy}
75
+ :received_events_url: https://api.github.com/users/hakobe/received_events
76
+ :type: User
77
+ :site_admin: false
78
+ - :login: toshimaru
79
+ :id: 803398
80
+ :node_id: MDQ6VXNlcjgwMzM5OA==
81
+ :avatar_url: https://avatars.githubusercontent.com/u/803398?v=4
82
+ :gravatar_id: ''
83
+ :url: https://api.github.com/users/toshimaru
84
+ :html_url: https://github.com/toshimaru
85
+ :followers_url: https://api.github.com/users/toshimaru/followers
86
+ :following_url: https://api.github.com/users/toshimaru/following{/other_user}
87
+ :gists_url: https://api.github.com/users/toshimaru/gists{/gist_id}
88
+ :starred_url: https://api.github.com/users/toshimaru/starred{/owner}{/repo}
89
+ :subscriptions_url: https://api.github.com/users/toshimaru/subscriptions
90
+ :organizations_url: https://api.github.com/users/toshimaru/orgs
91
+ :repos_url: https://api.github.com/users/toshimaru/repos
92
+ :events_url: https://api.github.com/users/toshimaru/events{/privacy}
93
+ :received_events_url: https://api.github.com/users/toshimaru/received_events
94
+ :type: User
95
+ :site_admin: false
96
+ - :login: Copilot
97
+ :id: 198982749
98
+ :node_id: BOT_kgDOC9w8XQ
99
+ :avatar_url: https://avatars.githubusercontent.com/in/1143301?v=4
100
+ :gravatar_id: ''
101
+ :url: https://api.github.com/users/Copilot
102
+ :html_url: https://github.com/apps/copilot-swe-agent
103
+ :followers_url: https://api.github.com/users/Copilot/followers
104
+ :following_url: https://api.github.com/users/Copilot/following{/other_user}
105
+ :gists_url: https://api.github.com/users/Copilot/gists{/gist_id}
106
+ :starred_url: https://api.github.com/users/Copilot/starred{/owner}{/repo}
107
+ :subscriptions_url: https://api.github.com/users/Copilot/subscriptions
108
+ :organizations_url: https://api.github.com/users/Copilot/orgs
109
+ :repos_url: https://api.github.com/users/Copilot/repos
110
+ :events_url: https://api.github.com/users/Copilot/events{/privacy}
111
+ :received_events_url: https://api.github.com/users/Copilot/received_events
112
+ :type: Bot
113
+ :site_admin: false
114
+ :requested_reviewers: []
115
+ :requested_teams: []
116
+ :labels: []
117
+ :milestone:
118
+ :commits_url: https://api.github.com/repos/motemen/git-pr-release/pulls/7/commits
119
+ :review_comments_url: https://api.github.com/repos/motemen/git-pr-release/pulls/7/comments
120
+ :review_comment_url: https://api.github.com/repos/motemen/git-pr-release/pulls/comments{/number}
121
+ :comments_url: https://api.github.com/repos/motemen/git-pr-release/issues/7/comments
122
+ :statuses_url: https://api.github.com/repos/motemen/git-pr-release/statuses/67d936fb57851f85db28249e91dfa0d8ccfe530b
123
+ :head:
124
+ :label: hakobe:support-multiple-assignees
125
+ :ref: support-multiple-assignees
126
+ :sha: 67d936fb57851f85db28249e91dfa0d8ccfe530b
127
+ :user:
128
+ :login: hakobe
129
+ :id: 6882
130
+ :node_id: MDQ6VXNlcjY4ODI=
131
+ :avatar_url: https://avatars0.githubusercontent.com/u/6882?v=4
132
+ :gravatar_id: ''
133
+ :url: https://api.github.com/users/hakobe
134
+ :html_url: https://github.com/hakobe
135
+ :followers_url: https://api.github.com/users/hakobe/followers
136
+ :following_url: https://api.github.com/users/hakobe/following{/other_user}
137
+ :gists_url: https://api.github.com/users/hakobe/gists{/gist_id}
138
+ :starred_url: https://api.github.com/users/hakobe/starred{/owner}{/repo}
139
+ :subscriptions_url: https://api.github.com/users/hakobe/subscriptions
140
+ :organizations_url: https://api.github.com/users/hakobe/orgs
141
+ :repos_url: https://api.github.com/users/hakobe/repos
142
+ :events_url: https://api.github.com/users/hakobe/events{/privacy}
143
+ :received_events_url: https://api.github.com/users/hakobe/received_events
144
+ :type: User
145
+ :site_admin: false
146
+ :repo:
147
+ :id: 17425170
148
+ :node_id: MDEwOlJlcG9zaXRvcnkxNzQyNTE3MA==
149
+ :name: git-pr-release
150
+ :full_name: hakobe/git-pr-release
151
+ :private: false
152
+ :owner:
153
+ :login: hakobe
154
+ :id: 6882
155
+ :node_id: MDQ6VXNlcjY4ODI=
156
+ :avatar_url: https://avatars0.githubusercontent.com/u/6882?v=4
157
+ :gravatar_id: ''
158
+ :url: https://api.github.com/users/hakobe
159
+ :html_url: https://github.com/hakobe
160
+ :followers_url: https://api.github.com/users/hakobe/followers
161
+ :following_url: https://api.github.com/users/hakobe/following{/other_user}
162
+ :gists_url: https://api.github.com/users/hakobe/gists{/gist_id}
163
+ :starred_url: https://api.github.com/users/hakobe/starred{/owner}{/repo}
164
+ :subscriptions_url: https://api.github.com/users/hakobe/subscriptions
165
+ :organizations_url: https://api.github.com/users/hakobe/orgs
166
+ :repos_url: https://api.github.com/users/hakobe/repos
167
+ :events_url: https://api.github.com/users/hakobe/events{/privacy}
168
+ :received_events_url: https://api.github.com/users/hakobe/received_events
169
+ :type: User
170
+ :site_admin: false
171
+ :html_url: https://github.com/hakobe/git-pr-release
172
+ :description: Creates a pull request which summarizes feature branches that are
173
+ to be released into production
174
+ :fork: true
175
+ :url: https://api.github.com/repos/hakobe/git-pr-release
176
+ :forks_url: https://api.github.com/repos/hakobe/git-pr-release/forks
177
+ :keys_url: https://api.github.com/repos/hakobe/git-pr-release/keys{/key_id}
178
+ :collaborators_url: https://api.github.com/repos/hakobe/git-pr-release/collaborators{/collaborator}
179
+ :teams_url: https://api.github.com/repos/hakobe/git-pr-release/teams
180
+ :hooks_url: https://api.github.com/repos/hakobe/git-pr-release/hooks
181
+ :issue_events_url: https://api.github.com/repos/hakobe/git-pr-release/issues/events{/number}
182
+ :events_url: https://api.github.com/repos/hakobe/git-pr-release/events
183
+ :assignees_url: https://api.github.com/repos/hakobe/git-pr-release/assignees{/user}
184
+ :branches_url: https://api.github.com/repos/hakobe/git-pr-release/branches{/branch}
185
+ :tags_url: https://api.github.com/repos/hakobe/git-pr-release/tags
186
+ :blobs_url: https://api.github.com/repos/hakobe/git-pr-release/git/blobs{/sha}
187
+ :git_tags_url: https://api.github.com/repos/hakobe/git-pr-release/git/tags{/sha}
188
+ :git_refs_url: https://api.github.com/repos/hakobe/git-pr-release/git/refs{/sha}
189
+ :trees_url: https://api.github.com/repos/hakobe/git-pr-release/git/trees{/sha}
190
+ :statuses_url: https://api.github.com/repos/hakobe/git-pr-release/statuses/{sha}
191
+ :languages_url: https://api.github.com/repos/hakobe/git-pr-release/languages
192
+ :stargazers_url: https://api.github.com/repos/hakobe/git-pr-release/stargazers
193
+ :contributors_url: https://api.github.com/repos/hakobe/git-pr-release/contributors
194
+ :subscribers_url: https://api.github.com/repos/hakobe/git-pr-release/subscribers
195
+ :subscription_url: https://api.github.com/repos/hakobe/git-pr-release/subscription
196
+ :commits_url: https://api.github.com/repos/hakobe/git-pr-release/commits{/sha}
197
+ :git_commits_url: https://api.github.com/repos/hakobe/git-pr-release/git/commits{/sha}
198
+ :comments_url: https://api.github.com/repos/hakobe/git-pr-release/comments{/number}
199
+ :issue_comment_url: https://api.github.com/repos/hakobe/git-pr-release/issues/comments{/number}
200
+ :contents_url: https://api.github.com/repos/hakobe/git-pr-release/contents/{+path}
201
+ :compare_url: https://api.github.com/repos/hakobe/git-pr-release/compare/{base}...{head}
202
+ :merges_url: https://api.github.com/repos/hakobe/git-pr-release/merges
203
+ :archive_url: https://api.github.com/repos/hakobe/git-pr-release/{archive_format}{/ref}
204
+ :downloads_url: https://api.github.com/repos/hakobe/git-pr-release/downloads
205
+ :issues_url: https://api.github.com/repos/hakobe/git-pr-release/issues{/number}
206
+ :pulls_url: https://api.github.com/repos/hakobe/git-pr-release/pulls{/number}
207
+ :milestones_url: https://api.github.com/repos/hakobe/git-pr-release/milestones{/number}
208
+ :notifications_url: https://api.github.com/repos/hakobe/git-pr-release/notifications{?since,all,participating}
209
+ :labels_url: https://api.github.com/repos/hakobe/git-pr-release/labels{/name}
210
+ :releases_url: https://api.github.com/repos/hakobe/git-pr-release/releases{/id}
211
+ :deployments_url: https://api.github.com/repos/hakobe/git-pr-release/deployments
212
+ :created_at: 2014-03-05 02:20:59.000000000 Z
213
+ :updated_at: 2014-05-13 01:42:58.000000000 Z
214
+ :pushed_at: 2014-05-12 11:42:34.000000000 Z
215
+ :git_url: git://github.com/hakobe/git-pr-release.git
216
+ :ssh_url: git@github.com:hakobe/git-pr-release.git
217
+ :clone_url: https://github.com/hakobe/git-pr-release.git
218
+ :svn_url: https://github.com/hakobe/git-pr-release
219
+ :homepage: https://rubygems.org/gems/git-pr-release
220
+ :size: 236
221
+ :stargazers_count: 0
222
+ :watchers_count: 0
223
+ :language: Ruby
224
+ :has_issues: false
225
+ :has_projects: true
226
+ :has_downloads: true
227
+ :has_wiki: true
228
+ :has_pages: false
229
+ :forks_count: 0
230
+ :mirror_url:
231
+ :archived: false
232
+ :open_issues_count: 0
233
+ :license:
234
+ :forks: 0
235
+ :open_issues: 0
236
+ :watchers: 0
237
+ :default_branch: master
238
+ :base:
239
+ :label: motemen:master
240
+ :ref: master
241
+ :sha: a0d1fd72732d705270878d22601c44e0533641e1
242
+ :user:
243
+ :login: motemen
244
+ :id: 8465
245
+ :node_id: MDQ6VXNlcjg0NjU=
246
+ :avatar_url: https://avatars2.githubusercontent.com/u/8465?v=4
247
+ :gravatar_id: ''
248
+ :url: https://api.github.com/users/motemen
249
+ :html_url: https://github.com/motemen
250
+ :followers_url: https://api.github.com/users/motemen/followers
251
+ :following_url: https://api.github.com/users/motemen/following{/other_user}
252
+ :gists_url: https://api.github.com/users/motemen/gists{/gist_id}
253
+ :starred_url: https://api.github.com/users/motemen/starred{/owner}{/repo}
254
+ :subscriptions_url: https://api.github.com/users/motemen/subscriptions
255
+ :organizations_url: https://api.github.com/users/motemen/orgs
256
+ :repos_url: https://api.github.com/users/motemen/repos
257
+ :events_url: https://api.github.com/users/motemen/events{/privacy}
258
+ :received_events_url: https://api.github.com/users/motemen/received_events
259
+ :type: User
260
+ :site_admin: false
261
+ :repo:
262
+ :id: 15468156
263
+ :node_id: MDEwOlJlcG9zaXRvcnkxNTQ2ODE1Ng==
264
+ :name: git-pr-release
265
+ :full_name: motemen/git-pr-release
266
+ :private: false
267
+ :owner:
268
+ :login: motemen
269
+ :id: 8465
270
+ :node_id: MDQ6VXNlcjg0NjU=
271
+ :avatar_url: https://avatars2.githubusercontent.com/u/8465?v=4
272
+ :gravatar_id: ''
273
+ :url: https://api.github.com/users/motemen
274
+ :html_url: https://github.com/motemen
275
+ :followers_url: https://api.github.com/users/motemen/followers
276
+ :following_url: https://api.github.com/users/motemen/following{/other_user}
277
+ :gists_url: https://api.github.com/users/motemen/gists{/gist_id}
278
+ :starred_url: https://api.github.com/users/motemen/starred{/owner}{/repo}
279
+ :subscriptions_url: https://api.github.com/users/motemen/subscriptions
280
+ :organizations_url: https://api.github.com/users/motemen/orgs
281
+ :repos_url: https://api.github.com/users/motemen/repos
282
+ :events_url: https://api.github.com/users/motemen/events{/privacy}
283
+ :received_events_url: https://api.github.com/users/motemen/received_events
284
+ :type: User
285
+ :site_admin: false
286
+ :html_url: https://github.com/motemen/git-pr-release
287
+ :description: Release pull request generator
288
+ :fork: false
289
+ :url: https://api.github.com/repos/motemen/git-pr-release
290
+ :forks_url: https://api.github.com/repos/motemen/git-pr-release/forks
291
+ :keys_url: https://api.github.com/repos/motemen/git-pr-release/keys{/key_id}
292
+ :collaborators_url: https://api.github.com/repos/motemen/git-pr-release/collaborators{/collaborator}
293
+ :teams_url: https://api.github.com/repos/motemen/git-pr-release/teams
294
+ :hooks_url: https://api.github.com/repos/motemen/git-pr-release/hooks
295
+ :issue_events_url: https://api.github.com/repos/motemen/git-pr-release/issues/events{/number}
296
+ :events_url: https://api.github.com/repos/motemen/git-pr-release/events
297
+ :assignees_url: https://api.github.com/repos/motemen/git-pr-release/assignees{/user}
298
+ :branches_url: https://api.github.com/repos/motemen/git-pr-release/branches{/branch}
299
+ :tags_url: https://api.github.com/repos/motemen/git-pr-release/tags
300
+ :blobs_url: https://api.github.com/repos/motemen/git-pr-release/git/blobs{/sha}
301
+ :git_tags_url: https://api.github.com/repos/motemen/git-pr-release/git/tags{/sha}
302
+ :git_refs_url: https://api.github.com/repos/motemen/git-pr-release/git/refs{/sha}
303
+ :trees_url: https://api.github.com/repos/motemen/git-pr-release/git/trees{/sha}
304
+ :statuses_url: https://api.github.com/repos/motemen/git-pr-release/statuses/{sha}
305
+ :languages_url: https://api.github.com/repos/motemen/git-pr-release/languages
306
+ :stargazers_url: https://api.github.com/repos/motemen/git-pr-release/stargazers
307
+ :contributors_url: https://api.github.com/repos/motemen/git-pr-release/contributors
308
+ :subscribers_url: https://api.github.com/repos/motemen/git-pr-release/subscribers
309
+ :subscription_url: https://api.github.com/repos/motemen/git-pr-release/subscription
310
+ :commits_url: https://api.github.com/repos/motemen/git-pr-release/commits{/sha}
311
+ :git_commits_url: https://api.github.com/repos/motemen/git-pr-release/git/commits{/sha}
312
+ :comments_url: https://api.github.com/repos/motemen/git-pr-release/comments{/number}
313
+ :issue_comment_url: https://api.github.com/repos/motemen/git-pr-release/issues/comments{/number}
314
+ :contents_url: https://api.github.com/repos/motemen/git-pr-release/contents/{+path}
315
+ :compare_url: https://api.github.com/repos/motemen/git-pr-release/compare/{base}...{head}
316
+ :merges_url: https://api.github.com/repos/motemen/git-pr-release/merges
317
+ :archive_url: https://api.github.com/repos/motemen/git-pr-release/{archive_format}{/ref}
318
+ :downloads_url: https://api.github.com/repos/motemen/git-pr-release/downloads
319
+ :issues_url: https://api.github.com/repos/motemen/git-pr-release/issues{/number}
320
+ :pulls_url: https://api.github.com/repos/motemen/git-pr-release/pulls{/number}
321
+ :milestones_url: https://api.github.com/repos/motemen/git-pr-release/milestones{/number}
322
+ :notifications_url: https://api.github.com/repos/motemen/git-pr-release/notifications{?since,all,participating}
323
+ :labels_url: https://api.github.com/repos/motemen/git-pr-release/labels{/name}
324
+ :releases_url: https://api.github.com/repos/motemen/git-pr-release/releases{/id}
325
+ :deployments_url: https://api.github.com/repos/motemen/git-pr-release/deployments
326
+ :created_at: 2013-12-27 06:35:52.000000000 Z
327
+ :updated_at: 2019-02-18 01:40:52.000000000 Z
328
+ :pushed_at: 2018-11-15 10:45:07.000000000 Z
329
+ :git_url: git://github.com/motemen/git-pr-release.git
330
+ :ssh_url: git@github.com:motemen/git-pr-release.git
331
+ :clone_url: https://github.com/motemen/git-pr-release.git
332
+ :svn_url: https://github.com/motemen/git-pr-release
333
+ :homepage: https://rubygems.org/gems/git-pr-release
334
+ :size: 62
335
+ :stargazers_count: 359
336
+ :watchers_count: 359
337
+ :language: Ruby
338
+ :has_issues: true
339
+ :has_projects: true
340
+ :has_downloads: true
341
+ :has_wiki: true
342
+ :has_pages: false
343
+ :forks_count: 28
344
+ :mirror_url:
345
+ :archived: false
346
+ :open_issues_count: 6
347
+ :license:
348
+ :key: mit
349
+ :name: MIT License
350
+ :spdx_id: MIT
351
+ :url: https://api.github.com/licenses/mit
352
+ :node_id: MDc6TGljZW5zZTEz
353
+ :forks: 28
354
+ :open_issues: 6
355
+ :watchers: 359
356
+ :default_branch: master
357
+ :_links:
358
+ :self:
359
+ :href: https://api.github.com/repos/motemen/git-pr-release/pulls/7
360
+ :html:
361
+ :href: https://github.com/motemen/git-pr-release/pull/7
362
+ :issue:
363
+ :href: https://api.github.com/repos/motemen/git-pr-release/issues/7
364
+ :comments:
365
+ :href: https://api.github.com/repos/motemen/git-pr-release/issues/7/comments
366
+ :review_comments:
367
+ :href: https://api.github.com/repos/motemen/git-pr-release/pulls/7/comments
368
+ :review_comment:
369
+ :href: https://api.github.com/repos/motemen/git-pr-release/pulls/comments{/number}
370
+ :commits:
371
+ :href: https://api.github.com/repos/motemen/git-pr-release/pulls/7/commits
372
+ :statuses:
373
+ :href: https://api.github.com/repos/motemen/git-pr-release/statuses/67d936fb57851f85db28249e91dfa0d8ccfe530b
374
+ :author_association: CONTRIBUTOR
375
+ :merged: true
376
+ :mergeable:
377
+ :rebaseable:
378
+ :mergeable_state: unknown
379
+ :merged_by:
380
+ :login: motemen
381
+ :id: 8465
382
+ :node_id: MDQ6VXNlcjg0NjU=
383
+ :avatar_url: https://avatars2.githubusercontent.com/u/8465?v=4
384
+ :gravatar_id: ''
385
+ :url: https://api.github.com/users/motemen
386
+ :html_url: https://github.com/motemen
387
+ :followers_url: https://api.github.com/users/motemen/followers
388
+ :following_url: https://api.github.com/users/motemen/following{/other_user}
389
+ :gists_url: https://api.github.com/users/motemen/gists{/gist_id}
390
+ :starred_url: https://api.github.com/users/motemen/starred{/owner}{/repo}
391
+ :subscriptions_url: https://api.github.com/users/motemen/subscriptions
392
+ :organizations_url: https://api.github.com/users/motemen/orgs
393
+ :repos_url: https://api.github.com/users/motemen/repos
394
+ :events_url: https://api.github.com/users/motemen/events{/privacy}
395
+ :received_events_url: https://api.github.com/users/motemen/received_events
396
+ :type: User
397
+ :site_admin: false
398
+ :comments: 2
399
+ :review_comments: 2
400
+ :maintainer_can_modify: false
401
+ :commits: 2
402
+ :additions: 17
403
+ :deletions: 1
404
+ :changed_files: 1
@@ -76,6 +76,8 @@ RSpec.describe Git::Pr::Release::CLI do
76
76
  expect(@cli.staging_branch).to eq "staging"
77
77
  expect(@cli.template_path).to eq nil
78
78
  expect(@cli.labels).to eq []
79
+ expect(@cli.assign_pr_author).to eq false
80
+ expect(@cli.request_pr_author_review).to eq false
79
81
  end
80
82
  end
81
83
 
@@ -181,6 +183,134 @@ RSpec.describe Git::Pr::Release::CLI do
181
183
  end
182
184
  end
183
185
  end
186
+
187
+ describe "assign_pr_author" do
188
+ context "With ENV set to true" do
189
+ around do |example|
190
+ original = ENV.to_hash
191
+ begin
192
+ ENV["GIT_PR_RELEASE_ASSIGN_PR_AUTHOR"] = "true"
193
+ example.run
194
+ ensure
195
+ ENV.replace(original)
196
+ end
197
+ end
198
+
199
+ it "enables assign_pr_author" do
200
+ subject
201
+ expect(@cli.assign_pr_author).to eq true
202
+ end
203
+ end
204
+
205
+ context "With ENV set to 1" do
206
+ around do |example|
207
+ original = ENV.to_hash
208
+ begin
209
+ ENV["GIT_PR_RELEASE_ASSIGN_PR_AUTHOR"] = "1"
210
+ example.run
211
+ ensure
212
+ ENV.replace(original)
213
+ end
214
+ end
215
+
216
+ it "enables assign_pr_author" do
217
+ subject
218
+ expect(@cli.assign_pr_author).to eq true
219
+ end
220
+ end
221
+
222
+ context "With ENV set to false" do
223
+ around do |example|
224
+ original = ENV.to_hash
225
+ begin
226
+ ENV["GIT_PR_RELEASE_ASSIGN_PR_AUTHOR"] = "false"
227
+ example.run
228
+ ensure
229
+ ENV.replace(original)
230
+ end
231
+ end
232
+
233
+ it "disables assign_pr_author" do
234
+ subject
235
+ expect(@cli.assign_pr_author).to eq false
236
+ end
237
+ end
238
+
239
+ context "With git_config" do
240
+ before {
241
+ allow(@cli).to receive(:git_config).with("assign-pr-author") { "true" }
242
+ }
243
+
244
+ it "enables assign_pr_author" do
245
+ subject
246
+ expect(@cli.assign_pr_author).to eq true
247
+ end
248
+ end
249
+ end
250
+
251
+ describe "request_pr_author_review" do
252
+ context "With ENV set to true" do
253
+ around do |example|
254
+ original = ENV.to_hash
255
+ begin
256
+ ENV["GIT_PR_RELEASE_REQUEST_PR_AUTHOR_REVIEW"] = "true"
257
+ example.run
258
+ ensure
259
+ ENV.replace(original)
260
+ end
261
+ end
262
+
263
+ it "enables request_pr_author_review" do
264
+ subject
265
+ expect(@cli.request_pr_author_review).to eq true
266
+ end
267
+ end
268
+
269
+ context "With ENV set to 1" do
270
+ around do |example|
271
+ original = ENV.to_hash
272
+ begin
273
+ ENV["GIT_PR_RELEASE_REQUEST_PR_AUTHOR_REVIEW"] = "1"
274
+ example.run
275
+ ensure
276
+ ENV.replace(original)
277
+ end
278
+ end
279
+
280
+ it "enables request_pr_author_review" do
281
+ subject
282
+ expect(@cli.request_pr_author_review).to eq true
283
+ end
284
+ end
285
+
286
+ context "With ENV set to false" do
287
+ around do |example|
288
+ original = ENV.to_hash
289
+ begin
290
+ ENV["GIT_PR_RELEASE_REQUEST_PR_AUTHOR_REVIEW"] = "false"
291
+ example.run
292
+ ensure
293
+ ENV.replace(original)
294
+ end
295
+ end
296
+
297
+ it "disables request_pr_author_review" do
298
+ subject
299
+ expect(@cli.request_pr_author_review).to eq false
300
+ end
301
+ end
302
+
303
+ context "With git_config" do
304
+ before {
305
+ allow(@cli).to receive(:git_config).with("request-pr-author-review") { "true" }
306
+ }
307
+
308
+ it "enables request_pr_author_review" do
309
+ subject
310
+ expect(@cli.request_pr_author_review).to eq true
311
+ end
312
+ end
313
+ end
184
314
  end
185
315
 
186
316
  describe "#fetch_merged_prs" do
@@ -275,7 +405,7 @@ RSpec.describe Git::Pr::Release::CLI do
275
405
  expect(@cli).to have_received(:prepare_release_pr)
276
406
  expect(@cli).to have_received(:pull_request_files)
277
407
  expect(@cli).to have_received(:build_and_merge_pr_title_and_body).with(@created_pr, @merged_prs, @changed_files)
278
- expect(@cli).to have_received(:update_release_pr).with(@created_pr, @pr_title, @pr_body)
408
+ expect(@cli).to have_received(:update_release_pr).with(@created_pr, @pr_title, @pr_body, @merged_prs)
279
409
  }
280
410
  end
281
411
 
@@ -296,7 +426,7 @@ RSpec.describe Git::Pr::Release::CLI do
296
426
  expect(@cli).to have_received(:pull_request_files).with(existing_release_pr)
297
427
  expect(@cli).not_to have_received(:prepare_release_pr)
298
428
  expect(@cli).to have_received(:build_and_merge_pr_title_and_body).with(existing_release_pr, @merged_prs, @changed_files)
299
- expect(@cli).to have_received(:update_release_pr).with(existing_release_pr, @pr_title, @pr_body)
429
+ expect(@cli).to have_received(:update_release_pr).with(existing_release_pr, @pr_title, @pr_body, @merged_prs)
300
430
  }
301
431
  end
302
432
 
@@ -317,7 +447,7 @@ RSpec.describe Git::Pr::Release::CLI do
317
447
  expect(@cli).not_to have_received(:prepare_release_pr)
318
448
  expect(@cli).not_to have_received(:pull_request_files)
319
449
  expect(@cli).to have_received(:build_and_merge_pr_title_and_body).with(nil, @merged_prs, [])
320
- expect(@cli).not_to have_received(:update_release_pr).with(@created_pr, @pr_title, @pr_body)
450
+ expect(@cli).not_to have_received(:update_release_pr).with(@created_pr, @pr_title, @pr_body, @merged_prs)
321
451
  }
322
452
  end
323
453
 
@@ -343,7 +473,7 @@ RSpec.describe Git::Pr::Release::CLI do
343
473
  subject
344
474
 
345
475
  expect(@cli).not_to have_received(:build_and_merge_pr_title_and_body)
346
- expect(@cli).to have_received(:update_release_pr).with(existing_release_pr, @new_pr_title, @new_pr_body)
476
+ expect(@cli).to have_received(:update_release_pr).with(existing_release_pr, @new_pr_title, @new_pr_body, @merged_prs)
347
477
  }
348
478
  end
349
479
  end
@@ -410,20 +540,32 @@ RSpec.describe Git::Pr::Release::CLI do
410
540
  end
411
541
 
412
542
  describe "#update_release_pr" do
413
- subject { @cli.update_release_pr(@release_pr, "PR Title", "PR Body") }
543
+ subject { @cli.update_release_pr(@release_pr, "PR Title", "PR Body", @merged_prs) }
414
544
 
415
545
  before {
416
546
  @cli = configured_cli
417
547
 
418
548
  @release_pr = double(number: 1023)
419
549
 
550
+ @agent = Sawyer::Agent.new("http://example.com/") do |conn|
551
+ conn.builder.handlers.delete(Faraday::Adapter::NetHttp)
552
+ conn.adapter(:test, Faraday::Adapter::Test::Stubs.new)
553
+ end
554
+ @merged_prs = [
555
+ Sawyer::Resource.new(@agent, load_yaml("pr_3.yml")),
556
+ Sawyer::Resource.new(@agent, load_yaml("pr_4.yml")),
557
+ Sawyer::Resource.new(@agent, load_yaml("pr_6.yml")),
558
+ ]
559
+
420
560
  @client = double(Octokit::Client)
421
561
  allow(@client).to receive(:update_pull_request) { @release_pr }
422
562
  allow(@client).to receive(:add_labels_to_an_issue)
563
+ allow(@client).to receive(:add_assignees)
564
+ allow(@client).to receive(:request_pull_request_review)
423
565
  allow(@cli).to receive(:client) { @client }
424
566
  }
425
567
 
426
- context "Without labels" do
568
+ context "Without labels and without assign_pr_author" do
427
569
  it {
428
570
  subject
429
571
 
@@ -436,6 +578,8 @@ RSpec.describe Git::Pr::Release::CLI do
436
578
  }
437
579
  )
438
580
  expect(@client).not_to have_received(:add_labels_to_an_issue)
581
+ expect(@client).not_to have_received(:add_assignees)
582
+ expect(@client).not_to have_received(:request_pull_request_review)
439
583
  }
440
584
  end
441
585
 
@@ -457,6 +601,58 @@ RSpec.describe Git::Pr::Release::CLI do
457
601
  expect(@client).to have_received(:add_labels_to_an_issue).with(
458
602
  "motemen/git-pr-release", 1023, ["release"]
459
603
  )
604
+ expect(@client).not_to have_received(:add_assignees)
605
+ expect(@client).not_to have_received(:request_pull_request_review)
606
+ }
607
+ end
608
+
609
+ context "With assign_pr_author enabled" do
610
+ before {
611
+ allow(@cli).to receive(:assign_pr_author) { true }
612
+ }
613
+
614
+ it {
615
+ subject
616
+
617
+ expect(@client).to have_received(:update_pull_request).with(
618
+ "motemen/git-pr-release",
619
+ 1023,
620
+ {
621
+ title: "PR Title",
622
+ body: "PR Body",
623
+ }
624
+ )
625
+ # Both pr_3.yml and pr_4.yml have hakobe as the author, so only one unique assignee
626
+ # And the author of pr_6.yml is ninjinkun.
627
+ expect(@client).to have_received(:add_assignees).with(
628
+ "motemen/git-pr-release", 1023, ["hakobe", "ninjinkun"]
629
+ )
630
+ expect(@client).not_to have_received(:request_pull_request_review)
631
+ }
632
+ end
633
+
634
+ context "With request_pr_author_review enabled" do
635
+ before {
636
+ allow(@cli).to receive(:request_pr_author_review) { true }
637
+ }
638
+
639
+ it {
640
+ subject
641
+
642
+ expect(@client).to have_received(:update_pull_request).with(
643
+ "motemen/git-pr-release",
644
+ 1023,
645
+ {
646
+ title: "PR Title",
647
+ body: "PR Body",
648
+ }
649
+ )
650
+ expect(@client).not_to have_received(:add_assignees)
651
+ # Both pr_3.yml and pr_4.yml have hakobe as the author
652
+ # And the author of pr_6.yml is ninjinkun.
653
+ expect(@client).to have_received(:request_pull_request_review).with(
654
+ "motemen/git-pr-release", 1023, reviewers: ["hakobe", "ninjinkun"]
655
+ )
460
656
  }
461
657
  end
462
658
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Git::Pr::Release::PullRequest do
4
+ let(:pr_data) {
5
+ agent = Sawyer::Agent.new "http://foo.com/a/" do |conn|
6
+ conn.builder.handlers.delete(Faraday::Adapter::NetHttp)
7
+ conn.adapter :test, Faraday::Adapter::Test::Stubs.new
8
+ end
9
+ Sawyer::Resource.new(agent, load_yaml(pr_data_yaml))
10
+ }
11
+ subject { described_class.new(pr_data) }
12
+
13
+ describe "#mention" do
14
+ context "with multiple assignees" do
15
+ let(:pr_data_yaml) { "pr_7.yml" }
16
+
17
+ it "returns all assignees as mentions" do
18
+ expect(subject.mention).to eq " @hakobe @toshimaru @Copilot"
19
+ end
20
+ end
21
+
22
+ context "with no assignees" do
23
+ let(:pr_data_yaml) { "pr_3.yml" }
24
+
25
+ it "returns PR creator as mention" do
26
+ expect(subject.mention).to eq " @hakobe"
27
+ end
28
+ end
29
+
30
+ context "when mention_type is 'author'" do
31
+ let(:pr_data_yaml) { "pr_7.yml" }
32
+
33
+ before do
34
+ allow(Git::Pr::Release::PullRequest).to receive(:mention_type).and_return('author')
35
+ end
36
+
37
+ it "returns PR author regardless of assignees" do
38
+ expect(subject.mention).to eq " @hakobe"
39
+ end
40
+ end
41
+ end
42
+
43
+ describe "#to_checklist_item" do
44
+ context "with multiple assignees" do
45
+ let(:pr_data_yaml) { "pr_7.yml" }
46
+
47
+ it "includes all assignees in the checklist item" do
48
+ expect(subject.to_checklist_item).to eq "- [ ] #7 @hakobe @toshimaru @Copilot"
49
+ end
50
+
51
+ it "includes title when print_title is true" do
52
+ expect(subject.to_checklist_item(true)).to eq "- [ ] #7 Support multiple assignees @hakobe @toshimaru @Copilot"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -90,6 +90,26 @@ RSpec.describe Git::Pr::Release do
90
90
  MARKDOWN
91
91
  }
92
92
  end
93
+ context "new pr added when the same numbers are included in a forward match" do
94
+ it {
95
+ actual = merge_pr_body(<<~OLD_BODY, <<~NEW_BODY)
96
+ - [x] #3 Provides a creating release pull-request object for template @hakobe
97
+ - [ ] #6 Support two factor auth @ninjinkun
98
+ OLD_BODY
99
+ - [ ] #3 Provides a creating release pull-request object for template @hakobe
100
+ - [ ] #4 use user who create PR if there is no assignee @hakobe
101
+ - [ ] #6 Support two factor auth @ninjinkun
102
+ - [ ] #30 Extract logic from bin/git-pr-release @banyan
103
+ NEW_BODY
104
+
105
+ expect(actual).to eq <<~MARKDOWN.chomp
106
+ - [x] #3 Provides a creating release pull-request object for template @hakobe
107
+ - [ ] #4 use user who create PR if there is no assignee @hakobe
108
+ - [ ] #6 Support two factor auth @ninjinkun
109
+ - [ ] #30 Extract logic from bin/git-pr-release @banyan
110
+ MARKDOWN
111
+ }
112
+ end
93
113
  end
94
114
 
95
115
  describe "#host_and_repository_and_scheme" do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pr-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - motemen
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: octokit
@@ -66,6 +65,20 @@ dependencies:
66
65
  - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rake
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
69
82
  - !ruby/object:Gem::Dependency
70
83
  name: rspec
71
84
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +130,7 @@ executables:
117
130
  extensions: []
118
131
  extra_rdoc_files: []
119
132
  files:
133
+ - ".github/workflows/release.yml"
120
134
  - ".github/workflows/test.yml"
121
135
  - ".gitignore"
122
136
  - ".rspec"
@@ -137,9 +151,11 @@ files:
137
151
  - spec/fixtures/file/pr_3.yml
138
152
  - spec/fixtures/file/pr_4.yml
139
153
  - spec/fixtures/file/pr_6.yml
154
+ - spec/fixtures/file/pr_7.yml
140
155
  - spec/fixtures/file/template_1.erb
141
156
  - spec/fixtures/file/template_2.erb
142
157
  - spec/git/pr/release/cli_spec.rb
158
+ - spec/git/pr/release/pull_request_spec.rb
143
159
  - spec/git/pr/release_spec.rb
144
160
  - spec/spec_helper.rb
145
161
  - spec/support/capture_support.rb
@@ -148,7 +164,6 @@ homepage: https://github.com/x-motemen/git-pr-release
148
164
  licenses:
149
165
  - MIT
150
166
  metadata: {}
151
- post_install_message:
152
167
  rdoc_options: []
153
168
  require_paths:
154
169
  - lib
@@ -163,8 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
178
  - !ruby/object:Gem::Version
164
179
  version: '0'
165
180
  requirements: []
166
- rubygems_version: 3.4.0.dev
167
- signing_key:
181
+ rubygems_version: 3.6.9
168
182
  specification_version: 4
169
183
  summary: Creates a release pull request
170
184
  test_files:
@@ -173,9 +187,11 @@ test_files:
173
187
  - spec/fixtures/file/pr_3.yml
174
188
  - spec/fixtures/file/pr_4.yml
175
189
  - spec/fixtures/file/pr_6.yml
190
+ - spec/fixtures/file/pr_7.yml
176
191
  - spec/fixtures/file/template_1.erb
177
192
  - spec/fixtures/file/template_2.erb
178
193
  - spec/git/pr/release/cli_spec.rb
194
+ - spec/git/pr/release/pull_request_spec.rb
179
195
  - spec/git/pr/release_spec.rb
180
196
  - spec/spec_helper.rb
181
197
  - spec/support/capture_support.rb