danger 9.1.0 → 9.2.0

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/bin/danger +1 -1
  3. data/lib/danger/ci_source/appcircle.rb +71 -71
  4. data/lib/danger/ci_source/appveyor.rb +1 -0
  5. data/lib/danger/ci_source/azure_pipelines.rb +20 -5
  6. data/lib/danger/ci_source/bamboo.rb +1 -1
  7. data/lib/danger/ci_source/bitbucket_pipelines.rb +1 -2
  8. data/lib/danger/ci_source/bitrise.rb +3 -3
  9. data/lib/danger/ci_source/buildkite.rb +1 -1
  10. data/lib/danger/ci_source/circle_api.rb +2 -2
  11. data/lib/danger/ci_source/code_build.rb +1 -1
  12. data/lib/danger/ci_source/codefresh.rb +1 -1
  13. data/lib/danger/ci_source/concourse.rb +4 -5
  14. data/lib/danger/ci_source/dotci.rb +4 -6
  15. data/lib/danger/ci_source/github_actions.rb +6 -6
  16. data/lib/danger/ci_source/gitlab_ci.rb +4 -4
  17. data/lib/danger/ci_source/jenkins.rb +21 -22
  18. data/lib/danger/ci_source/local_git_repo.rb +7 -1
  19. data/lib/danger/ci_source/local_only_git_repo.rb +1 -0
  20. data/lib/danger/ci_source/support/find_repo_info_from_url.rb +11 -10
  21. data/lib/danger/ci_source/support/pull_request_finder.rb +15 -7
  22. data/lib/danger/ci_source/teamcity.rb +1 -1
  23. data/lib/danger/ci_source/xcode_cloud.rb +7 -7
  24. data/lib/danger/commands/init.rb +1 -1
  25. data/lib/danger/commands/local.rb +1 -1
  26. data/lib/danger/commands/local_helpers/http_cache.rb +2 -0
  27. data/lib/danger/commands/local_helpers/local_setup.rb +2 -0
  28. data/lib/danger/commands/local_helpers/pry_setup.rb +1 -0
  29. data/lib/danger/commands/plugins/plugin_json.rb +1 -3
  30. data/lib/danger/commands/plugins/plugin_lint.rb +0 -2
  31. data/lib/danger/commands/plugins/plugin_readme.rb +2 -5
  32. data/lib/danger/commands/runner.rb +1 -1
  33. data/lib/danger/commands/staging.rb +7 -7
  34. data/lib/danger/commands/systems.rb +4 -6
  35. data/lib/danger/core_ext/file_list.rb +2 -2
  36. data/lib/danger/danger_core/dangerfile.rb +13 -13
  37. data/lib/danger/danger_core/environment_manager.rb +2 -1
  38. data/lib/danger/danger_core/executor.rb +10 -11
  39. data/lib/danger/danger_core/message_aggregator.rb +1 -0
  40. data/lib/danger/danger_core/messages/base.rb +1 -0
  41. data/lib/danger/danger_core/messages/markdown.rb +3 -4
  42. data/lib/danger/danger_core/messages/violation.rb +1 -2
  43. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +1 -3
  44. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +4 -4
  45. data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +8 -2
  46. data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +3 -2
  47. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +2 -0
  48. data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +3 -1
  49. data/lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb +3 -2
  50. data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +3 -1
  51. data/lib/danger/danger_core/plugins/dangerfile_vsts_plugin.rb +3 -3
  52. data/lib/danger/danger_core/standard_error.rb +2 -3
  53. data/lib/danger/helpers/comments_helper.rb +5 -5
  54. data/lib/danger/helpers/comments_parsing_helper.rb +3 -2
  55. data/lib/danger/helpers/emoji_mapper.rb +1 -1
  56. data/lib/danger/plugin_support/plugin.rb +0 -1
  57. data/lib/danger/plugin_support/plugin_linter.rb +1 -0
  58. data/lib/danger/request_sources/bitbucket_cloud.rb +3 -5
  59. data/lib/danger/request_sources/bitbucket_cloud_api.rb +2 -4
  60. data/lib/danger/request_sources/bitbucket_server.rb +10 -13
  61. data/lib/danger/request_sources/bitbucket_server_api.rb +9 -10
  62. data/lib/danger/request_sources/code_insights_api.rb +7 -11
  63. data/lib/danger/request_sources/github/github.rb +15 -14
  64. data/lib/danger/request_sources/github/github_review.rb +3 -2
  65. data/lib/danger/request_sources/github/github_review_resolver.rb +0 -2
  66. data/lib/danger/request_sources/github/github_review_unsupported.rb +0 -2
  67. data/lib/danger/request_sources/gitlab.rb +46 -58
  68. data/lib/danger/request_sources/local_only.rb +0 -2
  69. data/lib/danger/request_sources/request_source.rb +4 -4
  70. data/lib/danger/request_sources/support/get_ignored_violation.rb +1 -1
  71. data/lib/danger/request_sources/vsts.rb +8 -10
  72. data/lib/danger/request_sources/vsts_api.rb +5 -2
  73. data/lib/danger/version.rb +1 -1
  74. data/lib/danger.rb +1 -0
  75. metadata +34 -35
  76. data/lib/danger/ci_source/vsts.rb +0 -73
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "danger/plugin_support/plugin"
4
2
 
