danger-gitlab_reviewbot 1.0.2 → 1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18d9331afe98308a84876492708add4449315fe4a1f90145c9b23e70e8547fb7
|
4
|
+
data.tar.gz: 9abbf57104a68241af9bfc41475ddd32872ee7210a5f87096716b8ad1952611c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 474afe53630d3bd6c7c09b718d120ee0a966ac5fae93c80520e8ab1b4cff2376bb866ccbfce8b1c198afb923296755f222751e4e76f4b77a44f7fa81a130bae3
|
7
|
+
data.tar.gz: 537f846fa8177706d9dfa989c50dc36dba52730530bc617d0c1b3e24f4fa9075956082033ec4b4f9187bcfa507ef1a966bb2bcf3382ec018fe224237e9f2e0e7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-gitlab_reviewbot (1.0
|
4
|
+
danger-gitlab_reviewbot (1.1.0)
|
5
5
|
danger-gitlab
|
6
6
|
danger-plugin-api (~> 1.0)
|
7
7
|
|
@@ -20,26 +20,26 @@ GEM
|
|
20
20
|
colored2 (3.1.2)
|
21
21
|
cork (0.3.0)
|
22
22
|
colored2 (~> 3.1)
|
23
|
-
danger (
|
23
|
+
danger (6.3.2)
|
24
24
|
claide (~> 1.0)
|
25
25
|
claide-plugins (>= 0.9.2)
|
26
26
|
colored2 (~> 3.1)
|
27
27
|
cork (~> 0.1)
|
28
|
-
faraday (
|
28
|
+
faraday (~> 0.9)
|
29
29
|
faraday-http-cache (~> 2.0)
|
30
|
-
git (~> 1.
|
30
|
+
git (~> 1.6)
|
31
31
|
kramdown (~> 2.0)
|
32
32
|
kramdown-parser-gfm (~> 1.0)
|
33
33
|
no_proxy_fix
|
34
34
|
octokit (~> 4.7)
|
35
35
|
terminal-table (~> 1)
|
36
|
-
danger-gitlab (
|
37
|
-
danger (
|
38
|
-
gitlab (~> 4.0)
|
36
|
+
danger-gitlab (7.0.0)
|
37
|
+
danger (~> 6.0)
|
38
|
+
gitlab (~> 4.2, >= 4.2.0)
|
39
39
|
danger-plugin-api (1.0.0)
|
40
40
|
danger (> 2.0)
|
41
41
|
diff-lcs (1.3)
|
42
|
-
faraday (
|
42
|
+
faraday (0.17.3)
|
43
43
|
multipart-post (>= 1.2, < 3)
|
44
44
|
faraday-http-cache (2.2.0)
|
45
45
|
faraday (>= 0.8)
|
@@ -42,6 +42,10 @@ module Gitlab
|
|
42
42
|
merge_requests(project_id, :state => 'opened', :per_page => '100').select { |mr| mr.merge_status != 'can_be_merged' }
|
43
43
|
end
|
44
44
|
|
45
|
+
def find_user_with_username(username)
|
46
|
+
users({:username => username}).map { |u| User.new(u.id, u.username) }
|
47
|
+
end
|
48
|
+
|
45
49
|
def users_with_pending_mr_review(project_id)
|
46
50
|
outstanding_mrs = fetch_mrs_requiring_review(project_id)
|
47
51
|
all_assignees = outstanding_mrs.reduce([]) { |acc, mr| acc + mr.assignees }
|
@@ -32,7 +32,7 @@ module Danger
|
|
32
32
|
# NOTE: The plugin won't remove existing assigned reviewers
|
33
33
|
#
|
34
34
|
# @return Int
|
35
|
-
|
35
|
+
attr_writer :assignees_amount
|
36
36
|
def assignees_amount
|
37
37
|
@assignees_amount || 1
|
38
38
|
end
|
@@ -44,7 +44,7 @@ module Danger
|
|
44
44
|
# * Danger::AssignStrategies::LeastBusyStrategy - assign the N users with the least amount of open MRs
|
45
45
|
# to review
|
46
46
|
#
|
47
|
-
|
47
|
+
attr_writer :strategy
|
48
48
|
def strategy
|
49
49
|
@strategy || Danger::AssignStrategies::RandomStrategy
|
50
50
|
end
|
@@ -5,12 +5,14 @@ module Danger
|
|
5
5
|
attr_accessor :project_id
|
6
6
|
attr_accessor :group_name
|
7
7
|
attr_accessor :client
|
8
|
+
attr_accessor :excluded_users
|
8
9
|
|
9
10
|
def initialize(client:, project:, mr:, group:)
|
10
11
|
@client = client
|
11
12
|
@project_id = project
|
12
13
|
@mr_iid = mr
|
13
14
|
@group_name = group
|
15
|
+
@excluded_users = []
|
14
16
|
end
|
15
17
|
|
16
18
|
def assign!(amount)
|
@@ -37,7 +39,8 @@ module Danger
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def fetch_users_in_group
|
40
|
-
client.
|
42
|
+
excluded_users = @excluded_users.map { |u| client.find_user_with_username(u) }
|
43
|
+
client.fetch_users_for_group(@group_name).filter { |u| ! excluded_users.include? u }
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -10,9 +10,11 @@ module Danger
|
|
10
10
|
@tom = Gitlab::User.new(2, 'Tom')
|
11
11
|
@nic = Gitlab::User.new(3, 'Nic')
|
12
12
|
@luke = Gitlab::User.new(4, 'Luke')
|
13
|
+
@lei = Gitlab::User.new(5, 'Lei')
|
14
|
+
|
13
15
|
|
14
16
|
@mock_client = double(Gitlab::Client)
|
15
|
-
@author = @
|
17
|
+
@author = @lei
|
16
18
|
@members = [@author, @tom, @sam]
|
17
19
|
allow(@mock_client).to receive(:fetch_author_for_mr).and_return(@author)
|
18
20
|
allow(@mock_client).to receive(:fetch_users_for_group).with(2200).and_return(@members)
|
@@ -54,6 +56,23 @@ module Danger
|
|
54
56
|
@strategy.assign!(2)
|
55
57
|
end
|
56
58
|
|
59
|
+
it "honours excluded users" do
|
60
|
+
allow(@mock_client).to receive(:fetch_mr_reviewers).with(10, 110).and_return([])
|
61
|
+
allow(@mock_client).to receive(:find_user_with_username).with('Luke').and_return(@luke)
|
62
|
+
allow(@mock_client).to receive(:find_user_with_username).with('Nic').and_return(@nic)
|
63
|
+
allow(@mock_client).to receive(:fetch_users_for_group).with(2200).and_return(@members + [@nic, @luke])
|
64
|
+
@strategy.excluded_users = ['Nic', 'Luke']
|
65
|
+
|
66
|
+
expect(@mock_client).to receive(:assign_mr_to_users) do |project, mr, users|
|
67
|
+
expect(project).to be == 10
|
68
|
+
expect(mr).to be == 110
|
69
|
+
expect(users).to contain_exactly(@tom, @sam)
|
70
|
+
end
|
71
|
+
|
72
|
+
@strategy.assign!(2)
|
73
|
+
|
74
|
+
end
|
75
|
+
|
57
76
|
|
58
77
|
end
|
59
78
|
end
|