danger 3.5.5 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c92b72cb5561d7e1421f18365fc62b481c9762d8
4
- data.tar.gz: f8cdf206cb65498b8312019dfc839d70d4360ef2
3
+ metadata.gz: 829cfd070afd91b790b2aac00e62a09d0e8e169e
4
+ data.tar.gz: 5d52205da94c5a538fb1f148be5719733864c76a
5
5
  SHA512:
6
- metadata.gz: 3dc93f4a46211f5924006f83797e15a02284faf6f515343daf211041a066719916292df8b49f60a360ff828d910686bcdef932676ca91c68c3c9e414ea93034d
7
- data.tar.gz: 1a615082ce6d120d6732357ce403247da7a607affe8620ea2a2edb55cc9c239b3bdb585c2c39967e6c3d71db493f4b1c4ffd125481009049f54ff12e961c6fdd
6
+ metadata.gz: 8b540ce368e451e7287f5fa711281c1426c0f1118c9b8b753244425d7e9626251f16e50cc4bfce19dc42dab9ded3b33cf6bde007b872cd8dc52045593ab0efdb
7
+ data.tar.gz: ee493e7e72148446b71082a52fef7a23efee22f0ec3bc92bbb6c9e3005b5d7fffaea04abf51eba94b6e4bcfcc4f564ea52f82358d7b862a7322dc17a6adba8cc
data/README.md CHANGED
@@ -45,6 +45,8 @@ We keep all of the end-user documentation at [http://danger.systems](http://dang
45
45
 
46
46
  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
47
 
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
+
48
50
  ## I'm here to help out!
49
51
 
50
52
  Brilliant. So, let's get you set up.
@@ -17,6 +17,12 @@ module Danger
17
17
  #
18
18
  # With that set up, you can edit your job to add `bundle exec danger` at the build action.
19
19
  #
20
+ # ##### Pipeline
21
+ # If your're using [pipelines](https://jenkins.io/solutions/pipeline/) you should be using the [GitHub branch source plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Branch+Source+Plugin)
22
+ # for easy setup and handling of PRs.
23
+ #
24
+ # After you've set up the plugin, add a `sh 'bundle exec danger'` line in your pipeline script and make sure that build PRs is enabled.
25
+ #
20
26
  # #### GitLab
21
27
  # You will want to be using the [GitLab Plugin](https://github.com/jenkinsci/gitlab-plugin)
22
28
  # in order to ensure that you have the build environment set up for MR integration.
@@ -53,7 +59,7 @@ module Danger
53
59
  end
54
60
 
55
61
  def initialize(env)
56
- self.repo_url = env.fetch("GIT_URL_1") { env["GIT_URL"] }
62
+ self.repo_url = self.class.repo_url(env)
57
63
  self.pull_request_id = self.class.pull_request_id(env)
58
64
 
59
65
  repo_matches = self.repo_url.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$})
@@ -63,9 +69,34 @@ module Danger
63
69
  def self.pull_request_id(env)
64
70
  if env["ghprbPullId"]
65
71
  env["ghprbPullId"]
72
+ elsif env["CHANGE_ID"]
73
+ env["CHANGE_ID"]
66
74
  else
67
75
  env["gitlabMergeRequestId"]
68
76
  end
69
77
  end
78
+
79
+ def self.repo_url(env)
80
+ if env["GIT_URL_1"]
81
+ env["GIT_URL_1"]
82
+ elsif env["CHANGE_URL"]
83
+ change_url = env["CHANGE_URL"]
84
+ case change_url
85
+ when %r{\/pull\/} # GitHub
86
+ matches = change_url.match(%r{(.+)\/pull\/[0-9]+})
87
+ matches[1] unless matches.nil?
88
+ when %r{\/merge_requests\/} # GitLab
89
+ matches = change_url.match(%r{(.+)\/merge_requests\/[0-9]+})
90
+ matches[1] unless matches.nil?
91
+ when %r{\/pull-requests\/} # Bitbucket
92
+ matches = change_url.match(%r{(.+)\/pull-requests\/[0-9]+})
93
+ matches[1] unless matches.nil?
94
+ else
95
+ change_url
96
+ end
97
+ else
98
+ env["GIT_URL"]
99
+ end
100
+ end
70
101
  end
71
102
  end
@@ -15,7 +15,7 @@ module Danger
15
15
  # By default, using `fail` would fail the corresponding build. Either via an API call, or
16
16
  # via the return value for the danger command.
17
17
  #
