danger 0.7.3 → 0.7.4

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: d97659425a77d1d4f21f22f7ba9fd43afd47d974
4
- data.tar.gz: 4d3eb4ce159a4deb8326bebb05073e81cc91e233
3
+ metadata.gz: fcdcdc1039905ce7ed910c8e951042b5f2fd994c
4
+ data.tar.gz: 96f2dd059e8d700ca3965e36339183e027a2c080
5
5
  SHA512:
6
- metadata.gz: 6ba7e1f9b4fb554dc663d81bf58b260a51914625c245ef9a30b6265f67155e1a1ba164df8c7db9a4c6895897b0761301df2bbe1f7a896bbf61dd5f6f7e70b002
7
- data.tar.gz: bd2495aa7cc47436669f8c4d9d190a501bf7273cb53997b97f93abb1541c2eabf17e8b8906d9b2b7f8ee4f580225680243804e58776a59b642ba2c08ae0ef84f
6
+ metadata.gz: b7e6ad0524f308e7ecfdab0b80759dc123024f2a6bde3c141bdc6c9317f63ea36b95dd4964b12be97487247b24ca12f886b1effd52352735ea307b15eefd5d60
7
+ data.tar.gz: a1fc5b70bfbd76637b683b2944942109732650f400d0415726e9d803f0ebd4b45001444f2c202ff873ecddcaf445acd77454d19d17e3a0f20f634f1c2060253c
data/README.md CHANGED
@@ -40,6 +40,20 @@ bundle exec danger
40
40
 
41
41
  This will look at your `Dangerfile` and update the pull request accordingly. While you are setting up Danger, you may want to use: `--verbose` for more debug information.
42
42
 
43
+ **Supported CIs**: Travis CI, CircleCI, Jenkins, Xcode Server and Buildkite.
44
+
45
+ ### Making your own
46
+ If the CI server you're using isn't available yet, you can build it yourself:
47
+
48
+ Take a look at some of the [already existing integrations](https://github.com/danger/danger/tree/master/lib/danger/ci_source). The class has 2 mandatory methods:
49
+
50
+ - `self.validates?` which should detect if the CI is active (detecting via ENV variables, mostly)
51
+ - `initialize` which should set 2 variables:
52
+ - `self.repo_slug` the repo slug, in `org/repo` or `user/repo` format.
53
+ - `self.pull_request_id` the number of the pull request that the CI is testing (often available in ENV variables)
54
+
55
+ We'd love to see pull requests for new integrations!
56
+
43
57
  ## What happens?
44
58
 
45
59
  Danger runs at the end of a CI build, she will execute a `Dangerfile`. This file is given some special variables based on the git diff and the Pull Request being running. You can use these variables in Ruby to provide messages, warnings and failures for your build. You set up Danger with a GitHub user account and she will post updates via comments on the Pull Request, and can fail your build too.
@@ -134,7 +148,7 @@ To create a new plugin run
134
148
  danger new_plugin
135
149
  ```
136
150
 
137
- This will generate a new Ruby file which you can modify to fit your needs.
151
+ This will generate a new Ruby file which you can modify to fit your needs.
138
152
 
139
153
  ## Support
140
154
 
@@ -155,8 +169,11 @@ open to turning useful bits into the official API.
155
169
 
156
170
  ## Test locally with `danger local`
157
171
 
158
- Using `danger local` will look for the last merged pull request in your git history, and apply your current
159
- `Dangerfile` against that Pull Request. Useful when editing.
172
+ You can use `danger local` to run Danger in an environment similar to how it will be ran on CI. By default Danger will look
173
+ at the most recently merged PR, then run your `Dangerfile` against that Pull Request. This is really useful when making changes.
174
+
175
+ If you have a specific PR in mind that you'd like to work against, make sure you have it merged in your current git
176
+ history, then append `--use-merged-pr=[id]` to the command.
160
177
 
161
178
  ## Suppress Violations
162
179
 
@@ -12,7 +12,8 @@ module Danger
12
12
  :deleted_files,
13
13
  :added_files,
14
14
  :deletions,
15
- :insertions
15
+ :insertions,
16
+ :commits
16
17
  ]
17
18
  end
18
19
 
@@ -34,10 +34,19 @@ module Danger
34
34
  end
35
35
  end
36
36
 
37
+ specific_pr = env["LOCAL_GIT_PR_ID"]
38
+ pr_ref = specific_pr ? "##{specific_pr}" : ''
39
+ pr_command = "log --merges --oneline | grep \"Merge pull request #{pr_ref}\" | head -n 1"
40
+
37
41
  # get the most recent PR merge
38
- pr_merge = run_git "log --since='2 weeks ago' --merges --oneline | grep \"Merge pull request\" | head -n 1".strip
42
+ pr_merge = run_git pr_command.strip
43
+
39
44
  if pr_merge.to_s.empty?
40
- raise "No recent pull requests found for this repo, danger requires at least one PR for the local mode"
45
+ if specific_pr
46
+ raise "Could not find the pull request (#{specific_pr}) inside the git history for this repo."
47
+ else
48
+ raise "No recent pull requests found for this repo, danger requires at least one PR for the local mode."
49
+ end
41
50
  end
42
51
 
43
52
  self.pull_request_id = pr_merge.match("#([0-9]+)")[1]
@@ -5,9 +5,16 @@ module Danger
5
5
 
6
6
  def initialize(argv)
7
7
  @dangerfile_path = "Dangerfile" if File.exist? "Dangerfile"
8
+ @pr_num = argv.option('use-merged-pr')
8
9
  super
9
10
  end
10
11
 
12
+ def self.options
13
+ [
14
+ ['--use-merged-pr=[#id]', 'The ID of an alreadty merged PR inside your history to use as a reference for the local run.']
15
+ ].concat(super)
16
+ end
17
+
11
18
  def validate!
12
19
  super
13
20
  unless @dangerfile_path
@@ -17,6 +24,7 @@ module Danger
17
24
 
18
25
  def run
19
26
  ENV["DANGER_USE_LOCAL_GIT"] = "YES"
27
+ ENV["LOCAL_GIT_PR_ID"] = @pr_num if @pr_num
20
28
 
21
29
  dm = Dangerfile.new
22
30
  dm.env = EnvironmentManager.new(ENV)
@@ -47,6 +55,7 @@ module Danger
47
55
 
48
56
  dm.env.scm = GitRepo.new
49
57
 
58
+ dm.env.ensure_danger_branches_are_setup
50
59
  dm.env.scm.diff_for_folder(".", from: dm.env.ci_source.base_commit, to: dm.env.ci_source.head_commit)
51
60
  dm.parse(Pathname.new(@dangerfile_path))
52
61
  dm.print_results
@@ -3,14 +3,6 @@ module Danger
3
3
  self.summary = 'Generate a new danger plugin.'
4
4
  self.command = 'new_plugin'
5
5
 
6
- def initialize(argv)
7
- super
8
- end
9
-
10
- def validate!
11
- super
12
- end
13
-
14
6
  def run
15
7
  require 'fileutils'
16
8
 
@@ -7,6 +7,8 @@ module Danger
7
7
  self.summary = 'Run the Dangerfile.'
8
8
  self.command = 'danger'
9
9
 
10
+ self.plugin_prefixes = %w(claide danger)
11
+
10
12
  def initialize(argv)
11
13
  @dangerfile_path = "Dangerfile" if File.exist? "Dangerfile"
12
14
  @base = argv.option('base')
@@ -38,17 +38,17 @@ module Danger
38
38
  pull_id = ci_source.pull_request_id
39
39
  test_branch = request_source.base_commit
40
40
 
41
- # Next, we want to ensure that we have a version of the current branch that at a know location
41
+ # Next, we want to ensure that we have a version of the current branch at a known location
42
42
  scm.exec "branch #{danger_base_branch} #{test_branch}"
43
43
 
44
44
  # OK, so we want to ensure that we have a known head branch, this will always represent
45
- # the head ( e.g. the most recent commit that will be merged. )
45
+ # the head of the PR ( e.g. the most recent commit that will be merged. )
46
46
  scm.exec "fetch origin +refs/pull/#{pull_id}/merge:#{danger_head_branch}"
47
47
  end
48
48
 
49
49
  def clean_up
50
50
  [danger_base_branch, danger_base_branch].each do |branch|
51
- scm.exec "branch -d #{branch}"
51
+ scm.exec "branch -D #{branch}"
52
52
  end
53
53
  end
54
54
 
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "0.7.3".freeze
2
+ VERSION = "0.7.4".freeze
3
3
  DESCRIPTION = "Automate your PR etiquette.".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: 0.7.3
4
+ version: 0.7.4
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-04-29 00:00:00.000000000 Z
12
+ date: 2016-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project:
259
- rubygems_version: 2.6.2
259
+ rubygems_version: 2.4.8
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: Automate your PR etiquette.