danger 9.2.0 → 9.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719588ed490c1115e2439aabacb0dd400e1852bf03a0f25514b26dcb08e0ad9e
|
4
|
+
data.tar.gz: 7426ab63483923ceffd843789c473a46f7726b1f9057a74b558bbeeb2c6948d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fa39fb8d2a11ac973a1c4b7a9647bef1a0bfdd36411d403e1f3121b3a1b7490dbaa7489c17f018fa1ae88be4ceccc6ee213267ee32133dfbf162cb3bab93e6f
|
7
|
+
data.tar.gz: 01ba1c81cfdb4a37661826f913ed3227e1432fbbede1d69e6521eacfd4d6c8595f8a5140134c431446b591f81027797a4f93b67b674fcfd9c860d452575ea5fb
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "danger/request_sources/github/github"
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
# ### CI Setup
|
5
|
+
#
|
6
|
+
# Custom CI with GitHub
|
7
|
+
#
|
8
|
+
# This CI source is for custom, most likely internal, CI systems that are use GitHub as source control.
|
9
|
+
# An example could be argo-workflows or tekton hosted in your own Kubernetes cluster.
|
10
|
+
#
|
11
|
+
# The following environment variables are required:
|
12
|
+
# - `CUSTOM_CI_WITH_GITHUB` - Set to any value to indicate that this is a custom CI with GitHub
|
13
|
+
#
|
14
|
+
# ### Token Setup
|
15
|
+
#
|
16
|
+
# #### GitHub
|
17
|
+
# As you own the setup, it's up to you to add the environment variable for the `DANGER_GITHUB_API_TOKEN`.
|
18
|
+
#
|
19
|
+
class CustomCIWithGithub < CI
|
20
|
+
def self.validates_as_ci?(env)
|
21
|
+
env.key? "CUSTOM_CI_WITH_GITHUB"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.validates_as_pr?(env)
|
25
|
+
value = env["GITHUB_EVENT_NAME"]
|
26
|
+
["pull_request", "pull_request_target"].include?(value)
|
27
|
+
end
|
28
|
+
|
29
|
+
def supported_request_sources
|
30
|
+
@supported_request_sources ||= [Danger::RequestSources::GitHub]
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(env)
|
34
|
+
self.repo_slug = env["GITHUB_REPOSITORY"]
|
35
|
+
pull_request_event = JSON.parse(File.read(env["GITHUB_EVENT_PATH"]))
|
36
|
+
self.pull_request_id = pull_request_event["number"]
|
37
|
+
self.repo_url = pull_request_event["repository"]["clone_url"]
|
38
|
+
|
39
|
+
# if environment variable DANGER_GITHUB_API_TOKEN is not set, use env GITHUB_TOKEN
|
40
|
+
if (env.key? "CUSTOM_CI_WITH_GITHUB") && (!env.key? "DANGER_GITHUB_API_TOKEN")
|
41
|
+
env["DANGER_GITHUB_API_TOKEN"] = env["GITHUB_TOKEN"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -49,7 +49,7 @@ module Danger
|
|
49
49
|
|
50
50
|
configure_octokit(ENV["DANGER_TMPDIR"] || Dir.tmpdir)
|
51
51
|
|
52
|
-
env = EnvironmentManager.new(ENV, cork)
|
52
|
+
env = EnvironmentManager.new(ENV, cork, @danger_id)
|
53
53
|
dm = Dangerfile.new(env, cork)
|
54
54
|
|
55
55
|
LocalSetup.new(dm, cork).setup(verbose: verbose) do
|
@@ -57,7 +57,7 @@ module Danger
|
|
57
57
|
Danger::EnvironmentManager.danger_base_branch,
|
58
58
|
Danger::EnvironmentManager.danger_head_branch,
|
59
59
|
@dangerfile_path,
|
60
|
-
|
60
|
+
@danger_id,
|
61
61
|
nil,
|
62
62
|
nil
|
63
63
|
)
|
@@ -78,15 +78,20 @@ module Danger
|
|
78
78
|
messages = update_inline_comments_for_kind!(:messages, messages, danger_id: danger_id)
|
79
79
|
markdowns = update_inline_comments_for_kind!(:markdowns, markdowns, danger_id: danger_id)
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
81
|
+
has_comments = (warnings.count > 0 || errors.count > 0 || messages.count > 0 || markdowns.count > 0)
|
82
|
+
if has_comments
|
83
|
+
comment = generate_description(warnings: warnings,
|
84
|
+
errors: errors)
|
85
|
+
comment += "\n\n"
|
86
|
+
comment += generate_comment(warnings: warnings,
|
87
|
+
errors: errors,
|
88
|
+
messages: messages,
|
89
|
+
markdowns: markdowns,
|
90
|
+
previous_violations: {},
|
91
|
+
danger_id: danger_id,
|
92
|
+
template: "bitbucket_server")
|
93
|
+
@api.post_comment(comment)
|
94
|
+
end
|
90
95
|
end
|
91
96
|
|
92
97
|
def update_pr_by_line!(message_groups:,
|
@@ -8,13 +8,9 @@ module Danger
|
|
8
8
|
|
9
9
|
def diff_for_folder(folder, from: "master", to: "HEAD", lookup_top_level: false)
|
10
10
|
self.folder = folder
|
11
|
-
git_top_level = folder
|
12
|
-
|
13
|
-
|
14
|
-
git_top_level = exec("rev-parse --show-toplevel")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
repo = Git.open git_top_level
|
11
|
+
git_top_level = find_git_top_level_if_needed!(folder, lookup_top_level)
|
12
|
+
|
13
|
+
repo = Git.open(git_top_level)
|
18
14
|
|
19
15
|
ensure_commitish_exists!(from)
|
20
16
|
ensure_commitish_exists!(to)
|
@@ -168,6 +164,26 @@ module Danger
|
|
168
164
|
def commit_is_ref?(commit)
|
169
165
|
/[a-f0-9]{5,40}/ !~ commit
|
170
166
|
end
|
167
|
+
|
168
|
+
def find_git_top_level_if_needed!(folder, lookup_top_level)
|
169
|
+
git_top_level = Dir.chdir(folder) { exec("rev-parse --show-toplevel") }
|
170
|
+
return git_top_level if lookup_top_level
|
171
|
+
|
172
|
+
# To keep backward compatibility, `GitRepo#diff_for_folder` expects folder
|
173
|
+
# to be top level git directory or requires `true` to `lookup_top_level`.
|
174
|
+
# https://github.com/danger/danger/pull/1178
|
175
|
+
return folder if compare_path(git_top_level, folder)
|
176
|
+
|
177
|
+
message = "#{folder} is not the top level git directory. Pass correct path or `true` to `lookup_top_level` option for `diff_for_folder`"
|
178
|
+
raise ArgumentError, message
|
179
|
+
end
|
180
|
+
|
181
|
+
# Compare given paths as realpath. Return true if both are same.
|
182
|
+
# `git rev-parse --show-toplevel` returns a path resolving symlink. In rspec, given path can
|
183
|
+
# be a temporary directory's path created under a symlinked directory `/var`.
|
184
|
+
def compare_path(path1, path2)
|
185
|
+
Pathname.new(path1).realdirpath == Pathname.new(path2).realdirpath
|
186
|
+
end
|
171
187
|
end
|
172
188
|
end
|
173
189
|
|
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: 9.
|
4
|
+
version: 9.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: 2023-
|
12
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: claide
|
@@ -107,14 +107,14 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.13'
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
117
|
+
version: '1.13'
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: kramdown
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,14 +163,14 @@ dependencies:
|
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '6.0'
|
167
167
|
type: :runtime
|
168
168
|
prerelease: false
|
169
169
|
version_requirements: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
173
|
+
version: '6.0'
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
175
|
name: terminal-table
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- lib/danger/ci_source/codemagic.rb
|
224
224
|
- lib/danger/ci_source/codeship.rb
|
225
225
|
- lib/danger/ci_source/concourse.rb
|
226
|
+
- lib/danger/ci_source/custom_ci_with_github.rb
|
226
227
|
- lib/danger/ci_source/dotci.rb
|
227
228
|
- lib/danger/ci_source/drone.rb
|
228
229
|
- lib/danger/ci_source/github_actions.rb
|
@@ -343,8 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
343
344
|
- !ruby/object:Gem::Version
|
344
345
|
version: '0'
|
345
346
|
requirements: []
|
346
|
-
|
347
|
-
rubygems_version: 2.7.6.2
|
347
|
+
rubygems_version: 3.1.6
|
348
348
|
signing_key:
|
349
349
|
specification_version: 4
|
350
350
|
summary: Like Unit Tests, but for your Team Culture.
|