18
- # It is possible to have Danger ignore specific warnings or errors by writing `Danger: Ignore "[warning/error text]`.
18
+ # It is possible to have Danger ignore specific warnings or errors by writing `Danger: Ignore "[warning/error text]"`.
19
19
  #
20
20
  # Sidenote: Messaging is the only plugin which adds functions to the root of the Dangerfile.
21
21
  #
@@ -3,6 +3,8 @@ require "octokit"
3
3
  require "danger/helpers/comments_helper"
4
4
  require "danger/helpers/comment"
5
5
 
6
+ require "danger/request_sources/support/get_ignored_violation"
7
+
6
8
  module Danger
7
9
  module RequestSources
8
10
  class GitHub < RequestSource
@@ -83,13 +85,11 @@ module Danger
83
85
  end
84
86
 
85
87
  fetch_issue_details(self.pr_json)
86
- self.ignored_violations = ignored_violations_from_pr(self.pr_json)
88
+ self.ignored_violations = ignored_violations_from_pr
87
89
  end
88
90
 
89
- def ignored_violations_from_pr(pr_json)
90
- pr_body = pr_json["body"]
91
- return [] if pr_body.nil?
92
- pr_body.chomp.scan(/>\s*danger\s*:\s*ignore\s*"(.*)"/i).flatten
91
+ def ignored_violations_from_pr
92
+ GetIgnoredViolation.new(self.pr_json["body"]).call
93
93
  end
94
94
 
95
95
  def fetch_issue_details(pr_json)
@@ -3,6 +3,8 @@ require "gitlab"
3
3
  require "danger/helpers/comments_helper"
4
4
  require "danger/helpers/comment"
5
5
 
6
+ require "danger/request_sources/support/get_ignored_violation"
7
+
6
8
  module Danger
7
9
  module RequestSources
8
10
  class GitLab < RequestSource
@@ -88,19 +90,19 @@ module Danger
88
90
  def fetch_details
89
91
  self.mr_json = client.merge_request(escaped_ci_slug, self.ci_source.pull_request_id)
90
92
  self.commits_json = client.merge_request_commits(escaped_ci_slug, self.ci_source.pull_request_id)
91
- self.ignored_violations = ignored_violations_from_pr(self.mr_json)
93
+ self.ignored_violations = ignored_violations_from_pr
92
94
  end
93
95
 
94
- def ignored_violations_from_pr(mr_json)
95
- pr_body = mr_json.description
96
- return [] if pr_body.nil?
97
- pr_body.chomp.scan(/>\s*danger\s*:\s*ignore\s*"(.*)"/i).flatten
96
+ def ignored_violations_from_pr
97
+ GetIgnoredViolation.new(self.mr_json.description).call
98
98
  end
99
99
 
100
- def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger")
100
+ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false)
101
101
  editable_comments = mr_comments.select { |comment| comment.generated_by_danger?(danger_id) }
102
102
 
103
- if editable_comments.empty?
103
+ should_create_new_comment = new_comment || editable_comments.empty?
104
+
105
+ if should_create_new_comment
104
106
  previous_violations = {}
105
107
  else
106
108
  comment = editable_comments.first.body
@@ -0,0 +1,17 @@
1
+ class GetIgnoredViolation
2
+ IGNORE_REGEXP = />*\s*danger\s*:\s*ignore\s*"(?<error>[^"]*)"/i
3
+
4
+ def initialize(body)
5
+ @body = body
6
+ end
7
+
8
+ def call
9
+ return [] unless body
10
+
11
+ body.chomp.scan(IGNORE_REGEXP).flatten
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :body
17
+ end
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "3.5.5".freeze
2
+ VERSION = "3.6.0".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.5.5
4
+ version: 3.6.0
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-10-14 00:00:00.000000000 Z
12
+ date: 2016-10-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -447,6 +447,7 @@ files:
447
447
  - lib/danger/request_sources/github.rb
448
448
  - lib/danger/request_sources/gitlab.rb
449
449
  - lib/danger/request_sources/request_source.rb
450
+ - lib/danger/request_sources/support/get_ignored_violation.rb
450
451
  - lib/danger/scm_source/git_repo.rb
451
452
  - lib/danger/version.rb
452
453
  homepage: https://github.com/danger/danger
@@ -469,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
469
470
  version: '0'
470
471
  requirements: []
471
472
  rubyforge_project:
472
- rubygems_version: 2.6.7
473
+ rubygems_version: 2.2.2
473
474
  signing_key:
474
475
  specification_version: 4
475
476
  summary: Like Unit Tests, but for your Team Culture.