dependabot-common 0.125.4 → 0.125.5

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: ab1d6e026ca5a9a1cc8637814dacb5d8238ab248fa3c80df5bc8986f9bd4ea28
4
- data.tar.gz: e1f1ceae98349c8336e243491a346ee8e1ce265488aae2e7932066d2c1170992
3
+ metadata.gz: c683b87c4d10464e00bfcbe61d6a1702c6adad610305230f0e22449251c929b5
4
+ data.tar.gz: d0c02633ca51635730a51658b2742f60c04bee1f68af1ea7e024e57258339742
5
5
  SHA512:
6
- metadata.gz: 16fe9bfff89dde150778a188ee2068672d384ceaabb729502e7d79ae6f0a7c7b667adc9e47961b58711212e90d9c7ef551ab377ce71df717ad53f323eabb0d24
7
- data.tar.gz: 70af4395acf6a36fbb4fb7bbb589bdee606cec2c03419134b583e302c745cdb49ad55c6312e5f101d8016ab41efdf47a3cc06cfeb312053ba9d540626e212a4d
6
+ metadata.gz: c3250bee5817cfdc529a46d70582f9c2286c687a61186c3730efb3fd956a2a6f30bdaebd28f5be86a6bdec5560955524aed712302624451c1284162f39b56af6
7
+ data.tar.gz: 5e41108192d658e04db516055ee6b73768cd4f5d6c25b32cb01f79d71d487587ee929e411ded93bda9abfc0f0e5fd27e56ce91a357a221767071a250ff2de3f2
@@ -8,6 +8,8 @@ module Dependabot
8
8
  class Azure
9
9
  class NotFound < StandardError; end
10
10
 
11
+ MAX_PR_DESCRIPTION_LENGTH = 3999
12
+
11
13
  #######################
12
14
  # Constructor methods #
13
15
  #######################
@@ -154,15 +156,7 @@ module Dependabot
154
156
  # rubocop:disable Metrics/ParameterLists
155
157
  def create_pull_request(pr_name, source_branch, target_branch,
156
158
  pr_description, labels, work_item = nil)
157
- # Azure DevOps only support descriptions up to 4000 characters
158
- # https://developercommunity.visualstudio.com/content/problem/608770/remove-4000-character-limit-on-pull-request-descri.html
159
- azure_max_length = 3999
160
- if pr_description.length > azure_max_length
161
- truncated_msg = "...\n\n_Description has been truncated_"
162
- truncate_length = azure_max_length - truncated_msg.length
163
- pr_description = pr_description[0..truncate_length] + truncated_msg
164
- end
165
- # rubocop:enable Metrics/ParameterLists
159
+ pr_description = truncate_pr_description(pr_description)
166
160
 
167
161
  content = {
168
162
  sourceRefName: "refs/heads/" + source_branch,
@@ -178,6 +172,7 @@ module Dependabot
178
172
  "/_apis/git/repositories/" + source.unscoped_repo +
179
173
  "/pullrequests?api-version=5.0", content.to_json)
180
174
  end
175
+ # rubocop:enable Metrics/ParameterLists
181
176
 
182
177
  def get(url)
183
178
  response = Excon.get(
@@ -230,6 +225,19 @@ module Dependabot
230
225
  end
231
226
  end
232
227
 
228
+ def truncate_pr_description(pr_description)
229
+ # Azure DevOps only support descriptions up to 4000 characters in UTF-16
230
+ # encoding.
231
+ # https://developercommunity.visualstudio.com/content/problem/608770/remove-4000-character-limit-on-pull-request-descri.html
232
+ pr_description = pr_description.dup.force_encoding(Encoding::UTF_16)
233
+ if pr_description.length > MAX_PR_DESCRIPTION_LENGTH
234
+ truncated_msg = "...\n\n_Description has been truncated_".dup.force_encoding(Encoding::UTF_16)
235
+ truncate_length = MAX_PR_DESCRIPTION_LENGTH - truncated_msg.length
236
+ pr_description = (pr_description[0..truncate_length] + truncated_msg)
237
+ end
238
+ pr_description.force_encoding(Encoding::UTF_8)
239
+ end
240
+
233
241
  attr_reader :auth_header
234
242
  attr_reader :credentials
235
243
  attr_reader :source
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.125.4"
4
+ VERSION = "0.125.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.125.4
4
+ version: 0.125.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-17 00:00:00.000000000 Z
11
+ date: 2020-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-codecommit