danger 5.3.2 → 5.3.3
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 +4 -4
- data/README.md +2 -8
- data/lib/danger/ci_source/teamcity.rb +10 -1
- data/lib/danger/commands/init.rb +4 -4
- data/lib/danger/request_sources/github/github.rb +11 -3
- data/lib/danger/request_sources/github/github_review.rb +1 -2
- data/lib/danger/version.rb +1 -1
- metadata +4 -5
- data/lib/danger/request_sources/github/octokit_pr_review.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c4f4e43ea259c3203e6be2c3990d24e64b1eb87
|
4
|
+
data.tar.gz: 8a78dfd71a3b65200988fe21e7fab9ee2a6da163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611c401f519dec25f89a8ea35cb5b21cb48c618690c8595b2788b91b00e1b2c8d5585a191a2cc2551a8c43992116af841767b009c590963926fb4b2edc930fcf
|
7
|
+
data.tar.gz: 4b8e80af258bd44d48f1cfed63559a0405d1fdda0d0ad5d35eb6e73fe1e46c77d5dee0be3c887276dad1cab498e1660f48a01906800ea6f56299d3822be9611f
|
data/README.md
CHANGED
@@ -10,8 +10,9 @@ Formalize your Pull Request etiquette.
|
|
10
10
|
|
11
11
|
<p align="center">
|
12
12
|
<a href="#what-is-danger">What is Danger?</a> •
|
13
|
+
<a href="VISION.md">Vision</a> •
|
13
14
|
<a href="#im-here-to-help-out">Helping Out</a> •
|
14
|
-
<a href="
|
15
|
+
<a href="http://danger.systems/guides/creating_your_first_plugin.html">Plugin Development</a>
|
15
16
|
</p>
|
16
17
|
|
17
18
|
-------
|
@@ -45,8 +46,6 @@ We keep all of the end-user documentation at [http://danger.systems](http://dang
|
|
45
46
|
|
46
47
|
Some quick links: [Guides Index](http://danger.systems/guides.html), [DSL Reference](http://danger.systems/reference.html), [Getting Started](http://danger.systems/guides/getting_started.html) and [What does Danger Do?](http://danger.systems/guides/what_does_danger_do.html).
|
47
48
|
|
48
|
-
Sidenote: There is a [pure JS version](https://github.com/danger/danger-js) in the works, it's at the point where it can fail your build but that's about it for now, would love help there if it interests you.
|
49
|
-
|
50
49
|
## I'm here to help out!
|
51
50
|
|
52
51
|
Brilliant. So, let's get you set up.
|
@@ -83,11 +82,6 @@ require 'pry'
|
|
83
82
|
binding.pry
|
84
83
|
```
|
85
84
|
|
86
|
-
## Tell me of these Plugins
|
87
|
-
|
88
|
-
* Follow the [Creating your first plugin](http://danger.systems/guides/creating_your_first_plugin.html) guide
|
89
|
-
* (Talk through the tech specs here.)
|
90
|
-
|
91
85
|
## License, Contributor's Guidelines and Code of Conduct
|
92
86
|
|
93
87
|
We try to keep as much discussion as possible in GitHub issues, but also have a pretty inactive Slack --- if you'd like an invite, ping [@Orta](https://twitter.com/orta/) a DM on Twitter with your email. It's mostly interesting if you want to stay on top of Danger without all the emails from GitHub.
|
@@ -17,7 +17,16 @@ module Danger
|
|
17
17
|
# is to pass in the token as a prefix to the command `DANGER_GITHUB_API_TOKEN="123" bundle exec danger`.
|
18
18
|
#
|
19
19
|
# However, you will need to find a way to add the environment vars: `GITHUB_REPO_SLUG`, `GITHUB_PULL_REQUEST_ID` and
|
20
|
-
# `GITHUB_REPO_URL`. These are not added by default. You
|
20
|
+
# `GITHUB_REPO_URL`. These are not added by default. You can manually add `GITHUB_REPO_SLUG` and `GITHUB_REPO_URL`
|
21
|
+
# as build parameters or by exporting them inside your Simple Command Runner.
|
22
|
+
#
|
23
|
+
# As for `GITHUB_PULL_REQUEST_ID`, TeamCity provides the `%teamcity.build.branch%` variable which is in the format
|
24
|
+
# `PR_NUMBER/merge`. You can slice the Pull Request ID out by doing the following:
|
25
|
+
#
|
26
|
+
# ```sh
|
27
|
+
# branch="%teamcity.build.branch%"
|
28
|
+
# export GITHUB_PULL_REQUEST_ID=(${branch//\// })
|
29
|
+
# ```
|
21
30
|
#
|
22
31
|
# #### GitLab
|
23
32
|
#
|
data/lib/danger/commands/init.rb
CHANGED
@@ -182,7 +182,7 @@ module Danger
|
|
182
182
|
|
183
183
|
def uses_travis
|
184
184
|
danger = "bundle exec danger".yellow
|
185
|
-
config = YAML.load(File.read(".travis.yml"))
|
185
|
+
config = YAML.load(File.read(".travis.yml"))
|
186
186
|
if config.kind_of?(Hash) && config["script"]
|
187
187
|
ui.say "Add " + "- ".yellow + danger + " as a new step in the " + "script".yellow + " section of your .travis.yml file."
|
188
188
|
else
|
@@ -195,7 +195,7 @@ module Danger
|
|
195
195
|
|
196
196
|
def uses_circle
|
197
197
|
danger = "- bundle exec danger".yellow
|
198
|
-
config = YAML.load(File.read("circle.yml"))
|
198
|
+
config = YAML.load(File.read("circle.yml"))
|
199
199
|
|
200
200
|
if config.kind_of?(Hash) && config["test"]
|
201
201
|
if config["test"]["post"]
|
@@ -248,11 +248,11 @@ module Danger
|
|
248
248
|
|
249
249
|
ui.say "In order to expose an environment variable, go to:"
|
250
250
|
ui.link "https://circleci.com/gh/#{current_repo_slug}/edit#env-vars"
|
251
|
-
ui.say "The name is " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal
|
251
|
+
ui.say "The name is " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal Access Token."
|
252
252
|
end
|
253
253
|
|
254
254
|
def unsure_token
|
255
|
-
ui.say "You need to expose a token called " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal
|
255
|
+
ui.say "You need to expose a token called " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal Access Token."
|
256
256
|
ui.say "Depending on the CI system, this may need to be done on the machine (in the " + "~/.bashprofile".yellow + ") or in a web UI somewhere."
|
257
257
|
ui.say "We have a guide for all supported CI systems on danger.systems:"
|
258
258
|
ui.link "http://danger.systems/guides/getting_started.html#setting-up-danger-to-run-on-your-ci"
|
@@ -7,7 +7,6 @@ require "danger/helpers/comments_helper"
|
|
7
7
|
require "danger/helpers/comment"
|
8
8
|
require "danger/request_sources/github/github_review"
|
9
9
|
require "danger/request_sources/github/github_review_unsupported"
|
10
|
-
require "danger/request_sources/github/octokit_pr_review"
|
11
10
|
require "danger/request_sources/support/get_ignored_violation"
|
12
11
|
|
13
12
|
module Danger
|
@@ -329,8 +328,17 @@ module Danger
|
|
329
328
|
end
|
330
329
|
|
331
330
|
if matching_comments.empty?
|
332
|
-
|
333
|
-
|
331
|
+
begin
|
332
|
+
client.create_pull_request_comment(ci_source.repo_slug, ci_source.pull_request_id,
|
333
|
+
body, head_ref, m.file, position)
|
334
|
+
rescue Octokit::UnprocessableEntity => e
|
335
|
+
# Show more detail for UnprocessableEntity error
|
336
|
+
message = [e, "body: #{body}", "head_ref: #{head_ref}", "filename: #{m.file}", "position: #{position}"].join("\n")
|
337
|
+
puts message
|
338
|
+
|
339
|
+
# Not reject because this comment has not completed
|
340
|
+
next false
|
341
|
+
end
|
334
342
|
else
|
335
343
|
# Remove the surviving comment so we don't strike it out
|
336
344
|
danger_comments.reject! { |c| matching_comments.include? c }
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require "octokit"
|
4
4
|
require "danger/ci_source/ci_source"
|
5
|
-
require "danger/request_sources/github/octokit_pr_review"
|
6
5
|
require "danger/request_sources/github/github_review_resolver"
|
7
6
|
require "danger/danger_core/messages/violation"
|
8
7
|
require "danger/danger_core/messages/markdown"
|
@@ -65,7 +64,7 @@ module Danger
|
|
65
64
|
# If the review resolver says that there is nothing to submit we skip submission
|
66
65
|
return unless ReviewResolver.should_submit?(self, submission_body)
|
67
66
|
|
68
|
-
@review_json = @client.create_pull_request_review(@ci_source.repo_slug, @ci_source.pull_request_id, generate_event(general_violations), submission_body)
|
67
|
+
@review_json = @client.create_pull_request_review(@ci_source.repo_slug, @ci_source.pull_request_id, event: generate_event(general_violations), body: submission_body)
|
69
68
|
end
|
70
69
|
|
71
70
|
def generated_by_danger?(danger_id = "danger")
|
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: 5.3.
|
4
|
+
version: 5.3.3
|
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: 2017-
|
12
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|
@@ -101,14 +101,14 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '4.
|
104
|
+
version: '4.7'
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '4.
|
111
|
+
version: '4.7'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: kramdown
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -442,7 +442,6 @@ files:
|
|
442
442
|
- lib/danger/request_sources/github/github_review.rb
|
443
443
|
- lib/danger/request_sources/github/github_review_resolver.rb
|
444
444
|
- lib/danger/request_sources/github/github_review_unsupported.rb
|
445
|
-
- lib/danger/request_sources/github/octokit_pr_review.rb
|
446
445
|
- lib/danger/request_sources/gitlab.rb
|
447
446
|
- lib/danger/request_sources/request_source.rb
|
448
447
|
- lib/danger/request_sources/support/get_ignored_violation.rb
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require "octokit"
|
4
|
-
|
5
|
-
module Octokit
|
6
|
-
class Client
|
7
|
-
# The Pull Request Review API is currently available for developers to preview.
|
8
|
-
# During the preview period, the API may change without advance notice.
|
9
|
-
# please see the blog post for full details.
|
10
|
-
# To access the API during the preview period, you must provide
|
11
|
-
# a custom media type in the Accept header:
|
12
|
-
CUSTOM_ACCEPT_HEADER = "application/vnd.github.black-cat-preview+json".freeze
|
13
|
-
|
14
|
-
# Approve pull request event
|
15
|
-
PULL_REQUEST_REVIEW_EVENT_APPROVE = "APPROVE".freeze
|
16
|
-
|
17
|
-
# Request changes on the pull request event
|
18
|
-
PULL_REQUEST_REVIEW_EVENT_REQUEST_CHANGES = "REQUEST_CHANGES".freeze
|
19
|
-
|
20
|
-
# Left a gemeneral comment on the pull request event
|
21
|
-
PULL_REQUEST_REVIEW_EVENT_COMMENT = "COMMENT".freeze
|
22
|
-
|
23
|
-
# List pull request reviews for a pull request
|
24
|
-
#
|
25
|
-
# @see https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request
|
26
|
-
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
27
|
-
# @param pull_request_number [Integer] Number of the pull request to fetch reviews for
|
28
|
-
# @return [Array<Sawyer::Resource>] Array of reviews
|
29
|
-
# @example
|
30
|
-
# Octokit.pull_request_reviews('rails/rails', :state => 'closed')
|
31
|
-
def pull_request_reviews(repo, pull_request_number, options = {})
|
32
|
-
accept = {
|
33
|
-
accept: CUSTOM_ACCEPT_HEADER
|
34
|
-
}
|
35
|
-
paginate "#{Repository.path repo}/pulls/#{pull_request_number}/reviews", options.merge(accept)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Create a pull request review
|
39
|
-
#
|
40
|
-
# @see https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
|
41
|
-
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
42
|
-
# @param pull_request_number [Integer] Number of the pull request to create review for
|
43
|
-
# @param event [String] The review action (event) to perform. Can be one of
|
44
|
-
# PULL_REQUEST_REVIEW_EVENT_APPROVE
|
45
|
-
# PULL_REQUEST_REVIEW_EVENT_REQUEST_CHANGES
|
46
|
-
# PULL_REQUEST_REVIEW_EVENT_COMMENT
|
47
|
-
# @param body [String] The body for the pull request review (optional). Supports GFM.
|
48
|
-
# @return [Sawyer::Resource] The newly created pull request
|
49
|
-
# @example
|
50
|
-
# @client.create_pull_request_review("octokit/octokit.rb", "APPROVE", "Thanks for your contribution")
|
51
|
-
def create_pull_request_review(repo, pull_request_number, event, body = nil, options = {})
|
52
|
-
review = {
|
53
|
-
event: event,
|
54
|
-
accept: CUSTOM_ACCEPT_HEADER
|
55
|
-
}
|
56
|
-
review[:body] = body unless body.nil?
|
57
|
-
post "#{Repository.path repo}/pulls/#{pull_request_number}/reviews", options.merge(review)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Submit a pull request review
|
61
|
-
#
|
62
|
-
# @see https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
|
63
|
-
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
64
|
-
# @param pull_request_number [Integer] Number of the pull request to create review for
|
65
|
-
# @param review_id [Integer] ID of the pull request review to submit
|
66
|
-
# @param event [String] The review action (event) to perform. Can be one of
|
67
|
-
# PULL_REQUEST_REVIEW_EVENT_APPROVE
|
68
|
-
# PULL_REQUEST_REVIEW_EVENT_REQUEST_CHANGES
|
69
|
-
# PULL_REQUEST_REVIEW_EVENT_COMMENT
|
70
|
-
# @param body [String] The body for the pull request review (optional). Supports GFM.
|
71
|
-
# @return [Sawyer::Resource] The newly created pull request
|
72
|
-
# @example
|
73
|
-
# @client.submit_pull_request_review("octokit/octokit.rb", "REQUEST_CHANGES",
|
74
|
-
# "Nice changes, but please make couple of imrovements")
|
75
|
-
def submit_pull_request_review(repo, pull_request_number, review_id, event, body = nil, options = {})
|
76
|
-
review = {
|
77
|
-
event: event,
|
78
|
-
accept: CUSTOM_ACCEPT_HEADER
|
79
|
-
}
|
80
|
-
review[:body] = body unless body.nil?
|
81
|
-
post "#{Repository.path repo}/pulls/#{pull_request_number}/reviews/#{review_id}/events", options.merge(review)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|