5
3
  module Danger
@@ -58,6 +56,7 @@ module Danger
58
56
  # So that this init can fail.
59
57
  def self.new(dangerfile)
60
58
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::VSTS
59
+
61
60
  super
62
61
  end
63
62
 
@@ -174,6 +173,7 @@ module Danger
174
173
  end
175
174
 
176
175
  return paths.first if paths.count < 2
176
+
177
177
  paths.first(paths.count - 1).join(", ") + " & " + paths.last
178
178
  end
179
179
 
@@ -184,7 +184,7 @@ module Danger
184
184
  end
185
185
 
186
186
  def branch_name(key)
187
- repo_matches = @source.pr_json[key].to_s.match(%r{refs\/heads\/(.*)})
187
+ repo_matches = @source.pr_json[key].to_s.match(%r{refs/heads/(.*)})
188
188
  repo_matches[1] unless repo_matches.nil?
189
189
  end
190
190
  end
@@ -37,9 +37,7 @@ module Danger
37
37
  # be raised.
38
38
  #
39
39
  def contents
40
- @contents ||= begin
41
- dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
42
- end
40
+ @contents ||= dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
43
41
  end
44
42
 
45
43
  # The message of the exception reports the content of podspec for the
@@ -104,6 +102,7 @@ module Danger
104
102
 
105
103
  trace_line = backtrace.find { |l| l.include?(dsl_path.to_s) } || trace_line
106
104
  return result unless trace_line
105
+
107
106
  line_numer = trace_line.split(":")[1].to_i - 1
108
107
  return result unless line_numer
109
108
 
@@ -11,7 +11,7 @@ module Danger
11
11
  include Danger::Helpers::CommentsParsingHelper
12
12
 
13
13
  def markdown_parser(text)
14
- Kramdown::Document.new(text, input: "GFM", smart_quotes: %w[apos apos quot quot])
14
+ Kramdown::Document.new(text, input: "GFM", smart_quotes: %w(apos apos quot quot))
15
15
  end
16
16
 
17
17
  # !@group Extension points
@@ -26,6 +26,7 @@ module Danger
26
26
  # @return [String] The Markdown compatible link
27
27
  def markdown_link_to_message(message, hide_link)
28
28
  return "" if hide_link
29
+
29
30
  "#{message.file}#L#{message.line}"
30
31
  end
31
32
 
@@ -87,9 +88,9 @@ module Danger
87
88
  @tables = tables
88
89
  @markdowns = markdowns.map(&:message)
89
90
  @danger_id = danger_id
90
- @emoji_mapper = EmojiMapper.new(request_source.sub("_inline",""))
91
+ @emoji_mapper = EmojiMapper.new(request_source.sub("_inline", ""))
91
92
 
92
- return ERB.new(File.read(md_template), 0, "-").result(binding)
93
+ return ERB.new(File.read(md_template), trim_mode: "-").result(binding)
93
94
  end
94
95
 
95
96
  def generate_comment(warnings: [], errors: [], messages: [], markdowns: [], previous_violations: {}, danger_id: "danger", template: "github")
@@ -118,7 +119,6 @@ module Danger
118
119
  @resolved = resolved
119
120
  request_source_name = template.sub("_message_group", "")
120
121
 
