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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 213247ca462fd48119c8878ad2495521991b2859
4
- data.tar.gz: c5c7dfbaee22aececc7eb8426d9824e270d554fa
3
+ metadata.gz: 7e43a52772ece5e47082fc17bc2a4a4347716c81
4
+ data.tar.gz: bab8674d4d4fb7870f8c6d1a00ddace25657b3d6
5
5
  SHA512:
6
- metadata.gz: 343e44cf2467a419aaeb748b955b94c2631466d36b44cd0fb6bbd1bc6bc6a37b8abad378cd27c28b9263c8710d11f800e45021ecb5e4183b73cdfe2f6cd44230
7
- data.tar.gz: eba2f24c5b40df8303395e21318869913a75e3a597a3220fb2bc09a05475e61ff66c957bd687a213deaa94e7179125cb485f5ae6665f92ec66bc33ac737455f9
6
+ metadata.gz: 0689580ec954452ef86e27aaf2f667ea83f59e90817e71ac86a93debb49c099ff30faf88ec58d3b0114d3eeb6d42927464d34ba0b86807b592c9e1214f7a77b1
7
+ data.tar.gz: 3eced031241e2c3be33873c1e23383f491ca12948de035fc247e270c37cab84203a0d0591dd24e6c93cc6169e7bd7abe8845d76900498aeddc97012d3644ab38
data/Gemfile CHANGED
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'rspec', '~> 3.4'
6
+ gem 'pry'
data/Gemfile.lock CHANGED
@@ -120,6 +120,7 @@ DEPENDENCIES
120
120
  danger-mention!
121
121
  guard (~> 2.14)
122
122
  guard-rspec (~> 4.7)
123
+ pry
123
124
  rake (~> 10.0)
124
125
  rspec (~> 3.4)
125
126
  rubocop (~> 0.41)
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
- path = host + '/' + repo_slug + '/' + 'blame' + '/' + github.branch_for_base
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
- user_blacklist << pr_author
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
@@ -1,4 +1,4 @@
1
1
  module DangerMention
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  DESCRIPTION = 'Danger plugin to automatically mention potential reviewers on pull requests'
4
4
  end
@@ -32,21 +32,22 @@ module Danger
32
32
 
33
33
  describe :compose_urls do
34
34
  before do
35
- allow(@mention).to receive_message_chain('env.request_source.host').and_return('host')
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://host/slug/blame/branch/%s', f) }
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 receive(:pr_author).and_return('author')
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-mention
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojtek Lukaszuk