danger-mention 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +1 -0
- data/README.md +1 -1
- data/lib/danger_plugin.rb +18 -2
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +28 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e43a52772ece5e47082fc17bc2a4a4347716c81
|
4
|
+
data.tar.gz: bab8674d4d4fb7870f8c6d1a00ddace25657b3d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0689580ec954452ef86e27aaf2f667ea83f59e90817e71ac86a93debb49c099ff30faf88ec58d3b0114d3eeb6d42927464d34ba0b86807b592c9e1214f7a77b1
|
7
|
+
data.tar.gz: 3eced031241e2c3be33873c1e23383f491ca12948de035fc247e270c37cab84203a0d0591dd24e6c93cc6169e7bd7abe8845d76900498aeddc97012d3644ab38
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Danger Mention
|
2
2
|
|
3
|
-
A [Danger](https://github.com/danger/danger) plugin to automatically mention potential reviewers on pull requests.
|
3
|
+
A [Danger](https://github.com/danger/danger) plugin to automatically mention potential reviewers on pull requests on GitHub and GitLab.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
data/lib/danger_plugin.rb
CHANGED
@@ -75,7 +75,18 @@ module Danger
|
|
75
75
|
def compose_urls(files)
|
76
76
|
host = 'https://' + env.request_source.host
|
77
77
|
repo_slug = env.ci_source.repo_slug
|
78
|
-
|
78
|
+
|
79
|
+
path = ""
|
80
|
+
if defined? @dangerfile.gitlab
|
81
|
+
# https://gitlab.com/danger-systems/danger.systems/blame/danger_update/.gitlab-ci.yml
|
82
|
+
path = host + '/' + repo_slug + '/' + 'blame' + '/' + gitlab.branch_for_base
|
83
|
+
|
84
|
+
elsif defined? @dangerfile.github
|
85
|
+
# https://github.com/artsy/emission/blame/master/dangerfile.js
|
86
|
+
path = host + '/' + repo_slug + '/' + 'blame' + '/' + github.branch_for_base
|
87
|
+
else
|
88
|
+
raise "This plugin does not yet support bitbucket, would love PRs: https://github.com/danger/danger-mention/"
|
89
|
+
end
|
79
90
|
|
80
91
|
urls = []
|
81
92
|
files.each do |file|
|
@@ -105,7 +116,12 @@ module Danger
|
|
105
116
|
end
|
106
117
|
|
107
118
|
def find_reviewers(users, user_blacklist, max_reviewers)
|
108
|
-
|
119
|
+
if defined? @dangerfile.gitlab
|
120
|
+
user_blacklist << gitlab.mr_author
|
121
|
+
elsif defined? @dangerfile.github
|
122
|
+
user_blacklist << github.pr_author
|
123
|
+
end
|
124
|
+
|
109
125
|
users = users.select { |k, _| !user_blacklist.include? k }
|
110
126
|
users = users.sort_by { |_, value| value }.reverse
|
111
127
|
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -32,21 +32,22 @@ module Danger
|
|
32
32
|
|
33
33
|
describe :compose_urls do
|
34
34
|
before do
|
35
|
-
|
35
|
+
github = Danger::RequestSources::GitHub.new({}, testing_env)
|
36
|
+
allow(@mention).to receive_message_chain('env.request_source').and_return github
|
36
37
|
allow(@mention).to receive_message_chain('env.ci_source.repo_slug').and_return('slug')
|
37
38
|
allow(@mention).to receive_message_chain('github.branch_for_base').and_return('branch')
|
38
39
|
end
|
39
40
|
|
40
41
|
it 'composes urls for files' do
|
41
42
|
files = (1..4).to_a.map { |i| format('M%d', i) }
|
42
|
-
expected = files.map { |f| format('https://
|
43
|
+
expected = files.map { |f| format('https://github.com/slug/blame/branch/%s', f) }
|
43
44
|
results = @mention.compose_urls(files)
|
44
45
|
expect(results).to eq expected
|
45
46
|
end
|
46
47
|
|
47
48
|
describe :compose_urls do
|
48
49
|
before do
|
49
|
-
allow(@mention).to
|
50
|
+
allow(@mention).to receive_message_chain('github.pr_author').and_return('author')
|
50
51
|
end
|
51
52
|
|
52
53
|
it 'finds potential reviewers' do
|
@@ -88,7 +89,31 @@ module Danger
|
|
88
89
|
expect(output).to include('@user2')
|
89
90
|
end
|
90
91
|
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
describe :compose_urls_gitlab do
|
96
|
+
|
97
|
+
it 'composes gitlab urls for files' do
|
98
|
+
stub_env = {
|
99
|
+
"DRONE" => true,
|
100
|
+
"DRONE_REPO" => "k0nserv/danger-test",
|
101
|
+
"DRONE_PULL_REQUEST" => "593728",
|
102
|
+
"DANGER_GITLAB_API_TOKEN" => "a86e56d46ac78b"
|
103
|
+
}
|
104
|
+
|
105
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
106
|
+
env.request_source = Danger::RequestSources::GitLab.new(Danger::Drone.new(stub_env), testing_env)
|
107
|
+
danger = Danger::Dangerfile.new(env)
|
108
|
+
allow(danger.gitlab).to receive(:branch_for_base).and_return("branch_name")
|
91
109
|
|
110
|
+
files = (1..4).to_a.map { |i| format('M%d', i) }
|
111
|
+
expected = files.map { |f| format('https://gitlab.com/artsy/eigen/blame/branch_name/%s', f) }
|
112
|
+
|
113
|
+
results = danger.mention.compose_urls(files)
|
114
|
+
expect(results).to eq expected
|
115
|
+
end
|
92
116
|
end
|
93
117
|
end
|
94
118
|
end
|
119
|
+
|