121
-
122
122
  apply_template(danger_id: danger_id,
123
123
  markdowns: message_group.markdowns,
124
124
  template: template,
@@ -149,7 +149,7 @@ module Danger
149
149
  def generate_description(warnings: nil, errors: nil, template: "github")
150
150
  emoji_mapper = EmojiMapper.new(template)
151
151
  if (errors.nil? || errors.empty?) && (warnings.nil? || warnings.empty?)
152
- return ENV['DANGER_SUCCESS_MESSAGE'] || "All green. #{random_compliment}"
152
+ return ENV["DANGER_SUCCESS_MESSAGE"] || "All green. #{random_compliment}"
153
153
  else
154
154
  message = "#{emoji_mapper.map('warning')} "
155
155
  message += "#{'Error'.danger_pluralize(errors.count)}. " unless errors.empty?
@@ -29,6 +29,7 @@ module Danger
29
29
  tables.each do |table|
30
30
  match = danger_table?(table)
31
31
  next unless match
32
+
32
33
  title = match[1]
33
34
  kind = table_kind_from_title(title)
34
35
  next unless kind
@@ -51,8 +52,8 @@ module Danger
51
52
 
52
53
  private
53
54
 
54
- GITHUB_OLD_REGEX = %r{<th width="100%"(.*?)</th>}im
55
- NEW_REGEX = %r{<th.*data-danger-table="true"(.*?)</th>}im
55
+ GITHUB_OLD_REGEX = %r{<th width="100%"(.*?)</th>}im.freeze
56
+ NEW_REGEX = %r{<th.*data-danger-table="true"(.*?)</th>}im.freeze
56
57
 
57
58
  def danger_table?(table)
58
59
  # The old GitHub specific method relied on
@@ -18,7 +18,7 @@ module Danger
18
18
  TYPE_TO_EMOJI = {
19
19
  error: "no_entry_sign",
20
20
  warning: "warning",
21
- message: "book",
21
+ message: "book"
22
22
  }.freeze
23
23
 
24
24
  def initialize(template)
@@ -18,7 +18,6 @@ module Danger
18
18
  # Since we have a reference to the Dangerfile containing all the information
19
19
  # We need to redirect the self calls to the Dangerfile
20
20
 
21
- # rubocop:disable Style/MethodMissing
22
21
  def method_missing(method_sym, *arguments, **keyword_arguments, &block)
23
22
  if keyword_arguments.empty?
24
23
  @dangerfile.send(method_sym, *arguments, &block)
@@ -146,6 +146,7 @@ module Danger
146
146
  def apply_rules(json, type, rules)
147
147
  rules.each do |rule|
148
148
  next unless rule.function.call(json)
149
+
149
150
  rule.metadata = json
150
151
  rule.type = type
151
152
 
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "danger/helpers/comments_helper"
4
2
  require "danger/request_sources/bitbucket_cloud_api"
5
3
  require "danger/danger_core/message_group"
@@ -104,7 +102,6 @@ module Danger
104
102
  template: "bitbucket_server")
105
103
  summary_body += "\n\n"
106
104
 
107
-
108
105
  # this isn't the most elegant thing in the world, but we need the group
109
106
  # with file: nil, line: nil so we can combine its info in with the
110
107
  # summary_body
@@ -145,8 +142,8 @@ module Danger
145
142
 
146
143
  if kind == :markdown
147
144
  body = generate_inline_markdown_body(message,
148
- danger_id: danger_id,
149
- template: "bitbucket_server")
145
+ danger_id: danger_id,
146
+ template: "bitbucket_server")
150
147
  else
