danger-reviewer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reviewer/gem_version.rb +1 -1
- data/lib/reviewer/plugin.rb +14 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 646b0e5035c84b5a44fa8d5e9d1cf595c41b77d2cefc2ee0bfc4247dc75e090c
|
4
|
+
data.tar.gz: 9d77d32e0e27a25953c38049d6f7a69f0e2aa62d779f97eec00e348a916e979d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dc2417d16f930402640e6df18dc1ba35e69da0c5cf9888363c58637afcce78192f765cab32c54f7163336895920c3c3b181746c8b66270c69cc72ef5db64270
|
7
|
+
data.tar.gz: 88133eef61b9fa14c7d8aa28bdd4a6ecb154b7eee6d4b9a4dd524b03c6c9cabc3859d9dd567ae7bd26f6b935550312f6a39c4f3a833a787c5a6ec24efe53213a
|
data/lib/reviewer/gem_version.rb
CHANGED
data/lib/reviewer/plugin.rb
CHANGED
@@ -13,7 +13,7 @@ module Danger
|
|
13
13
|
|
14
14
|
authors = find_authors
|
15
15
|
members = team_members(team)
|
16
|
-
reviewers = find_reviewers((authors & members), user_blacklist, (max_reviewers - current.count))
|
16
|
+
reviewers = find_reviewers((authors & members), members, user_blacklist, (max_reviewers - current.count))
|
17
17
|
|
18
18
|
request_reviews(reviewers)
|
19
19
|
end
|
@@ -21,8 +21,6 @@ module Danger
|
|
21
21
|
def request_reviews(reviewers)
|
22
22
|
owner, repo = env.ci_source.repo_slug.split('/')
|
23
23
|
|
24
|
-
require 'pry'; binding.pry
|
25
|
-
|
26
24
|
uri = URI.parse("https://api.github.com/repos/#{owner}/#{repo}/pulls/#{github.pr_json[:number]}/requested_reviewers")
|
27
25
|
header = {'Content-Type': 'text/json', 'Authorization': "token #{ENV['DANGER_GITHUB_API_TOKEN']}" }
|
28
26
|
|
@@ -44,6 +42,7 @@ module Danger
|
|
44
42
|
|
45
43
|
git.modified_files.each do |file|
|
46
44
|
result = GitHub::Client.query(GitHub::BlameQuery, variables: { repository: repo, owner: owner, ref: branch, file: file })
|
45
|
+
next if result.data.repository.ref.nil?
|
47
46
|
result.data.repository.ref.target.blame.ranges.each do |range|
|
48
47
|
lines = (range.ending_line - range.starting_line) + 1
|
49
48
|
users[range.commit.author.user.login] += lines unless range.commit.author.user.nil?
|
@@ -53,13 +52,21 @@ module Danger
|
|
53
52
|
users.keys
|
54
53
|
end
|
55
54
|
|
56
|
-
def find_reviewers(
|
55
|
+
def find_reviewers(authors, members, user_blacklist, max_reviewers)
|
57
56
|
user_blacklist << github.pr_author
|
58
57
|
|
59
|
-
|
60
|
-
|
58
|
+
reviewers = []
|
59
|
+
|
60
|
+
authors = authors - user_blacklist
|
61
|
+
authors = authors.sort_by { |_, value| value }.reverse
|
62
|
+
|
63
|
+
reviewers += authors[0...max_reviewers]
|
64
|
+
|
65
|
+
if reviewers.count < max_reviewers
|
66
|
+
reviewers += (members - reviewers).sample(max_reviewers - reviewers.count)
|
67
|
+
end
|
61
68
|
|
62
|
-
|
69
|
+
reviewers
|
63
70
|
end
|
64
71
|
|
65
72
|
def current_reviewers
|