danger 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6408840e4167a8092819c1b40d3c409b61df856b
4
- data.tar.gz: 036b9a85309a45403d2649949f7f63b2722d5a50
3
+ metadata.gz: fc585b3a42ead8015e789fab0a20800043436033
4
+ data.tar.gz: 5568de8b9b97cdf2296ff8ef386286a4dc03096d
5
5
  SHA512:
6
- metadata.gz: decc456c54fc15961a5f73c92b8cf131a784bffb01842d05f97dff361f36ece7a0dbc1443e9d74fde21acd40a3c83fa070e0cc17dfc33745788f7a68441d1ead
7
- data.tar.gz: 56c7fe3cf50c9d0b8d7fb91f2e70f195970f10c7ec1f813768c357626eac43212edde7697ccf4e6ee1b2225f76b0d3628cfaa803893dc228c5cd6eba1458909d
6
+ metadata.gz: c955e1a1a81c272e25e6abdb5b3d8e51630f2f2850ef4c696acda0e5348f37211ced89910af612a592fab1c492c4ddc6bb3ccc9c0d704a49c23330ee0d628528
7
+ data.tar.gz: 8d88d1ad781ff5705e44d3f8780191786ccbb19012fc845c062c58b3412bf6a504f2c11b73a4a8052ab43d4a243e85920deba3c76564a561009cf98d3f385c6f
@@ -13,7 +13,8 @@ module Danger
13
13
  # ```
14
14
  # ### Token Setup
15
15
  #
16
- # Add the `DANGER_GITHUB_API_TOKEN` to your workflow's Secret Env Vars
16
+ # Add the `DANGER_GITHUB_API_TOKEN` to your workflow's App Env Vars.
17
+ # Warning: adding the token as a Secret Env Var will not work for PR builds, as [Bitrise does not expose secret vars to PRs](https://bitrise.uservoice.com/forums/235233-general/suggestions/11701587-make-secret-env-variables-available-for-prs-from-t).
17
18
  #
18
19
  class Bitrise < CI
19
20
  def self.validates_as_ci?(env)
@@ -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 🚫 [danger](http://example.com/ "generated_by_<%= @danger_id %>")
20
+ Generated by 🚫 [danger](https://danger.systems/ "generated_by_<%= @danger_id %>")
@@ -125,7 +125,7 @@ module Danger
125
125
 
126
126
  else
127
127
  value = plugin.send(method)
128
- value = value.scan(/.{,80}/).to_a.each(&:strip!).join("\n") if value.kind_of?(String)
128
+ value = wrap_text(value) if value.kind_of?(String)
129
129
  # So that we either have one value per row
130
130
  # or we have [] for an empty array
131
131
  value = value.join("\n") if value.kind_of?(Array) && value.count > 0
@@ -247,5 +247,12 @@ module Danger
247
247
  end
248
248
  end unless rows.empty?
249
249
  end
250
+
251
+ def wrap_text(text, width = 80)
252
+ text.gsub(/.{,#{width}}/) do |line|
253
+ line.strip!
254
+ "#{line}\n"
255
+ end
256
+ end
250
257
  end
251
258
  end
@@ -150,6 +150,26 @@ module Danger
150
150
  # @return [String]
151
151
  #
152
152
  def html_link(paths, full_path: true)
153
+ create_link(paths, full_path) { |href, text| create_html_link(href, text) }
154
+ end
155
+
156
+ # @!group Bitbucket Server Misc
157
+ # Returns a list of Markdown links for a file, or files in the head repository.
158
+ # It returns a string of multiple links if passed an array.
159
+ # @param [String or Array<String>] paths
160
+ # A list of strings to convert to Markdown links
161
+ # @param [Bool] full_path
162
+ # Shows the full path as the link's text, defaults to `true`.
163
+ #
164
+ # @return [String]
165
+ #
166
+ def markdown_link(paths, full_path: true)
167
+ create_link(paths, full_path) { |href, text| create_markdown_link(href, text) }
168
+ end
169
+
170
+ private
171
+
172
+ def create_link(paths, full_path)
153
173
  paths = [paths] unless paths.kind_of?(Array)
154
174
  commit = head_commit
155
175
  repo = pr_json[:fromRef][:repository][:links][:self].flat_map { |l| l[:href] }.first
@@ -160,17 +180,19 @@ module Danger
160
180
  text = full_path ? path : File.basename(path)
161
181
  url_path.gsub!(" ", "%20")
162
182
  line_ref = line ? "##{line}" : ""
163
- create_link("#{repo}/browse/#{url_path}?at=#{commit}#{line_ref}", text)
183
+ yield("#{repo}#{url_path}?at=#{commit}#{line_ref}", text)
164
184
  end
165
185
 
166
186
  return paths.first if paths.count < 2
167
187
  paths.first(paths.count - 1).join(", ") + " & " + paths.last
168
188
  end
169
189
 
170
- private
171
-
172
- def create_link(href, text)
190
+ def create_html_link(href, text)
173
191
  "<a href='#{href}'>#{text}</a>"
174
192
  end
193
+
194
+ def create_markdown_link(href, text)
195
+ "[#{text}](#{href})"
196
+ end
175
197
  end
176
198
  end
@@ -192,9 +192,9 @@ module Danger
192
192
  def html_link(paths, full_path: true)
193
193
  paths = [paths] unless paths.kind_of?(Array)
194
194
  commit = head_commit
195
- same_repo = mr_json[:project_id] == mr_json[:source_project_id]
196
- sender_repo = ci_source.repo_slug.split("/").first + "/" + mr_json[:author][:username]
197
- repo = same_repo ? ci_source.repo_slug : sender_repo
195
+ same_repo = mr_json["project_id"] == mr_json["source_project_id"]
196
+ sender_repo = env.ci_source.repo_slug.split("/").first + "/" + mr_author
197
+ repo = same_repo ? env.ci_source.repo_slug : sender_repo
198
198
  host = @gitlab.host
199
199
 
200
200
  paths = paths.map do |path|
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "3.2.1".freeze
2
+ VERSION = "3.2.2".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
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: 3.2.1
4
+ version: 3.2.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-09-04 00:00:00.000000000 Z
12
+ date: 2016-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide