dependabot-common 0.112.23 → 0.112.28

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: 9739bf9ed6384753d23d7c9f5aa511b19bfeeed400ebf206866e2a5a87cd2e02
4
- data.tar.gz: 470dd4daf818626c0c2824fd38e18b91e7a3df3390fbde07cd9aabfb7b4e0c00
3
+ metadata.gz: 857342c9058ee42bb8cf593f7ee5a5ecc6fb2b2582e58e75b5ecf5ba03db023c
4
+ data.tar.gz: de753e9fcc04de01fbdb4b8e7eae877747f67bc7448711e3eb128e70beb93e25
5
5
  SHA512:
6
- metadata.gz: 224772f202fd16546bd3be6de1cc749b7bc221e21e5f2eab192240b99d21b581bbe963231cb0440a0cc38ae1f805695cd9c07aa3ad80bdd97a10997e61df115a
7
- data.tar.gz: b721cf9ddff2395a5d0af942a1f1df0954ad58e3649d018ef9275bf75c12e44c3b9c3e9f5480661f274bbd3c2799f2eb8432ec6ed34e78f4666224f330a78aac
6
+ metadata.gz: 11f0f5c54393e6479e34309db26ae4619e8e302e89ecda71a6cec9ae69e5eae34311fec3ef557080b972246d6c123a962d90d8fe1a0170daa94353f9919e45bf
7
+ data.tar.gz: 93a0210a3d8e4054f5c46c884b98fa360c05f2e2175b9669410fd12ca91a516afb6bfd273ffcf0cfc011102a06f408702c2206293b879cd0c05dd776d9ea9984
@@ -258,7 +258,10 @@ module Dependabot
258
258
  team_reviewers: reviewers_hash[:team_reviewers] || []
259
259
  )
260
260
  rescue Octokit::UnprocessableEntity => e
261
- return if invalid_reviewer?(e.message)
261
+ if invalid_reviewer?(e.message)
262
+ comment_with_invalid_reviewer(pull_request, e.message)
263
+ return
264
+ end
262
265
 
263
266
  raise
264
267
  end
@@ -271,6 +274,36 @@ module Dependabot
271
274
  false
272
275
  end
273
276
 
277
+ def comment_with_invalid_reviewer(pull_request, message)
278
+ reviewers_hash =
279
+ Hash[reviewers.keys.map { |k| [k.to_sym, reviewers[k]] }]
280
+ reviewers = []
281
+ reviewers += reviewers_hash[:reviewers] || []
282
+ reviewers += (reviewers_hash[:team_reviewers] || []).
283
+ map { |rv| "#{source.repo.split('/').first}/#{rv}" }
284
+
285
+ reviewers_string =
286
+ if reviewers.count == 1
287
+ "`@#{reviewers.first}`"
288
+ else
289
+ names = reviewers.map { |rv| "`@#{rv}`" }
290
+ "#{names[0..-2].join(', ')} and #{names[-1]}"
291
+ end
292
+
293
+ msg = "Dependabot tried to add #{reviewers_string} as "
294
+ msg += reviewers.count > 1 ? "reviewers" : "a reviewer"
295
+ msg += " to this PR, but received the following error from GitHub:\n\n"\
296
+ "```\n" \
297
+ "#{message}\n"\
298
+ "```"
299
+
300
+ github_client_for_source.add_comment(
301
+ source.repo,
302
+ pull_request.number,
303
+ msg
304
+ )
305
+ end
306
+
274
307
  def add_assignees_to_pull_request(pull_request)
275
308
  github_client_for_source.add_assignees(
276
309
  source.repo,
@@ -6,9 +6,13 @@ module Dependabot
6
6
  class PullRequestCreator
7
7
  class MessageBuilder
8
8
  class IssueLinker
9
+ REPO_REGEX = %r{(?<repo>[\w.-]+/(?:(?!\.git|\.\s)[\w.-])+)}.freeze
9
10
  TAG_REGEX = /(?<tag>(?:\#|GH-)\d+)/i.freeze
10
11
  ISSUE_LINK_REGEXS = [
11
- /(?<=[^A-Za-z0-9\[\\]|^)\\*#{TAG_REGEX}(?=[^A-Za-z0-9\-]|$)/.freeze,
12
+ /
13
+ (?:(?<=[^A-Za-z0-9\[\\]|^)\\*#{TAG_REGEX}(?=[^A-Za-z0-9\-]|$))|
14
+ (?:(?<=\s|^)#{REPO_REGEX}#{TAG_REGEX}(?=[^A-Za-z0-9\-]|$))
15
+ /x.freeze,
12
16
  /\[#{TAG_REGEX}\](?=[^A-Za-z0-9\-\(])/.freeze,
13
17
  /\[(?<tag>(?:\#|GH-)?\d+)\]\(\)/i.freeze
14
18
  ].freeze
@@ -28,7 +32,14 @@ module Dependabot
28
32
  match(/(?<tag>(?:\#|GH-)?\d+)/i).
29
33
  named_captures.fetch("tag")
30
34
  number = tag.match(/\d+/).to_s
31
- "[#{tag}](#{source_url}/issues/#{number})"
35
+
36
+ repo = issue_link.
37
+ match("#{REPO_REGEX}#{TAG_REGEX}")&.
38
+ named_captures&.
39
+ fetch("repo", nil)
40
+ source = repo ? "https://github.com/#{repo}" : source_url
41
+
42
+ "[#{repo ? (repo + tag) : tag}](#{source}/issues/#{number})"
32
43
  end
33
44
  end
34
45
  end
@@ -9,7 +9,7 @@ module Dependabot
9
9
  GITHUB_USERNAME = /[a-z0-9]+(-[a-z0-9]+)*/i.freeze
10
10
  GITHUB_REF_REGEX = %r{
11
11
  (?:https?://)?
12
- github\.com/#{GITHUB_USERNAME}/[^/\s]+/
12
+ github\.com/(?<repo>#{GITHUB_USERNAME}/[^/\s]+)/
13
13
  (?:issue|pull)s?/(?<number>\d+)
14
14
  }x.freeze
15
15
 
@@ -76,7 +76,9 @@ module Dependabot
76
76
  ref.gsub("github.com", github_redirection_service || "github.com")
77
77
  if (previous_char.nil? || previous_char.match?(/\s/)) &&
78
78
  (next_char.nil? || next_char.match?(/\s/))
79
- "[##{last_match.named_captures.fetch('number')}]"\
79
+ number = last_match.named_captures.fetch("number")
80
+ repo = last_match.named_captures.fetch("repo")
81
+ "[#{repo}##{number}]"\
80
82
  "(#{sanitized_url})"
81
83
  else
82
84
  sanitized_url
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.112.23"
4
+ VERSION = "0.112.28"
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.112.23
4
+ version: 0.112.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ecr