151
148
  body = generate_inline_comment_body(emoji, message,
152
149
  danger_id: danger_id,
@@ -162,6 +159,7 @@ module Danger
162
159
  def delete_old_comments(danger_id: "danger")
163
160
  @api.fetch_comments.each do |c|
164
161
  next if c[:user][:uuid] != @api.my_uuid
162
+
165
163
  @api.delete_comment(c[:id]) if c[:content][:raw] =~ /generated_by_#{danger_id}/
166
164
  end
167
165
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # coding: utf-8
3
2
 
4
3
  require "danger/helpers/comments_helper"
5
4
 
@@ -57,7 +56,7 @@ module Danger
57
56
  def fetch_comments
58
57
  values = []
59
58
  # TODO: use a url parts encoder to encode the query
60
- corrected_uuid = @my_uuid[1...-1] if !@my_uuid.nil? # Endpoint doesnt support curly brackets for this, so remove them for this
59
+ corrected_uuid = @my_uuid[1...-1] unless @my_uuid.nil? # Endpoint doesnt support curly brackets for this, so remove them for this
61
60
  uri = "#{pr_api_endpoint}/comments?pagelen=100&q=deleted+%7E+false+AND+user.uuid+%7E+%22#{corrected_uuid}%22"
62
61
 
63
62
  while uri
@@ -114,7 +113,7 @@ module Danger
114
113
  uri = URI.parse("https://bitbucket.org/site/oauth2/access_token")
115
114
  req = Net::HTTP::Post.new(uri.request_uri, { "Content-Type" => "application/json" })
116
115
  req.basic_auth oauth_key, oauth_secret
117
- req.set_form_data({'grant_type' => 'client_credentials'})
116
+ req.set_form_data({ "grant_type" => "client_credentials" })
118
117
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
119
118
  http.request(req)
120
119
  end
@@ -177,7 +176,6 @@ module Danger
177
176
  def error_fetching_json(url, status_code)
178
177
  "Error fetching json for: #{url}, status code: #{status_code}"
179
178
  end
180
-
181
179
  end
182
180
  end
183
181
  end
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "danger/helpers/comments_helper"
4
2
  require "danger/request_sources/bitbucket_server_api"
5
3
  require "danger/request_sources/code_insights_api"
@@ -32,7 +30,7 @@ module Danger
32
30
 
33
31
  def initialize(ci_source, environment)
34
32
  self.ci_source = ci_source
35
- self.dismiss_out_of_range_messages = environment["DANGER_BITBUCKETSERVER_DISMISS_OUT_OF_RANGE_MESSAGES"] == 'true'
33
+ self.dismiss_out_of_range_messages = environment["DANGER_BITBUCKETSERVER_DISMISS_OUT_OF_RANGE_MESSAGES"] == "true"
36
34
 
37
35
  project, slug = ci_source.repo_slug.split("/")
38
36
  @api = BitbucketServerAPI.new(project, slug, ci_source.pull_request_id, environment)
@@ -164,6 +162,7 @@ module Danger
164
162
  next 1 unless b.file && b.line
165
163
 
166
164
  next a.line <=> b.line if a.file == b.file
165
+
167
166
  next a.file <=> b.file
168
167
  end
169
168
 
@@ -188,26 +187,24 @@ module Danger
188
187
  def find_position_in_diff?(file, line)
189
188
  return nil if file.nil? || line.nil?
190
189
  return nil if file.empty?
190
+
191
191
  added_lines(file).include?(line)
192
192
  end
193
193
 
194
194
  def file_diff(file)
195
- self.pr_diff[:diffs].find{|diff| diff[:destination] && diff[:destination][:toString] == file } || {:hunks => []}
195
+ self.pr_diff[:diffs].find { |diff| diff[:destination] && diff[:destination][:toString] == file } || { hunks: [] }
196
196
  end
197
197
 
198
198
  def added_lines(file)
199
199
  @added_lines ||= {}
200
- @added_lines[file] ||= begin
201
- file_diff(file)[:hunks].map do |hunk|
202
- hunk[:segments].select{|segment| segment[:type] == 'ADDED' }.map do |segment|
203
- segment[:lines].map do |line|
204
- line[:destination]
205
- end
200
+ @added_lines[file] ||= file_diff(file)[:hunks].map do |hunk|
201
+ hunk[:segments].select { |segment| segment[:type] == "ADDED" }.map do |segment|
202
+ segment[:lines].map do |line|
203
+ line[:destination]
206
204
  end
207
- end.flatten
208
- end
205
+ end
206
+ end.flatten
209
207
  end
210
-
211
208
  end
212
209
  end
213
210
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # coding: utf-8
3
2
 
4
3
  require "openssl"
5
4
  require "danger/helpers/comments_helper"
@@ -65,9 +64,9 @@ module Danger
65
64
  end
66
65
 
67
66
  def update_pr_build_status(status, changeset, build_job_link, description)
68
- uri = URI("#{self.host}/rest/build-status/1.0/commits/#{changeset}")
69
- body = build_status_body(status, build_job_link, description)
70
- post(uri, body)
67
+ uri = URI("#{self.host}/rest/build-status/1.0/commits/#{changeset}")
68
+ body = build_status_body(status, build_job_link, description)
69
+ post(uri, body)
71
70
  end
72
71
 
73
72
  private
@@ -118,12 +117,12 @@ module Danger
118
117
  end
119
118
 
120
119
  def build_status_body(status, build_job_link, description)
121
- body = Hash.new
122
- body["state"] = status
123
- body["key"] = self.key
124
- body["url"] = build_job_link
125
- body["description"] = description if description
126
- return body.to_json
120
+ body = {}
121
+ body["state"] = status
122
+ body["key"] = self.key
123
+ body["url"] = build_job_link
124
+ body["description"] = description if description
125
+ return body.to_json
127
126
  end
128
127
  end
129
128
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # coding: utf-8
3
2
 
4
3
  module Danger
5
4
  module RequestSources
@@ -38,7 +37,7 @@ module Danger
38
37
 
39
38
  def delete_report(commit)
40
39
  uri = URI(report_endpoint_at_commit(commit))
41
- request = Net::HTTP::Delete.new(uri.request_uri, {"Content-Type" => "application/json"})
40
+ request = Net::HTTP::Delete.new(uri.request_uri, { "Content-Type" => "application/json" })
42
41
  request.basic_auth @username, @password
43
42
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: use_ssl) do |http|
44
43
  http.request(request)
