danger 3.3.0 → 3.3.1

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 (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/danger/ci_source/bitrise.rb +2 -0
  3. data/lib/danger/ci_source/buildkite.rb +2 -0
  4. data/lib/danger/ci_source/circle.rb +1 -0
  5. data/lib/danger/ci_source/drone.rb +2 -0
  6. data/lib/danger/ci_source/gitlab_ci.rb +1 -0
  7. data/lib/danger/ci_source/jenkins.rb +12 -1
  8. data/lib/danger/ci_source/local_git_repo.rb +24 -31
  9. data/lib/danger/ci_source/semaphore.rb +1 -0
  10. data/lib/danger/ci_source/support/merged_pull_request_finder.rb +66 -0
  11. data/lib/danger/ci_source/support/remote_finder.rb +26 -0
  12. data/lib/danger/ci_source/surf.rb +1 -0
  13. data/lib/danger/ci_source/teamcity.rb +2 -0
  14. data/lib/danger/ci_source/travis.rb +1 -0
  15. data/lib/danger/ci_source/xcode_server.rb +1 -0
  16. data/lib/danger/danger_core/environment_manager.rb +2 -2
  17. data/lib/danger/danger_core/executor.rb +12 -5
  18. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +9 -9
  19. data/lib/danger/helpers/comment.rb +1 -1
  20. data/lib/danger/{request_source → request_sources}/bitbucket_cloud.rb +0 -0
  21. data/lib/danger/{request_source → request_sources}/bitbucket_cloud_api.rb +0 -0
  22. data/lib/danger/{request_source → request_sources}/bitbucket_server.rb +0 -0
  23. data/lib/danger/{request_source → request_sources}/bitbucket_server_api.rb +0 -0
  24. data/lib/danger/{request_source → request_sources}/github.rb +25 -26
  25. data/lib/danger/{request_source → request_sources}/gitlab.rb +0 -0
  26. data/lib/danger/{request_source → request_sources}/request_source.rb +0 -0
  27. data/lib/danger/version.rb +1 -1
  28. metadata +25 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e10fb247dbfbbf65bddac255ef51fbde2886ec7
4
- data.tar.gz: 26e8a81ba580a77b844ee956875974dc52605e41
3
+ metadata.gz: 7c097c9080ca08cc97450e41454aea6db1634169
4
+ data.tar.gz: b7c32ddada66f84e92260dd1290e81f8e6619faf
5
5
  SHA512:
6
- metadata.gz: 5af8334759ab6fd99078bdc24b25723f21266fc2a3ef603c66ea0940576f7b2228740aead12e1d6198afce6ce1ce46fb2f074d4b111d615f693bb29bb4eda08a
7
- data.tar.gz: a9248512d06c5c37cbcf45f2d29ebb8ff02f325e8609c540b9eb05629fb0a01ac81fce622a198a7b13fc76fe3f04c1d879312f915a7480f44bf6b91db94c737b
6
+ metadata.gz: a20361f8bfd84a9ee0b4864b5379ea6e2c546d6757f237790c9a1246c0a1236f38173c72e46ba8ff2d239c03c228605f73aa62396d84a7dbe7357d9a9f8897ce
7
+ data.tar.gz: f869abaa8c464b490a475f3d61908e5fbad1e857270639c2fe29dbbbab510b67da2c27c544761c33e889bbff9e90a21362396fe991930fd4c9d30771bf0d9050
@@ -1,4 +1,6 @@
1
1
  # http://devcenter.bitrise.io/docs/available-environment-variables
2
+ require "danger/request_sources/github"
3
+ require "danger/request_sources/gitlab"
2
4
 
3
5
  module Danger
4
6
  # ### CI Setup
@@ -1,5 +1,7 @@
1
1
  # https://buildkite.com/docs/agent/osx
2
2
  # https://buildkite.com/docs/guides/environment-variables
3
+ require "danger/request_sources/github"
4
+ require "danger/request_sources/gitlab"
3
5
 
4
6
  module Danger
5
7
  # ### CI Setup
@@ -1,6 +1,7 @@
1
1
  # https://circleci.com/docs/environment-variables
2
2
  require "uri"
3
3
  require "danger/ci_source/circle_api"
4
+ require "danger/request_sources/github"
4
5
 
5
6
  module Danger
6
7
  # ### CI Setup
@@ -1,4 +1,6 @@
1
1
  # http://readme.drone.io/usage/variables/
2
+ require "danger/request_sources/github"
3
+ require "danger/request_sources/gitlab"
2
4
 
3
5
  module Danger
4
6
  # ### CI Setup
@@ -1,5 +1,6 @@
1
1
  # http://docs.gitlab.com/ce/ci/variables/README.html
2
2
  require "uri"
3
+ require "danger/request_sources/gitlab"
3
4
 
4
5
  module Danger
5
6
  # ### CI Setup
@@ -1,5 +1,9 @@
1
1
  # https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables
2
2
  # https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin
3
+ require "danger/request_sources/github"
4
+ require "danger/request_sources/gitlab"
5
+ require "danger/request_sources/bitbucket_server"
6
+ require "danger/request_sources/bitbucket_cloud"
3
7
 
4
8
  module Danger
5
9
  # https://jenkins-ci.org
@@ -38,7 +42,14 @@ module Danger
38
42
  end
39
43
 
40
44
  def supported_request_sources
41
- @supported_request_sources ||= [Danger::RequestSources::GitHub, Danger::RequestSources::GitLab, Danger::RequestSources::BitbucketServer, Danger::RequestSources::BitbucketCloud]
45
+ @supported_request_sources ||= begin
46
+ [
47
+ Danger::RequestSources::GitHub,
48
+ Danger::RequestSources::GitLab,
49
+ Danger::RequestSources::BitbucketServer,
50
+ Danger::RequestSources::BitbucketCloud
51
+ ]
52
+ end
42
53
  end
43
54
 
44
55
  def initialize(env)
@@ -2,6 +2,9 @@
2
2
 
3
3
  require "git"
4
4
  require "uri"
5
+ require "danger/ci_source/support/remote_finder"
6
+ require "danger/ci_source/support/merged_pull_request_finder"
7
+ require "danger/request_sources/github"
5
8
 
6
9
  module Danger
7
10
  # ignore
@@ -28,39 +31,29 @@ module Danger
28
31
  @supported_request_sources ||= [Danger::RequestSources::GitHub]
29
32
  end
30
33
 
31
- def initialize(env = {})
32
- github_host = env["DANGER_GITHUB_HOST"] || "github.com"
33
-
34
- # get the remote URL
35
- remote = run_git("remote show origin -n").lines.grep(/Fetch URL/)[0].split(": ", 2)[1]
36
- if remote
37
- remote_url_matches = remote.match(%r{#{Regexp.escape github_host}(:|/)(?<repo_slug>.+/.+?)(?:\.git)?$})
38
- if !remote_url_matches.nil? and remote_url_matches["repo_slug"]
39
- self.repo_slug = remote_url_matches["repo_slug"]
40
- else
41
- puts "Danger local requires a repository hosted on GitHub.com or GitHub Enterprise."
42
- end
43
- end
44
-
45
- specific_pr = env["LOCAL_GIT_PR_ID"]
46
- pr_ref = specific_pr ? "##{specific_pr}" : ""
47
- pr_command = "log --merges --oneline"
34
+ def print_repo_slug_warning
35
+ puts "Danger local requires a repository hosted on GitHub.com or GitHub Enterprise.".freeze
36
+ end
48
37
 
49
- # get the most recent PR merge
50
- pr_merge = run_git(pr_command.strip).lines.grep(Regexp.new("Merge pull request " + pr_ref))[0]
38
+ def parents(sha)
39
+ @parents ||= run_git("rev-list --parents -n 1 #{sha}").strip.split(" ".freeze)
40
+ end
51
41
 
52
- if pr_merge.to_s.empty?
53
- if specific_pr
54
- raise "Could not find the pull request (#{specific_pr}) inside the git history for this repo."
55
- else
56
- raise "No recent pull requests found for this repo, danger requires at least one PR for the local mode."
57
- end
58
- end
59
- self.pull_request_id = pr_merge.match("#([0-9]+)")[1]
60
- sha = pr_merge.split(" ")[0]
61
- parents = run_git("rev-list --parents -n 1 #{sha}").strip.split(" ")
62
- self.base_commit = parents[0]
63
- self.head_commit = parents[1]
42
+ def initialize(env = {})
43
+ repo_slug = RemoteFinder.new(
44
+ env["DANGER_GITHUB_HOST"] || "github.com".freeze,
45
+ run_git("remote show origin -n".freeze)
46
+ ).call
47
+
48
+ pull_request_id, sha = MergedPullRequestFinder.new(
49
+ env["LOCAL_GIT_PR_ID"] || "",
50
+ run_git("log --oneline -50".freeze)
51
+ ).call
52
+
53
+ self.repo_slug = repo_slug ? repo_slug : print_repo_slug_warning
54
+ self.pull_request_id = pull_request_id
55
+ self.base_commit = parents(sha)[0]
56
+ self.head_commit = parents(sha)[1]
64
57
  end
65
58
  end
66
59
  end
@@ -1,4 +1,5 @@
1
1
  # https://semaphoreci.com/docs/available-environment-variables.html
2
+ require "danger/request_sources/github"
2
3
 
3
4
  module Danger
4
5
  # ### CI Setup
@@ -0,0 +1,66 @@
1
+ module Danger
2
+ class MergedPullRequestFinder
3
+ def initialize(specific_pull_request_id, git_logs)
4
+ @specific_pull_request_id = specific_pull_request_id
5
+ @git_logs = git_logs
6
+ end
7
+
8
+ def call
9
+ check_if_any_merged_pull_request!
10
+
11
+ [merged_pull_request_id, merged_pull_request_sha]
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :specific_pull_request_id, :git_logs
17
+
18
+ # @return [String] "#42"
19
+ def pull_request_ref
20
+ specific_pull_request_id ? "##{specific_pull_request_id}" : "".freeze
21
+ end
22
+
23
+ # @return [String] Log line of format: "Merge pull request #42"
24
+ def most_recent_merged_pull_request
25
+ @most_recent_merged_pull_request ||= begin
26
+ git_logs.lines.grep(/Merge pull request #{pull_request_ref}/)[0]
27
+ end
28
+ end
29
+
30
+ # @return [String] Log line of format: "description (#42)"
31
+ def most_recent_squash_and_merged_pull_request
32
+ @most_recent_squash_and_merged_pull_request ||= begin
33
+ git_logs.lines.grep(/#{pull_request_ref}/)[0]
34
+ end
35
+ end
36
+
37
+ # @return [String] Log line of most recent merged Pull Request
38
+ def merged_pull_request
39
+ return if pull_request_ref.empty?
40
+
41
+ if most_recent_merged_pull_request
42
+ most_recent_merged_pull_request
43
+ elsif most_recent_squash_and_merged_pull_request
44
+ most_recent_squash_and_merged_pull_request
45
+ end
46
+ end
47
+
48
+ def check_if_any_merged_pull_request!
49
+ if merged_pull_request.to_s.empty?
50
+ if specific_pull_request_id
51
+ raise "Could not find the Pull Request (#{specific_pull_request_id}) inside the git history for this repo."
52
+ else
53
+ raise "No recent Pull Requests found for this repo, danger requires at least one Pull Request for the local mode.".freeze
54
+ end
55
+ end
56
+ end
57
+
58
+ def merged_pull_request_id
59
+ merged_pull_request.match(/#(?<id>[0-9]+)/)[:id]
60
+ end
61
+
62
+ def merged_pull_request_sha
63
+ merged_pull_request.split(" ".freeze).first
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,26 @@
1
+ module Danger
2
+ class RemoteFinder
3
+ def initialize(github_host, remote_logs)
4
+ @github_host = github_host
5
+ @remote_logs = remote_logs
6
+ end
7
+
8
+ def call
9
+ remote_url_matches && remote_url_matches["repo_slug"]
10
+ end
11
+
12
+ private
13
+
14
+ attr_reader :remote_logs, :github_host
15
+
16
+ # @return [String] The remote URL
17
+ def remote
18
+ @remote ||= remote_logs.lines.grep(/Fetch URL/)[0].split(": ".freeze, 2)[1]
19
+ end
20
+
21
+ # @return [nil / MatchData] MatchData object or nil if not matched
22
+ def remote_url_matches
23
+ remote.match(%r{#{Regexp.escape github_host}(:|/)(?<repo_slug>.+/.+?)(?:\.git)?$})
24
+ end
25
+ end
26
+ end
@@ -1,4 +1,5 @@
1
1
  # http://github.com/surf-build/surf
2
+ require "danger/request_sources/github"
2
3
 
3
4
  module Danger
4
5
  # ### CI Setup
@@ -1,4 +1,6 @@
1
1
  # https://www.jetbrains.com/teamcity/
2
+ require "danger/request_sources/github"
3
+ require "danger/request_sources/gitlab"
2
4
 
3
5
  module Danger
4
6
  # ### CI Setup
@@ -1,5 +1,6 @@
1
1
  # http://docs.travis-ci.com/user/osx-ci-environment/
2
2
  # http://docs.travis-ci.com/user/environment-variables/
3
+ require "danger/request_sources/github"
3
4
 
4
5
  module Danger
5
6
  # ### CI Setup
@@ -1,5 +1,6 @@
1
1
  # Following the advice from @czechboy0 https://github.com/danger/danger/issues/171
2
2
  # https://github.com/czechboy0/Buildasaur
3
+ require "danger/request_sources/github"
3
4
 
4
5
  module Danger
5
6
  # ### CI Setup
@@ -1,5 +1,5 @@
1
1
  require "danger/ci_source/ci_source"
2
- require "danger/request_source/request_source"
2
+ require "danger/request_sources/request_source"
3
3
 
4
4
  module Danger
5
5
  class EnvironmentManager
@@ -28,7 +28,7 @@ module Danger
28
28
  self.request_source = request_source
29
29
  end
30
30
 
31
- raise "Could not find a Request Source for #{ci_klass}".red unless self.request_source
31
+ raise "Could not find a Request Source for #{ci_klass}\nCI: #{ci_source.inspect}".red unless self.request_source
32
32
  self.scm = self.request_source.scm
33
33
  end
34
34
 
@@ -40,6 +40,7 @@ module Danger
40
40
  # Offer the chance for a user to specify a branch through the command line
41
41
  ci_base = base || EnvironmentManager.danger_base_branch
42
42
  ci_head = head || EnvironmentManager.danger_head_branch
43
+
43
44
  dm.env.scm.diff_for_folder(".", from: ci_base, to: ci_head)
44
45
 
45
46
  # Parse the local Dangerfile
@@ -52,12 +53,18 @@ module Danger
52
53
  end
53
54
  end
54
55
 
55
- def post_results(dm, danger_id)
56
- gh = dm.env.request_source
57
- violations = dm.violation_report
58
- status = dm.status_report
56
+ def post_results(danger_file, danger_id)
57
+ request_source = danger_file.env.request_source
58
+ violations = danger_file.violation_report
59
+ status = danger_file.status_report
59
60
 
60
- gh.update_pull_request!(warnings: violations[:warnings], errors: violations[:errors], messages: violations[:messages], markdowns: status[:markdowns], danger_id: danger_id)
61
+ request_source.update_pull_request!(
62
+ warnings: violations[:warnings],
63
+ errors: violations[:errors],
64
+ messages: violations[:messages],
65
+ markdowns: status[:markdowns],
66
+ danger_id: danger_id
67
+ )
61
68
  end
62
69
  end
63
70
  end
@@ -97,7 +97,7 @@ module Danger
97
97
  # @return [String]
98
98
  #
99
99
  def pr_title
100
- @github.pr_json[:title].to_s
100
+ @github.pr_json["title"].to_s
101
101
  end
102
102
 
103
103
  # @!group PR Metadata
@@ -105,7 +105,7 @@ module Danger
105
105
  # @return [String]
106
106
  #
107
107
  def pr_body
108
- pr_json[:body].to_s
108
+ pr_json["body"].to_s
109
109
  end
110
110
 
111
111
  # @!group PR Metadata
@@ -113,7 +113,7 @@ module Danger
113
113
  # @return [String]
114
114
  #
115
115
  def pr_author
116
- pr_json[:user][:login].to_s
116
+ pr_json["user"]["login"].to_s
117
117
  end
118
118
 
119
119
  # @!group PR Metadata
@@ -121,7 +121,7 @@ module Danger
121
121
  # @return [String]
122
122
  #
123
123
  def pr_labels
124
- @github.issue_json[:labels].map { |l| l[:name] }
124
+ @github.issue_json["labels"].map { |l| l[:name] }
125
125
  end
126
126
 
127
127
  # @!group PR Commit Metadata
@@ -129,7 +129,7 @@ module Danger
129
129
  # @return [String]
130
130
  #
131
131
  def branch_for_base
132
- pr_json[:base][:ref]
132
+ pr_json["base"]["ref"]
133
133
  end
134
134
 
135
135
  # @!group PR Commit Metadata
@@ -137,7 +137,7 @@ module Danger
137
137
  # @return [String]
138
138
  #
139
139
  def branch_for_head
140
- pr_json[:head][:ref]
140
+ pr_json["head"]["ref"]
141
141
  end
142
142
 
143
143
  # @!group PR Commit Metadata
@@ -145,7 +145,7 @@ module Danger
145
145
  # @return [String]
146
146
  #
147
147
  def base_commit
148
- pr_json[:base][:sha]
148
+ pr_json["base"]["sha"]
149
149
  end
150
150
 
151
151
  # @!group PR Commit Metadata
@@ -153,7 +153,7 @@ module Danger
153
153
  # @return [String]
154
154
  #
155
155
  def head_commit
156
- pr_json[:head][:sha]
156
+ pr_json["head"]["sha"]
157
157
  end
158
158
 
159
159
  # @!group GitHub Misc
@@ -193,7 +193,7 @@ module Danger
193
193
  def html_link(paths, full_path: true)
194
194
  paths = [paths] unless paths.kind_of?(Array)
195
195
  commit = head_commit
196
- repo = pr_json[:head][:repo][:html_url]
196
+ repo = pr_json["head"]["repo"]["html_url"]
197
197
 
198
198
  paths = paths.map do |path|
199
199
  url_path = path.start_with?("/") ? path : "/#{path}"
@@ -8,7 +8,7 @@ module Danger
8
8
  end
9
9
 
10
10
  def self.from_github(comment)
11
- self.new(comment[:id], comment[:body])
11
+ self.new(comment["id"], comment["body"])
12
12
  end
13
13
 
14
14
  def self.from_gitlab(comment)
@@ -52,8 +52,8 @@ module Danger
52
52
 
53
53
  def setup_danger_branches
54
54
  # we can use a github specific feature here:
55
- base_commit = self.pr_json[:base][:sha]
56
- head_commit = self.pr_json[:head][:sha]
55
+ base_commit = self.pr_json["base"]["sha"]
56
+ head_commit = self.pr_json["head"]["sha"]
57
57
 
58
58
  # Next, we want to ensure that we have a version of the current branch at a known location
59
59
  self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
@@ -65,7 +65,7 @@ module Danger
65
65
 
66
66
  def fetch_details
67
67
  self.pr_json = client.pull_request(ci_source.repo_slug, ci_source.pull_request_id)
68
- if self.pr_json[:message] == "Moved Permanently"
68
+ if self.pr_json["message"] == "Moved Permanently"
69
69
  raise "Repo moved or renamed, make sure to update the git remote".red
70
70
  end
71
71
 
@@ -74,13 +74,13 @@ module Danger
74
74
  end
75
75
 
76
76
  def ignored_violations_from_pr(pr_json)
77
- pr_body = pr_json[:body]
77
+ pr_body = pr_json["body"]
78
78
  return [] if pr_body.nil?
79
79
  pr_body.chomp.scan(/>\s*danger\s*:\s*ignore\s*"(.*)"/i).flatten
80
80
  end
81
81
 
82
82
  def fetch_issue_details(pr_json)
83
- href = pr_json[:_links][:issue][:href]
83
+ href = pr_json["_links"]["issue"]["href"]
84
84
  self.issue_json = client.get(href)
85
85
  end
86
86
 
@@ -151,14 +151,13 @@ module Danger
151
151
  # Note: this can terminate the entire process.
152
152
  submit_pull_request_status!(warnings: warnings,
153
153
  errors: errors,
154
- details_url: comment_result[:html_url])
154
+ details_url: comment_result["html_url"])
155
155
  end
156
156
 
157
157
  def submit_pull_request_status!(warnings: [], errors: [], details_url: [])
158
158
  status = (errors.count.zero? ? "success" : "failure")
159
159
  message = generate_description(warnings: warnings, errors: errors)
160
-
161
- latest_pr_commit_ref = self.pr_json[:head][:sha]
160
+ latest_pr_commit_ref = self.pr_json["head"]["sha"]
162
161
 
163
162
  if latest_pr_commit_ref.empty? || latest_pr_commit_ref.nil?
164
163
  raise "Couldn't find a commit to update its status".red
@@ -176,7 +175,7 @@ module Danger
176
175
  # use a read-only GitHub account
177
176
  if errors.count > 0
178
177
  # We need to fail the actual build here
179
- is_private = pr_json[:base][:repo][:private]
178
+ is_private = pr_json["base"]["repo"]["private"]
180
179
  if is_private
181
180
  abort("\nDanger has failed this build. \nFound #{'error'.danger_pluralize(errors.count)} and I don't have write access to the PR to set a PR status.")
182
181
  else
@@ -203,32 +202,32 @@ module Danger
203
202
 
204
203
  diff_lines = self.pr_diff.lines
205
204
  pr_comments = client.pull_request_comments(ci_source.repo_slug, ci_source.pull_request_id)
206
- danger_comments = pr_comments.select { |comment| comment[:body].include?("generated_by_#{danger_id}") }
205
+ danger_comments = pr_comments.select { |comment| comment["body"].include?("generated_by_#{danger_id}") }
207
206
  non_danger_comments = pr_comments - danger_comments
208
207
 
209
- submit_inline_comments_for_kind!("warning", warnings, diff_lines, danger_comments, previous_violations[:warning], danger_id: danger_id)
210
- submit_inline_comments_for_kind!("no_entry_sign", errors, diff_lines, danger_comments, previous_violations[:error], danger_id: danger_id)
211
- submit_inline_comments_for_kind!("book", messages, diff_lines, danger_comments, previous_violations[:message], danger_id: danger_id)
208
+ submit_inline_comments_for_kind!("warning", warnings, diff_lines, danger_comments, previous_violations["warning"], danger_id: danger_id)
209
+ submit_inline_comments_for_kind!("no_entry_sign", errors, diff_lines, danger_comments, previous_violations["error"], danger_id: danger_id)
210
+ submit_inline_comments_for_kind!("book", messages, diff_lines, danger_comments, previous_violations["message"], danger_id: danger_id)
212
211
  submit_inline_comments_for_kind!(nil, markdowns, diff_lines, danger_comments, [], danger_id: danger_id)
213
212
 
214
213
  # submit removes from the array all comments that are still in force
215
214
  # so we strike out all remaining ones
216
215
  danger_comments.each do |comment|
217
- violation = violations_from_table(comment[:body]).first
216
+ violation = violations_from_table(comment["body"]).first
218
217
  if !violation.nil? && violation.sticky
219
218
  body = generate_inline_comment_body("white_check_mark", violation, danger_id: danger_id, resolved: true, template: "github")
220
- client.update_pull_request_comment(ci_source.repo_slug, comment[:id], body)
219
+ client.update_pull_request_comment(ci_source.repo_slug, comment["id"], body)
221
220
  else
222
221
  # We remove non-sticky violations that have no replies
223
222
  # Since there's no direct concept of a reply in GH, we simply consider
224
223
  # the existance of non-danger comments in that line as replies
225
224
  replies = non_danger_comments.select do |potential|
226
- potential[:path] == comment[:path] &&
227
- potential[:position] == comment[:position] &&
228
- potential[:commit_id] == comment[:commit_id]
225
+ potential["path"] == comment["path"] &&
226
+ potential["position"] == comment["position"] &&
227
+ potential["commit_id"] == comment["commit_id"]
229
228
  end
230
229
 
231
- client.delete_pull_request_comment(ci_source.repo_slug, comment[:id]) if replies.empty?
230
+ client.delete_pull_request_comment(ci_source.repo_slug, comment["id"]) if replies.empty?
232
231
  end
233
232
  end
234
233
  end
@@ -240,7 +239,7 @@ module Danger
240
239
  end
241
240
 
242
241
  def submit_inline_comments_for_kind!(emoji, messages, diff_lines, danger_comments, previous_violations, danger_id: "danger")
243
- head_ref = pr_json[:head][:sha]
242
+ head_ref = pr_json["head"]["sha"]
244
243
  previous_violations ||= []
245
244
  is_markdown_content = emoji.nil?
246
245
 
@@ -265,13 +264,13 @@ module Danger
265
264
  end
266
265
 
267
266
  matching_comments = danger_comments.select do |comment_data|
268
- if comment_data[:path] == m.file && comment_data[:commit_id] == head_ref && comment_data[:position] == position
267
+ if comment_data["path"] == m.file && comment_data["commit_id"] == head_ref && comment_data["position"] == position
269
268
  # Parse it to avoid problems with strikethrough
270
- violation = violations_from_table(comment_data[:body]).first
269
+ violation = violations_from_table(comment_data["body"]).first
271
270
  if violation
272
271
  messages_are_equivalent(violation, m)
273
272
  else
274
- comment_data[:body] == body
273
+ comment_data["body"] == body
275
274
  end
276
275
  else
277
276
  false
@@ -287,7 +286,7 @@ module Danger
287
286
 
288
287
  # Update the comment to remove the strikethrough if present
289
288
  comment = matching_comments.first
290
- client.update_pull_request_comment(ci_source.repo_slug, comment[:id], body)
289
+ client.update_pull_request_comment(ci_source.repo_slug, comment["id"], body)
291
290
  end
292
291
 
293
292
  # Remove this element from the array
@@ -360,7 +359,7 @@ module Danger
360
359
  end
361
360
 
362
361
  def markdown_link_to_message(message, hide_link)
363
- url = "https://github.com/#{ci_source.repo_slug}/blob/#{pr_json[:head][:sha]}/#{message.file}#L#{message.line}"
362
+ url = "https://github.com/#{ci_source.repo_slug}/blob/#{pr_json['head']['sha']}/#{message.file}#L#{message.line}"
364
363
 
365
364
  if hide_link
366
365
  "<span data-href=\"#{url}\"/>"
@@ -371,7 +370,7 @@ module Danger
371
370
 
372
371
  # @return [String] The organisation name, is nil if it can't be detected
373
372
  def organisation
374
- matched = self.issue_json[:repository_url].match(%r{repos\/(.*)\/})
373
+ matched = self.issue_json["repository_url"].match(%r{repos\/(.*)\/})
375
374
  return matched[1] if matched && matched[1]
376
375
  rescue
377
376
  nil
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "3.3.0".freeze
2
+ VERSION = "3.3.1".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.3.0
4
+ version: 3.3.1
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-16 00:00:00.000000000 Z
12
+ date: 2016-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -249,6 +249,20 @@ dependencies:
249
249
  - - "~>"
250
250
  - !ruby/object:Gem::Version
251
251
  version: '0.10'
252
+ - !ruby/object:Gem::Dependency
253
+ name: pry-byebug
254
+ requirement: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ version: '0'
259
+ type: :development
260
+ prerelease: false
261
+ version_requirements: !ruby/object:Gem::Requirement
262
+ requirements:
263
+ - - ">="
264
+ - !ruby/object:Gem::Version
265
+ version: '0'
252
266
  - !ruby/object:Gem::Dependency
253
267
  name: rubocop
254
268
  requirement: !ruby/object:Gem::Requirement
@@ -372,6 +386,8 @@ files:
372
386
  - lib/danger/ci_source/jenkins.rb
373
387
  - lib/danger/ci_source/local_git_repo.rb
374
388
  - lib/danger/ci_source/semaphore.rb
389
+ - lib/danger/ci_source/support/merged_pull_request_finder.rb
390
+ - lib/danger/ci_source/support/remote_finder.rb
375
391
  - lib/danger/ci_source/surf.rb
376
392
  - lib/danger/ci_source/teamcity.rb
377
393
  - lib/danger/ci_source/travis.rb
@@ -414,13 +430,13 @@ files:
414
430
  - lib/danger/plugin_support/plugin_linter.rb
415
431
  - lib/danger/plugin_support/plugin_parser.rb
416
432
  - lib/danger/plugin_support/templates/readme_table.html.erb
417
- - lib/danger/request_source/bitbucket_cloud.rb
418
- - lib/danger/request_source/bitbucket_cloud_api.rb
419
- - lib/danger/request_source/bitbucket_server.rb
420
- - lib/danger/request_source/bitbucket_server_api.rb
421
- - lib/danger/request_source/github.rb
422
- - lib/danger/request_source/gitlab.rb
423
- - lib/danger/request_source/request_source.rb
433
+ - lib/danger/request_sources/bitbucket_cloud.rb
434
+ - lib/danger/request_sources/bitbucket_cloud_api.rb
435
+ - lib/danger/request_sources/bitbucket_server.rb
436
+ - lib/danger/request_sources/bitbucket_server_api.rb
437
+ - lib/danger/request_sources/github.rb
438
+ - lib/danger/request_sources/gitlab.rb
439
+ - lib/danger/request_sources/request_source.rb
424
440
  - lib/danger/scm_source/git_repo.rb
425
441
  - lib/danger/version.rb
426
442
  homepage: https://github.com/danger/danger