git-pr-release 2.0.0 → 2.1.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: b8bcbbdbe3dfb5b6783306e29dad9c919d86264ea185742aeb07b91d141ac247
4
- data.tar.gz: 1d67e25f3acde325baf9a1103ecc619011486847def7e561aa620f9b0f538c9f
3
+ metadata.gz: e1a94b83554ecc020acc0a736dcec3d764e416cd0a99ea2b3a1948b9b2a85fb6
4
+ data.tar.gz: 2d41363fc87ca3d42e21b8bf18348f2ff9ef6f2e4a53237c4292338e62a9e257
5
5
  SHA512:
6
- metadata.gz: 602b5171e7b0a0160555632b19ff35af9ca7bf9c6d560d4364d8251b661cc205b51f645c15d33db701c623817f5ad31c6e307781178a6103582f35f001b06fb1
7
- data.tar.gz: 1fad3d9128cc3d982ceb426045013566967d53df7c25364d8b256562863286384b297bbcf14aa0df4acaa81b945e3c570ddef7559c30dbff2a5fe77a41231141
6
+ metadata.gz: fbb6731c6b4805a9bf512d727641a8e73bc4bf50261c2e821d1a17beeba359a1c2c2ed234269c7b4e05d3d08378ad225ad84955008c055ad6c7bbbe0993db43f
7
+ data.tar.gz: ac651dbda5be13ed6fd43db65baee451e5dba97723c79c7eaa7ca44c1214500651a10a93f8e8c911062d772c8ead1726edcb5c06a1bf2c9214ff1380406b827d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # git-pr-release
2
2
 