@@ -50,7 +49,6 @@ module Danger
50
49
  # HTTP 4xx - 5xx
51
50
  abort "\nError deleting report from Code Insights API: #{response.code} (#{response.message}) - #{response.body}\n\n"
52
51
  end
53
-
54
52
  end
55
53
 
56
54
  def send_report(commit, inline_warnings, inline_errors, inline_messages)
@@ -64,15 +62,14 @@ module Danger
64
62
 
65
63
  def put_report(commit, inline_errors_count)
66
64
  uri = URI(report_endpoint_at_commit(commit))
67
- request = Net::HTTP::Put.new(uri.request_uri, {"Content-Type" => "application/json"})
65
+ request = Net::HTTP::Put.new(uri.request_uri, { "Content-Type" => "application/json" })
68
66
  request.basic_auth @username, @password
69
- request.body = {"title": @report_title,
67
+ request.body = { "title": @report_title,
70
68
  "details": @report_description,
71
- "result": (inline_errors_count > 0) ? "FAIL" : "PASS",
69
+ "result": inline_errors_count > 0 ? "FAIL" : "PASS",
72
70
  "reporter": @username,
73
71
  "link": "https://github.com/danger/danger",
74
- "logoURL": @logo_url
75
- }.to_json
72
+ "logoURL": @logo_url }.to_json
76
73
 
77
74
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: use_ssl) do |http|
78
75
  http.request(request)
@@ -103,8 +100,8 @@ module Danger
103
100
  annotations << violation_hash_with_severity(violation, "HIGH")
104
101
  end
105
102
 
106
- body = {annotations: annotations}.to_json
107
- request = Net::HTTP::Post.new(uri.request_uri, {"Content-Type" => "application/json"})
103
+ body = { annotations: annotations }.to_json
104
+ request = Net::HTTP::Post.new(uri.request_uri, { "Content-Type" => "application/json" })
108
105
  request.basic_auth @username, @password
109
106
  request.body = body
110
107
 
@@ -140,7 +137,6 @@ module Danger
140
137
  def use_ssl
141
138
  @host.include? "https://"
142
139
  end
143
-
144
140
  end
145
141
  end
146
142
  end
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  # rubocop:disable Metrics/ClassLength
4
2
 
5
3
  require "octokit"
@@ -65,6 +63,7 @@ module Danger
65
63
 
66
64
  def client
