danger 4.0.1 → 4.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/danger/ci_source/xcode_server.rb +4 -1
- data/lib/danger/comment_generators/bitbucket_server.md.erb +3 -3
- data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +4 -6
- data/lib/danger/helpers/comments_helper.rb +9 -19
- data/lib/danger/helpers/emoji_mapper.rb +31 -0
- data/lib/danger/plugin_support/gems_resolver.rb +70 -0
- data/lib/danger/plugin_support/plugin_file_resolver.rb +14 -50
- data/lib/danger/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f983a96eaf1ae2a10009156c9b9be097912057a4
|
4
|
+
data.tar.gz: 13651a9f71c8abfc8b38cd0bf068d935d3c963c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7234f33564197cb0b0d92f528b64e0ce66a4c328c6298ace6d33a3f2a1474c7e8e5766ae862f61e529f490f3a54867b7c81b17ddfc346909bef1f99ae086c9
|
7
|
+
data.tar.gz: 5b4f0190b920e7c1033f9226ea92cf98ce47b64676ad1bcf2566e528ba24094e128c56d65ca8fdd50a88fcf4cd3eea7ebb0cab05613289ef7663555472005eda
|
@@ -27,7 +27,10 @@ module Danger
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def supported_request_sources
|
30
|
-
@supported_request_sources ||= [
|
30
|
+
@supported_request_sources ||= [
|
31
|
+
Danger::RequestSources::GitHub,
|
32
|
+
Danger::RequestSources::BitbucketServer
|
33
|
+
]
|
31
34
|
end
|
32
35
|
|
33
36
|
def initialize(env)
|
@@ -3,10 +3,10 @@
|
|
3
3
|
| | <%= table[:count] %> <%= table[:name] %><%= "s" unless table[:count] == 1 %> |
|
4
4
|
|---|---|
|
5
5
|
<%- table[:content].each do |violation| -%>
|
6
|
-
| <%=
|
6
|
+
| <%= @emoji_mapper.map(table[:emoji]) %> | <%= violation.message %> |
|
7
7
|
<%- end -%>
|
8
8
|
<%- table[:resolved].each do |message| -%>
|
9
|
-
|
|
9
|
+
| @emoji_mapper.map("white_check_mark") | <%= message %> |
|
10
10
|
<%- end -%>
|
11
11
|
|
12
12
|
<%- end -%>
|
@@ -17,4 +17,4 @@
|
|
17
17
|
<%# the previous line has to be aligned far to the left, otherwise markdown can break easily %>
|
18
18
|
<%- end -%>
|
19
19
|
|
20
|
-
Generated by
|
20
|
+
Generated by [danger](https://danger.systems/ "generated_by_<%= @danger_id %>")
|
@@ -140,8 +140,10 @@ module Danger
|
|
140
140
|
end
|
141
141
|
|
142
142
|
# @!group Bitbucket Server Misc
|
143
|
-
# Returns a list of
|
143
|
+
# Returns a list of Markdown links for a file, or files in the head repository.
|
144
144
|
# It returns a string of multiple anchors if passed an array.
|
145
|
+
# @note Atlassian [disabled inline HTML support](https://jira.atlassian.com/browse/BSERV-7147).
|
146
|
+
# This method method left for backward compatibility.
|
145
147
|
# @param [String or Array<String>] paths
|
146
148
|
# A list of strings to convert to github anchors
|
147
149
|
# @param [Bool] full_path
|
@@ -150,7 +152,7 @@ module Danger
|
|
150
152
|
# @return [String]
|
151
153
|
#
|
152
154
|
def html_link(paths, full_path: true)
|
153
|
-
|
155
|
+
markdown_link(paths, full_path: full_path)
|
154
156
|
end
|
155
157
|
|
156
158
|
# @!group Bitbucket Server Misc
|
@@ -187,10 +189,6 @@ module Danger
|
|
187
189
|
paths.first(paths.count - 1).join(", ") + " & " + paths.last
|
188
190
|
end
|
189
191
|
|
190
|
-
def create_html_link(href, text)
|
191
|
-
"<a href='#{href}'>#{text}</a>"
|
192
|
-
end
|
193
|
-
|
194
192
|
def create_markdown_link(href, text)
|
195
193
|
"[#{text}](#{href})"
|
196
194
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "kramdown"
|
2
2
|
require "danger/helpers/comments_parsing_helper"
|
3
|
+
require "danger/helpers/emoji_mapper"
|
3
4
|
|
4
5
|
# rubocop:disable Metrics/ModuleLength
|
5
6
|
|
@@ -70,8 +71,9 @@ module Danger
|
|
70
71
|
violations.reject { |_, v| v.empty? }
|
71
72
|
end
|
72
73
|
|
73
|
-
def table(name, emoji, violations, all_previous_violations)
|
74
|
-
content = violations
|
74
|
+
def table(name, emoji, violations, all_previous_violations, template: "github")
|
75
|
+
content = violations
|
76
|
+
content = content.map { |v| process_markdown(v) } unless template == "bitbucket_server"
|
75
77
|
|
76
78
|
kind = table_kind_from_title(name)
|
77
79
|
previous_violations = all_previous_violations[kind] || []
|
@@ -101,6 +103,7 @@ module Danger
|
|
101
103
|
@tables = tables
|
102
104
|
@markdowns = markdowns.map(&:message)
|
103
105
|
@danger_id = danger_id
|
106
|
+
@emoji_mapper = EmojiMapper.new(template)
|
104
107
|
|
105
108
|
return ERB.new(File.read(md_template), 0, "-").result(binding)
|
106
109
|
end
|
@@ -108,9 +111,9 @@ module Danger
|
|
108
111
|
def generate_comment(warnings: [], errors: [], messages: [], markdowns: [], previous_violations: {}, danger_id: "danger", template: "github")
|
109
112
|
apply_template(
|
110
113
|
tables: [
|
111
|
-
table("Error", "no_entry_sign", errors, previous_violations),
|
112
|
-
table("Warning", "warning", warnings, previous_violations),
|
113
|
-
table("Message", "book", messages, previous_violations)
|
114
|
+
table("Error", "no_entry_sign", errors, previous_violations, template: template),
|
115
|
+
table("Warning", "warning", warnings, previous_violations, template: template),
|
116
|
+
table("Message", "book", messages, previous_violations, template: template)
|
114
117
|
],
|
115
118
|
markdowns: markdowns,
|
116
119
|
danger_id: danger_id,
|
@@ -138,7 +141,7 @@ module Danger
|
|
138
141
|
if errors.empty? && warnings.empty?
|
139
142
|
return "All green. #{random_compliment}"
|
140
143
|
else
|
141
|
-
message = "
|
144
|
+
message = "⚠️ "
|
142
145
|
message += "#{'Error'.danger_pluralize(errors.count)}. " unless errors.empty?
|
143
146
|
message += "#{'Warning'.danger_pluralize(warnings.count)}. " unless warnings.empty?
|
144
147
|
message += "Don't worry, everything is fixable."
|
@@ -151,19 +154,6 @@ module Danger
|
|
151
154
|
"Yay.", "Jolly good show.", "Good on 'ya.", "Nice work."].sample
|
152
155
|
end
|
153
156
|
|
154
|
-
def character_from_emoji(emoji)
|
155
|
-
emoji.delete! ":"
|
156
|
-
if emoji == "no_entry_sign"
|
157
|
-
"🚫"
|
158
|
-
elsif emoji == "warning"
|
159
|
-
"⚠️"
|
160
|
-
elsif emoji == "book"
|
161
|
-
"📖"
|
162
|
-
elsif emoji == "white_check_mark"
|
163
|
-
"✅"
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
157
|
private
|
168
158
|
|
169
159
|
GITHUB_OLD_REGEX = %r{<th width="100%"(.*?)</th>}im
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Danger
|
2
|
+
class EmojiMapper
|
3
|
+
DATA = {
|
4
|
+
"github" => {
|
5
|
+
"no_entry_sign" => "🚫",
|
6
|
+
"warning" => "⚠️",
|
7
|
+
"book" => "📖",
|
8
|
+
"white_check_mark" => "✅"
|
9
|
+
},
|
10
|
+
"bitbucket_server" => {
|
11
|
+
"no_entry_sign" => "\u274C",
|
12
|
+
"warning" => "⚠️",
|
13
|
+
"book" => "\u2728",
|
14
|
+
"white_check_mark" => "\u2705"
|
15
|
+
}
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
def initialize(template)
|
19
|
+
@template = DATA.include?(template) ? template : "github"
|
20
|
+
end
|
21
|
+
|
22
|
+
def map(emoji)
|
23
|
+
emoji.delete! ":"
|
24
|
+
DATA[template][emoji]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :template
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "bundler"
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
class GemsResolver
|
5
|
+
def initialize(gem_names)
|
6
|
+
@gem_names = gem_names
|
7
|
+
@dir = Dir.mktmpdir # We want it to persist until OS cleans it on reboot
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns an Array of paths (plugin lib file paths) and gems (of metadata)
|
11
|
+
def call
|
12
|
+
Bundler.with_clean_env do
|
13
|
+
Dir.chdir(dir) do
|
14
|
+
create_gemfile_from_gem_names
|
15
|
+
`bundle install --path vendor/gems`
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
return paths, gems
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :gem_names, :dir
|
25
|
+
|
26
|
+
def create_gemfile_from_gem_names
|
27
|
+
gemfile = File.new("Gemfile", "w")
|
28
|
+
gemfile.write "source 'https://rubygems.org'"
|
29
|
+
|
30
|
+
gem_names.each do |plugin|
|
31
|
+
gemfile.write "\ngem '#{plugin}'"
|
32
|
+
end
|
33
|
+
|
34
|
+
gemfile.close
|
35
|
+
end
|
36
|
+
|
37
|
+
# The paths are relative to dir.
|
38
|
+
def paths
|
39
|
+
relative_paths = gem_names.flat_map do |plugin|
|
40
|
+
Dir.glob("vendor/gems/ruby/*/gems/#{plugin}*/lib/**/**/**/**.rb")
|
41
|
+
end
|
42
|
+
|
43
|
+
relative_paths.map { |path| File.join(dir, path) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def gems
|
47
|
+
real_gems.map { |gem| gem_metadata(gem) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def real_gems
|
51
|
+
spec_paths = gem_names.flat_map do |plugin|
|
52
|
+
Dir.glob("vendor/gems/ruby/*/specifications/#{plugin}*.gemspec").first
|
53
|
+
end
|
54
|
+
|
55
|
+
spec_paths.map { |path| Gem::Specification.load path }
|
56
|
+
end
|
57
|
+
|
58
|
+
def gem_metadata(gem)
|
59
|
+
{
|
60
|
+
name: gem.name,
|
61
|
+
gem: gem.name,
|
62
|
+
author: gem.authors,
|
63
|
+
url: gem.homepage,
|
64
|
+
description: gem.summary,
|
65
|
+
license: gem.license || "Unknown",
|
66
|
+
version: gem.version.to_s
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "pathname"
|
3
|
-
require "fileutils"
|
1
|
+
require "danger/plugin_support/gems_resolver"
|
4
2
|
|
5
3
|
module Danger
|
6
4
|
class PluginFileResolver
|
@@ -10,57 +8,23 @@ module Danger
|
|
10
8
|
@refs = references
|
11
9
|
end
|
12
10
|
|
11
|
+
# When given existing paths, map to absolute & existing paths
|
12
|
+
# When given a list of gems, resolve for list of gems
|
13
|
+
# When empty, imply you want to test the current lib folder as a plugin
|
13
14
|
def resolve
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# When given a list of gems
|
20
|
-
elsif @refs and @refs.kind_of? Array
|
21
|
-
Bundler.with_clean_env do
|
22
|
-
# We don't use the block syntax as we want it to persist until the OS cleans it on reboot
|
23
|
-
# or whatever, it needs to persist outside this scope.
|
24
|
-
dir = Dir.mktmpdir
|
25
|
-
|
26
|
-
Dir.chdir(dir) do
|
27
|
-
gem_names = @refs
|
28
|
-
gemfile = File.new("Gemfile", "w")
|
29
|
-
gemfile.write "source 'https://rubygems.org'"
|
30
|
-
|
31
|
-
gem_names.each do |plugin|
|
32
|
-
gemfile.write "\ngem '#{plugin}'"
|
33
|
-
end
|
34
|
-
|
35
|
-
gemfile.close
|
36
|
-
`bundle install --path vendor/gems`
|
37
|
-
|
38
|
-
# the paths are relative to our current Chdir
|
39
|
-
relative_paths = gem_names.flat_map { |plugin| Dir.glob("vendor/gems/ruby/*/gems/#{plugin}*/lib/**/**/**/**.rb") }
|
40
|
-
paths = relative_paths.map { |path| File.join(dir, path) }
|
41
|
-
|
42
|
-
spec_paths = gem_names.flat_map { |plugin| Dir.glob("vendor/gems/ruby/*/specifications/#{plugin}*.gemspec").first }
|
43
|
-
real_gems = spec_paths.map { |path| Gem::Specification.load path }
|
44
|
-
|
45
|
-
plugin_metadata = real_gems.map do |gem|
|
46
|
-
{
|
47
|
-
name: gem.name,
|
48
|
-
gem: gem.name,
|
49
|
-
author: gem.authors,
|
50
|
-
url: gem.homepage,
|
51
|
-
description: gem.summary,
|
52
|
-
license: gem.license || "Unknown",
|
53
|
-
version: gem.version.to_s
|
54
|
-
}
|
55
|
-
end
|
56
|
-
{ paths: paths, gems: plugin_metadata }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
# When empty, imply you want to test the current lib folder as a plugin
|
15
|
+
if !refs.nil? and refs.select { |ref| File.file? ref }.any?
|
16
|
+
paths = refs.select { |ref| File.file? ref }.map { |path| File.expand_path(path) }
|
17
|
+
elsif refs and refs.kind_of? Array
|
18
|
+
paths, gems = GemsResolver.new(refs).call
|
60
19
|
else
|
61
20
|
paths = Dir.glob(File.join(".", "lib/**/*.rb")).map { |path| File.expand_path(path) }
|
62
|
-
{ paths: paths, gems: [] }
|
63
21
|
end
|
22
|
+
|
23
|
+
{ paths: paths, gems: gems || [] }
|
64
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :refs
|
65
29
|
end
|
66
30
|
end
|
data/lib/danger/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orta Therox
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|
@@ -421,6 +421,8 @@ files:
|
|
421
421
|
- lib/danger/helpers/comment.rb
|
422
422
|
- lib/danger/helpers/comments_helper.rb
|
423
423
|
- lib/danger/helpers/comments_parsing_helper.rb
|
424
|
+
- lib/danger/helpers/emoji_mapper.rb
|
425
|
+
- lib/danger/plugin_support/gems_resolver.rb
|
424
426
|
- lib/danger/plugin_support/plugin.rb
|
425
427
|
- lib/danger/plugin_support/plugin_file_resolver.rb
|
426
428
|
- lib/danger/plugin_support/plugin_linter.rb
|
@@ -458,7 +460,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
458
460
|
version: '0'
|
459
461
|
requirements: []
|
460
462
|
rubyforge_project:
|
461
|
-
rubygems_version: 2.
|
463
|
+
rubygems_version: 2.5.2
|
462
464
|
signing_key:
|
463
465
|
specification_version: 4
|
464
466
|
summary: Like Unit Tests, but for your Team Culture.
|