3
+ ## v2.1.0 (2022-03-03)
4
+
5
+ [full changelog](https://github.com/x-motemen/git-pr-release/compare/v2.0.0...v2.1.0)
6
+
7
+ * (#75) reduce GitHub search API calls when the squashed option is specified (@Songmu)
8
+ * (#76) use bulk issue search to reduce API calls (@Songmu)
9
+ * (#77) Add option "ssl_no_verify" to skip verifying ssl certificate (@mtgto)
10
+ * (#78) add an argument to to_checklist_item to print pr title (@mtgto)
11
+
3
12
  ## v2.0.0 (2022-02-17)
4
13
 
5
14
  [full changelog](https://github.com/x-motemen/git-pr-release/compare/v1.9.0...v2.0.0)
data/README.md CHANGED
@@ -84,6 +84,16 @@ You can specify this value by `GIT_PR_RELEASE_MENTION` environment variable.
84
84
 
85
85
  If not specified, the mention will be the PR assignee
86
86
 
87
+ ## `pr-release.ssl_no_verify`
88
+
89
+ Whether to verify SSL certificate or not.
90
+ Accepted values: `true` | `false`
91
+
92
+ This option might be useful when self-hosted GitHub enterprise server is using self-signed certificate.
93
+
94
+ You can specify this value by `GIT_PR_RELEASE_SSL_NO_VERIFY` to `1`.
95
+
96
+ If not specified, verify SSL certificate always.
87
97
 
88
98
  Errors and exit statuses
89
99
  ------------------------
@@ -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.0.0'
7
+ spec.version = '2.1.0'
8
8
  spec.authors = ["motemen"]
9
9
  spec.email = ["motemen@gmail.com"]
10
10
  spec.summary = 'Creates a release pull request'
@@ -59,8 +59,12 @@ module Git
59
59
  host, @repository, scheme = host_and_repository_and_scheme
60
60
 
61
61
  if host
62
- # GitHub:Enterprise
63
- OpenSSL::SSL.const_set :VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE # XXX
62
+ if host != 'github.com' && scheme == 'https' # GitHub Enterprise
63
+ ssl_no_verify = %w[true 1].include? ENV.fetch('GIT_PR_RELEASE_SSL_NO_VERIFY') { git_config('ssl_no_verify') }
64
+ if ssl_no_verify
65
+ OpenSSL::SSL.const_set :VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE
66
+ end
67
+ end
64
68
 
65
69
  Octokit.configure do |c|
66
70
  c.api_endpoint = "#{scheme}://#{host}/api/v3"
@@ -85,7 +89,10 @@ module Git
85
89
  def fetch_merged_prs
86
90
  git :remote, 'update', 'origin' unless @no_fetch
87
91
 
88
- merged_pull_request_numbers = @squashed ? fetch_merged_pr_numbers_from_github : fetch_merged_pr_numbers_from_git_remote
92
+ merged_pull_request_numbers = fetch_merged_pr_numbers_from_git_remote
93
+ if @squashed
94
+ merged_pull_request_numbers.concat(fetch_squash_merged_pr_numbers_from_github)
95
+ end
89
96
 
90
97
  merged_prs = merged_pull_request_numbers.uniq.sort.map do |nr|
91
98
  pr = client.pull_request repository, nr
@@ -122,11 +129,49 @@ module Git
122
129
  end.compact
123
130
  end
124
131
 
125
- def fetch_merged_pr_numbers_from_github
126
- git(:log, '--pretty=format:%H', "origin/#{production_branch}..origin/#{staging_branch}").map(&:chomp).map do |sha1|
127
- sleep 1
128
- client.search_issues("repo:#{repository} is:pr is:closed #{sha1}")[:items].map(&:number)
129
- end.flatten
132
+ def search_issue_numbers(query)
133
+ sleep 1
134
+ say "search issues with query:#{query}", :debug
135
+ # Fortunately, we don't need to take care of the page count in response, because
136
+ # the default value of per_page is 30 and we can't specify more than 30 commits due to
137
+ # the length limit specification of the query string.
138
+ client.search_issues("#{query}")[:items].map(&:number)
139
+ end
140
+
141
+ def fetch_squash_merged_pr_numbers_from_github
142
+ # When "--abbrev" is specified, the length of the each line of the stdout isn't fixed.
143
+ # It is just a minimum length, and if the commit cannot be uniquely identified with
144
+ # that length, a longer commit hash will be displayed.
145
+ # We specify this option to minimize the length of the query string, but we use
146
+ # "--abbrev=7" because the SHA syntax of the search API requires a string of at
147
+ # least 7 characters.
148
+ # ref. https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests#search-by-commit-sha
149
+ # This is done because there is a length limit on the API query string, and we want
150
+ # to create a string with the minimum possible length.
151
+ shas = git(:log, '--pretty=format:%h', "--abbrev=7", "--no-merges", "--first-parent",
152
+ "origin/#{production_branch}..origin/#{staging_branch}").map(&:chomp)
153
+
154
+ pr_nums = []
155
+ query_base = "repo:#{repository} is:pr is:closed"
156
+ query = query_base
157
+ # Make bulk requests with multiple SHAs of the maximum possible length.
158
+ # If multiple SHAs are specified, the issue search API will treat it like an OR search,
159
+ # and all the pull requests will be searched.
160
+ # This is difficult to read from the current documentation, but that is the current
161
+ # behavior and GitHub support has responded that this is the spec.
162
+ shas.each do |sha|
163
+ # Longer than 256 characters are not supported in the query.
164
+ # ref. https://docs.github.com/en/rest/reference/search#limitations-on-query-length
165
+ if query.length + 1 + sha.length >= 256
166
+ pr_nums.concat(search_issue_numbers(query))
167
+ query = query_base
168
+ end
169
+ query += " " + sha
170
+ end
171
+ if query != query_base
172
+ pr_nums.concat(search_issue_numbers(query))
173
+ end
174
+ pr_nums
130
175
  end
131
176
 
132
177
  def create_release_pr(merged_prs)
@@ -10,8 +10,12 @@ module Git
10
10
  @pr = pr
11
11
  end
12
12
 
13
- def to_checklist_item
14
- "- [ ] ##{pr.number}" + mention
13
+ def to_checklist_item(print_title = false)
14
+ if print_title
15
+ "- [ ] ##{pr.number} #{pr.title}" + mention
16
+ else
17
+ "- [ ] ##{pr.number}" + mention
18
+ end
15
19
  end
16
20
 
17
21
  def html_link
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pr-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - motemen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2022-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit