danger 5.4.3 → 5.5.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.
- checksums.yaml +4 -4
- data/lib/danger/ci_source/jenkins.rb +7 -1
- data/lib/danger/commands/local_helpers/pry_setup.rb +1 -1
- data/lib/danger/helpers/comment.rb +1 -1
- data/lib/danger/request_sources/bitbucket_cloud.rb +4 -2
- data/lib/danger/request_sources/bitbucket_server.rb +4 -2
- data/lib/danger/request_sources/github/github.rb +4 -2
- data/lib/danger/request_sources/gitlab.rb +4 -2
- data/lib/danger/request_sources/vsts.rb +4 -2
- data/lib/danger/scm_source/git_repo.rb +52 -8
- data/lib/danger/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035ce582ea667e60dfda80d1c6c3292c17d7f384
|
4
|
+
data.tar.gz: faa2bacbc0e417f69e21b6fcf3e301f0789c90f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e139a3aa585b191a0d2959e4565a56626b5d66c11f03926c5c1ee91625d28a085309b4491aa489a1d9b220de8220af534cfc0f4481d13fa0a68a48f1059f4d30
|
7
|
+
data.tar.gz: 945bd0fecf7c392b19ce7928ea76938e862c540121f771accc791ad60fcc8722b3c18d4a287f5bcfb7500d9ec5dd5c9d52b5d7ae9dd91cb32029c9be7dc3df82
|
@@ -32,7 +32,11 @@ module Danger
|
|
32
32
|
# #### General
|
33
33
|
#
|
34
34
|
# People occasionally see issues with Danger not classing your CI runs as a PR, to give you visibilty
|
35
|
-
# the Jenkins side of Danger expects to see one of these env vars:
|
35
|
+
# the Jenkins side of Danger expects to see one of these env vars:
|
36
|
+
# - ghprbPullId
|
37
|
+
# - CHANGE_ID
|
38
|
+
# - gitlabMergeRequestIid
|
39
|
+
# - gitlabMergeRequestId
|
36
40
|
#
|
37
41
|
# ### Token Setup
|
38
42
|
#
|
@@ -81,6 +85,8 @@ module Danger
|
|
81
85
|
env["ghprbPullId"]
|
82
86
|
elsif env["CHANGE_ID"]
|
83
87
|
env["CHANGE_ID"]
|
88
|
+
elsif env["gitlabMergeRequestIid"]
|
89
|
+
env["gitlabMergeRequestIid"]
|
84
90
|
else
|
85
91
|
env["gitlabMergeRequestId"]
|
86
92
|
end
|
@@ -9,7 +9,7 @@ module Danger
|
|
9
9
|
validate_pry_available
|
10
10
|
FileUtils.cp dangerfile_path, DANGERFILE_COPY
|
11
11
|
File.open(DANGERFILE_COPY, "a") do |f|
|
12
|
-
f.write("
|
12
|
+
f.write("\nbinding.pry; File.delete(\"#{DANGERFILE_COPY}\")")
|
13
13
|
end
|
14
14
|
DANGERFILE_COPY
|
15
15
|
end
|
@@ -46,16 +46,18 @@ module Danger
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def setup_danger_branches
|
49
|
+
base_branch = self.pr_json[:destination][:branch][:name]
|
49
50
|
base_commit = self.pr_json[:destination][:commit][:hash]
|
51
|
+
head_branch = self.pr_json[:source][:branch][:name]
|
50
52
|
head_commit = self.pr_json[:source][:commit][:hash]
|
51
53
|
|
52
54
|
# Next, we want to ensure that we have a version of the current branch at a known location
|
53
|
-
scm.
|
55
|
+
scm.ensure_commitish_exists_on_branch! base_branch, base_commit
|
54
56
|
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
|
55
57
|
|
56
58
|
# OK, so we want to ensure that we have a known head branch, this will always represent
|
57
59
|
# the head of the PR ( e.g. the most recent commit that will be merged. )
|
58
|
-
scm.
|
60
|
+
scm.ensure_commitish_exists_on_branch! head_branch, head_commit
|
59
61
|
self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{head_commit}"
|
60
62
|
end
|
61
63
|
|
@@ -47,16 +47,18 @@ module Danger
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def setup_danger_branches
|
50
|
+
base_branch = self.pr_json[:toRef][:id].sub("refs/heads/", "")
|
50
51
|
base_commit = self.pr_json[:toRef][:latestCommit]
|
52
|
+
head_branch = self.pr_json[:fromRef][:id].sub("refs/heads/", "")
|
51
53
|
head_commit = self.pr_json[:fromRef][:latestCommit]
|
52
54
|
|
53
55
|
# Next, we want to ensure that we have a version of the current branch at a known location
|
54
|
-
scm.
|
56
|
+
scm.ensure_commitish_exists_on_branch! base_branch, base_commit
|
55
57
|
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
|
56
58
|
|
57
59
|
# OK, so we want to ensure that we have a known head branch, this will always represent
|
58
60
|
# the head of the PR ( e.g. the most recent commit that will be merged. )
|
59
|
-
scm.
|
61
|
+
scm.ensure_commitish_exists_on_branch! head_branch, head_commit
|
60
62
|
self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{head_commit}"
|
61
63
|
end
|
62
64
|
|
@@ -98,16 +98,18 @@ module Danger
|
|
98
98
|
|
99
99
|
def setup_danger_branches
|
100
100
|
# we can use a github specific feature here:
|
101
|
+
base_branch = self.pr_json["base"]["ref"]
|
101
102
|
base_commit = self.pr_json["base"]["sha"]
|
103
|
+
head_branch = self.pr_json["head"]["ref"]
|
102
104
|
head_commit = self.pr_json["head"]["sha"]
|
103
105
|
|
104
106
|
# Next, we want to ensure that we have a version of the current branch at a known location
|
105
|
-
scm.
|
107
|
+
scm.ensure_commitish_exists_on_branch! base_branch, base_commit
|
106
108
|
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
|
107
109
|
|
108
110
|
# OK, so we want to ensure that we have a known head branch, this will always represent
|
109
111
|
# the head of the PR ( e.g. the most recent commit that will be merged. )
|
110
|
-
scm.
|
112
|
+
scm.ensure_commitish_exists_on_branch! head_branch, head_commit
|
111
113
|
self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{head_commit}"
|
112
114
|
end
|
113
115
|
|
@@ -78,15 +78,17 @@ module Danger
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def setup_danger_branches
|
81
|
+
base_branch = self.mr_json.source_branch
|
82
|
+
head_branch = self.mr_json.target_branch
|
81
83
|
head_commit = self.scm.head_commit
|
82
84
|
|
83
85
|
# Next, we want to ensure that we have a version of the current branch at a known location
|
84
|
-
scm.
|
86
|
+
scm.ensure_commitish_exists_on_branch! base_branch, base_commit
|
85
87
|
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
|
86
88
|
|
87
89
|
# OK, so we want to ensure that we have a known head branch, this will always represent
|
88
90
|
# the head of the PR ( e.g. the most recent commit that will be merged. )
|
89
|
-
scm.
|
91
|
+
scm.ensure_commitish_exists_on_branch! head_branch, head_commit
|
90
92
|
self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{head_commit}"
|
91
93
|
end
|
92
94
|
|
@@ -53,16 +53,18 @@ module Danger
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def setup_danger_branches
|
56
|
+
base_branch = self.pr_json[:targetRefName].sub("refs/heads/", "")
|
56
57
|
base_commit = self.pr_json[:lastMergeTargetCommit][:commitId]
|
58
|
+
head_branch = self.pr_json[:sourceRefName].sub("refs/heads/", "")
|
57
59
|
head_commit = self.pr_json[:lastMergeSourceCommit][:commitId]
|
58
60
|
|
59
61
|
# Next, we want to ensure that we have a version of the current branch at a known location
|
60
|
-
scm.
|
62
|
+
scm.ensure_commitish_exists_on_branch! base_branch, base_commit
|
61
63
|
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
|
62
64
|
|
63
65
|
# OK, so we want to ensure that we have a known head branch, this will always represent
|
64
66
|
# the head of the PR ( e.g. the most recent commit that will be merged. )
|
65
|
-
scm.
|
67
|
+
scm.ensure_commitish_exists_on_branch! head_branch, head_commit
|
66
68
|
self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{head_commit}"
|
67
69
|
end
|
68
70
|
|
@@ -64,11 +64,29 @@ module Danger
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def ensure_commitish_exists!(commitish)
|
67
|
-
|
67
|
+
return ensure_commitish_exists_on_branch!(commitish, commitish) if commit_is_ref?(commitish)
|
68
|
+
return if commit_exists?(commitish)
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
git_in_depth_fetch
|
71
|
+
raise_if_we_cannot_find_the_commit(commitish) if commit_not_exists?(commitish)
|
72
|
+
end
|
73
|
+
|
74
|
+
def ensure_commitish_exists_on_branch!(branch, commitish)
|
75
|
+
return if commit_exists?(commitish)
|
76
|
+
|
77
|
+
depth = 0
|
78
|
+
success =
|
79
|
+
(3..6).any? do |factor|
|
80
|
+
depth += Math.exp(factor).to_i
|
81
|
+
|
82
|
+
git_fetch_branch_to_depth(branch, depth)
|
83
|
+
commit_exists?(commitish)
|
84
|
+
end
|
85
|
+
|
86
|
+
return if success
|
87
|
+
|
88
|
+
git_in_depth_fetch
|
89
|
+
raise_if_we_cannot_find_the_commit(commitish) if commit_not_exists?(commitish)
|
72
90
|
end
|
73
91
|
|
74
92
|
private
|
@@ -77,6 +95,10 @@ module Danger
|
|
77
95
|
exec("fetch --depth 1000000")
|
78
96
|
end
|
79
97
|
|
98
|
+
def git_fetch_branch_to_depth(branch, depth)
|
99
|
+
exec("fetch --depth=#{depth} --prune origin +refs/heads/#{branch}:refs/remotes/origin/#{branch}")
|
100
|
+
end
|
101
|
+
|
80
102
|
def default_env
|
81
103
|
{ "LANG" => "en_US.UTF-8" }
|
82
104
|
end
|
@@ -95,17 +117,35 @@ module Danger
|
|
95
117
|
|
96
118
|
def find_merge_base(repo, from, to)
|
97
119
|
possible_merge_base = possible_merge_base(repo, from, to)
|
120
|
+
return possible_merge_base if possible_merge_base
|
98
121
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
122
|
+
possible_merge_base = find_merge_base_with_incremental_fetch(repo, from, to)
|
123
|
+
return possible_merge_base if possible_merge_base
|
124
|
+
|
125
|
+
git_in_depth_fetch
|
126
|
+
possible_merge_base = possible_merge_base(repo, from, to)
|
103
127
|
|
104
128
|
raise "Cannot find a merge base between #{from} and #{to}." unless possible_merge_base
|
105
129
|
|
106
130
|
possible_merge_base
|
107
131
|
end
|
108
132
|
|
133
|
+
def find_merge_base_with_incremental_fetch(repo, from, to)
|
134
|
+
from_is_ref = commit_is_ref?(from)
|
135
|
+
to_is_ref = commit_is_ref?(to)
|
136
|
+
|
137
|
+
return unless from_is_ref || to_is_ref
|
138
|
+
|
139
|
+
depth = 0
|
140
|
+
(3..6).any? do |factor|
|
141
|
+
depth += Math.exp(factor).to_i
|
142
|
+
|
143
|
+
git_fetch_branch_to_depth(from, depth) if from_is_ref
|
144
|
+
git_fetch_branch_to_depth(to, depth) if to_is_ref
|
145
|
+
possible_merge_base(repo, from, to)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
109
149
|
def possible_merge_base(repo, from, to)
|
110
150
|
[repo.merge_base(from, to)].find { |base| commit_exists?(base) }
|
111
151
|
end
|
@@ -113,6 +153,10 @@ module Danger
|
|
113
153
|
def commits_in_branch_count(from, to)
|
114
154
|
exec("rev-list #{from}..#{to} --count").to_i
|
115
155
|
end
|
156
|
+
|
157
|
+
def commit_is_ref?(commit)
|
158
|
+
/[a-f0-9]{5,40}/ !~ commit
|
159
|
+
end
|
116
160
|
end
|
117
161
|
end
|
118
162
|
|
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.
|
4
|
+
version: 5.5.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: 2017-09-
|
12
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|
@@ -487,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
487
487
|
version: '0'
|
488
488
|
requirements: []
|
489
489
|
rubyforge_project:
|
490
|
-
rubygems_version: 2.
|
490
|
+
rubygems_version: 2.2.2
|
491
491
|
signing_key:
|
492
492
|
specification_version: 4
|
493
493
|
summary: Like Unit Tests, but for your Team Culture.
|