67
65
  raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN` or `DANGER_GITHUB_BEARER_TOKEN`" if !valid_access_token? && !valid_bearer_token? && !support_tokenless_auth
66
+
68
67
  @client ||= begin
69
68
  Octokit.configure do |config|
70
69
  config.connection_options[:ssl] = { verify: verify_ssl }
@@ -83,6 +82,7 @@ module Danger
83
82
 
84
83
  def review
85
84
  return @review unless @review.nil?
85
+
86
86
  begin
87
87
  @review = client.pull_request_reviews(ci_source.repo_slug, ci_source.pull_request_id)
88
88
  .map { |review_json| Danger::RequestSources::GitHubSource::Review.new(client, ci_source, review_json) }
@@ -133,10 +133,8 @@ module Danger
133
133
  end
134
134
 
135
135
  def issue_comments
136
- @comments ||= begin
137
- client.issue_comments(ci_source.repo_slug, ci_source.pull_request_id)
138
- .map { |comment| Comment.from_github(comment) }
139
- end
136
+ @comments ||= client.issue_comments(ci_source.repo_slug, ci_source.pull_request_id)
137
+ .map { |comment| Comment.from_github(comment) }
140
138
  end
141
139
 
142
140
  # Sending data to GitHub
@@ -224,7 +222,7 @@ module Danger
224
222
  context: "danger/#{danger_id}",
225
223
  target_url: details_url
226
224
  })
227
- rescue
225
+ rescue StandardError
228
226
  # This usually means the user has no commit access to this repo
229
227
  # That's always the case for open source projects where you can only
230
228
  # use a read-only GitHub account
@@ -248,6 +246,7 @@ module Danger
248
246
  issue_comments.each do |comment|
249
247
  next unless comment.generated_by_danger?(danger_id)
250
248
  next if comment.id == except
249
+
251
250
  client.delete_comment(ci_source.repo_slug, comment.id)
252
251
  end
253
252
  end
@@ -456,9 +455,9 @@ module Danger
456
455
 
457
456
  # @return [String] The organisation name, is nil if it can't be detected
458
457
  def organisation
459
- matched = self.issue_json["repository_url"].match(%r{repos\/(.*)\/})
458
+ matched = self.issue_json["repository_url"].match(%r{repos/(.*)/})
460
459
  return matched[1] if matched && matched[1]
461
- rescue
460
+ rescue StandardError
462
461
  nil
463
462
  end
464
463
 
@@ -473,17 +472,18 @@ module Danger
473
472
  end
474
473
 
475
474
  # @return [String] A URL to the specific file, ready to be downloaded
476
- def file_url(organisation: nil, repository: nil, branch: nil, path: nil)
475
+ def file_url(organisation: nil, repository: nil, ref: nil, branch: nil, path: nil)
477
476
  organisation ||= self.organisation
477
+ ref ||= branch
478
478
 
479
479
  begin
480
- # Retrieve the download URL (default branch on nil param)
481
- contents = client.contents("#{organisation}/#{repository}", path: path, ref: branch)
480
+ # Retrieve the download URL (default ref on nil param)
481
+ contents = client.contents("#{organisation}/#{repository}", path: path, ref: ref)
482
482
  @download_url = contents["download_url"]
483
483
  rescue Octokit::ClientError
484
484
  # Fallback to github.com
485
- branch ||= "master"
486
- @download_url = "https://raw.githubusercontent.com/#{organisation}/#{repository}/#{branch}/#{path}"
485
+ ref ||= "master"
486
+ @download_url = "https://raw.githubusercontent.com/#{organisation}/#{repository}/#{ref}/#{path}"
487
487
  end
488
488
  end
489
489
 
@@ -512,6 +512,7 @@ module Danger
512
512
  next 1 unless b.file && b.line
513
513
 
514
514
  next a.line <=> b.line if a.file == b.file
515
+
515
516
  next a.file <=> b.file
516
517
  end
517
518
 
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "octokit"
4
2
  require "danger/ci_source/ci_source"
5
3
  require "danger/request_sources/github/github_review_resolver"
@@ -35,16 +33,19 @@ module Danger
35
33
 
36
34
  def id
37
35
  return nil unless self.review_json
36
+
38
37
  self.review_json["id"]
39
38
  end
40
39
 
41
40
  def body
42
41
  return "" unless self.review_json
42
+
43
43
  self.review_json["body"]
44
44
  end
45
45
 
46
46
  def status
47
47
  return STATUS_PENDING if self.review_json.nil?
48
+
48
49
  return self.review_json["state"]
49
50
  end
50
51
 
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require "danger/request_sources/github/github_review"
4
2
 
5
3
  module Danger
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  module Danger
4
2
  module RequestSources
5
3
  module GitHubSource