danger 8.4.2 → 9.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +1 -1
  4. data/bin/danger +1 -1
  5. data/lib/danger/ci_source/appcircle.rb +83 -0
  6. data/lib/danger/ci_source/appveyor.rb +1 -0
  7. data/lib/danger/ci_source/azure_pipelines.rb +20 -5
  8. data/lib/danger/ci_source/bamboo.rb +1 -1
  9. data/lib/danger/ci_source/bitbucket_pipelines.rb +1 -2
  10. data/lib/danger/ci_source/bitrise.rb +10 -10
  11. data/lib/danger/ci_source/buildkite.rb +1 -1
  12. data/lib/danger/ci_source/circle.rb +1 -1
  13. data/lib/danger/ci_source/circle_api.rb +2 -2
  14. data/lib/danger/ci_source/code_build.rb +20 -6
  15. data/lib/danger/ci_source/codefresh.rb +7 -13
  16. data/lib/danger/ci_source/concourse.rb +4 -5
  17. data/lib/danger/ci_source/dotci.rb +4 -6
  18. data/lib/danger/ci_source/github_actions.rb +6 -6
  19. data/lib/danger/ci_source/gitlab_ci.rb +13 -19
  20. data/lib/danger/ci_source/jenkins.rb +22 -23
  21. data/lib/danger/ci_source/local_git_repo.rb +36 -38
  22. data/lib/danger/ci_source/local_only_git_repo.rb +5 -8
  23. data/lib/danger/ci_source/support/find_repo_info_from_url.rb +11 -10
  24. data/lib/danger/ci_source/support/pull_request_finder.rb +47 -43
  25. data/lib/danger/ci_source/teamcity.rb +1 -1
  26. data/lib/danger/ci_source/xcode_cloud.rb +7 -7
  27. data/lib/danger/commands/init.rb +1 -1
  28. data/lib/danger/commands/local.rb +1 -1
  29. data/lib/danger/commands/local_helpers/http_cache.rb +2 -0
  30. data/lib/danger/commands/local_helpers/local_setup.rb +2 -0
  31. data/lib/danger/commands/local_helpers/pry_setup.rb +1 -0
  32. data/lib/danger/commands/plugins/plugin_json.rb +1 -3
  33. data/lib/danger/commands/plugins/plugin_lint.rb +0 -2
  34. data/lib/danger/commands/plugins/plugin_readme.rb +2 -5
  35. data/lib/danger/commands/pr.rb +2 -1
  36. data/lib/danger/commands/runner.rb +1 -1
  37. data/lib/danger/commands/staging.rb +7 -7
  38. data/lib/danger/commands/systems.rb +4 -6
  39. data/lib/danger/comment_generators/gitlab_inline.md.erb +1 -1
  40. data/lib/danger/comment_generators/vsts_inline.md.erb +17 -0
  41. data/lib/danger/core_ext/file_list.rb +2 -2
  42. data/lib/danger/danger_core/dangerfile.rb +19 -16
  43. data/lib/danger/danger_core/environment_manager.rb +2 -1
  44. data/lib/danger/danger_core/executor.rb +10 -11
  45. data/lib/danger/danger_core/message_aggregator.rb +1 -0
  46. data/lib/danger/danger_core/messages/base.rb +1 -0
  47. data/lib/danger/danger_core/messages/markdown.rb +3 -4
  48. data/lib/danger/danger_core/messages/violation.rb +1 -2
  49. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb +1 -3
  50. data/lib/danger/danger_core/plugins/dangerfile_bitbucket_server_plugin.rb +4 -4
  51. data/lib/danger/danger_core/plugins/dangerfile_danger_plugin.rb +9 -3
  52. data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +4 -3
  53. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +3 -1
  54. data/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin.rb +3 -1
  55. data/lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb +4 -3
  56. data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +3 -1
  57. data/lib/danger/danger_core/plugins/dangerfile_vsts_plugin.rb +3 -3
  58. data/lib/danger/danger_core/standard_error.rb +2 -3
  59. data/lib/danger/helpers/array_subclass.rb +2 -2
  60. data/lib/danger/helpers/comments_helper.rb +8 -7
  61. data/lib/danger/helpers/comments_parsing_helper.rb +3 -2
  62. data/lib/danger/helpers/emoji_mapper.rb +1 -1
  63. data/lib/danger/plugin_support/plugin.rb +0 -1
  64. data/lib/danger/plugin_support/plugin_linter.rb +1 -0
  65. data/lib/danger/request_sources/bitbucket_cloud.rb +3 -6
  66. data/lib/danger/request_sources/bitbucket_cloud_api.rb +5 -7
  67. data/lib/danger/request_sources/bitbucket_server.rb +47 -11
  68. data/lib/danger/request_sources/bitbucket_server_api.rb +17 -14
  69. data/lib/danger/request_sources/code_insights_api.rb +9 -14
  70. data/lib/danger/request_sources/github/github.rb +30 -38
  71. data/lib/danger/request_sources/github/github_review.rb +3 -2
  72. data/lib/danger/request_sources/github/github_review_resolver.rb +0 -2
  73. data/lib/danger/request_sources/github/github_review_unsupported.rb +0 -2
  74. data/lib/danger/request_sources/gitlab.rb +53 -75
  75. data/lib/danger/request_sources/local_only.rb +1 -4
  76. data/lib/danger/request_sources/request_source.rb +20 -8
  77. data/lib/danger/request_sources/support/get_ignored_violation.rb +1 -1
  78. data/lib/danger/request_sources/vsts.rb +175 -15
  79. data/lib/danger/request_sources/vsts_api.rb +41 -7
  80. data/lib/danger/scm_source/git_repo.rb +2 -1
  81. data/lib/danger/version.rb +1 -1
  82. data/lib/danger.rb +1 -0
  83. metadata +39 -37
  84. data/lib/danger/ci_source/vsts.rb +0 -73
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require "base64"
4
4
  require "danger/helpers/comments_helper"
@@ -8,7 +8,7 @@ module Danger
8
8
  class VSTSAPI
9
9
  attr_accessor :host, :pr_api_endpoint, :min_api_version_for_comments
10
10
 
11
- def initialize(_project, slug, pull_request_id, environment)
11
+ def initialize(slug, pull_request_id, environment)
12
12
  self.min_api_version_for_comments = "3.0"
13
13
 
14
14
  user_name = ""
@@ -27,17 +27,15 @@ module Danger
27
27
 
28
28
  def supports_comments?
29
29
  major_version = @api_version.split(".").first.to_i
30
- minimun_version_for_comments = self.min_api_version_for_comments.split(".").first.to_i
30
+ minimum_version_for_comments = self.min_api_version_for_comments.split(".").first.to_i
31
31
 
32
- major_version >= minimun_version_for_comments
32
+ major_version >= minimum_version_for_comments
33
33
  end
34
34
 
35
35
  def inspect
36
36
  inspected = super
37
37
 
38
- if @token
39
- inspected = inspected.sub! @token, "********".freeze
40
- end
38
+ inspected.gsub!(@token, "********") if @token
41
39
 
42
40
  inspected
43
41
  end
@@ -46,6 +44,10 @@ module Danger
46
44
  @token && !@token.empty?
47
45
  end
48
46
 
47
+ def pull_request(*)
48
+ fetch_pr_json
49
+ end
50
+
49
51
  def fetch_pr_json
50
52
  uri = URI("#{pr_api_endpoint}?api-version=#{@api_version}")
51
53
  fetch_json(uri)
@@ -77,6 +79,38 @@ module Danger
77
79
  post(uri, body)
78
80
  end
79
81
 
82
+ def post_inline_comment(text, file, line)
83
+ uri = URI("#{pr_api_endpoint}/threads?api-version=#{@api_version}")
84
+ body = {
85
+ "comments" => [
86
+ {
87
+ "parentCommentId" => 0,
88
+ "content" => text,
89
+ "commentType" => 1
90
+ }
91
+ ],
92
+ "properties" => {
93
+ "Microsoft.TeamFoundation.Discussion.SupportsMarkdown" => {
94
+ "type" => "System.Int32",
95
+ "value" => 1
96
+ }
97
+ },
98
+ "status" => 1,
99
+ "threadContext" => {
100
+ "filePath" => file,
101
+ "rightFileEnd" => {
102
+ "line" => line + 1,
103
+ "offset" => 1
104
+ },
105
+ "rightFileStart" => {
106
+ "line" => line,
107
+ "offset" => 1
108
+ }
109
+ }
110
+ }.to_json
111
+ post(uri, body)
112
+ end
113
+
80
114
  def update_comment(thread, id, new_comment)
81
115
  uri = URI("#{pr_api_endpoint}/threads/#{thread}/comments/#{id}?api-version=#{@api_version}")
82
116
  body = {
@@ -55,7 +55,8 @@ module Danger
55
55
  def exec(string)
56
56
  require "open3"
57
57
  Dir.chdir(self.folder || ".") do
58
- Open3.popen2(default_env, "git #{string}") do |_stdin, stdout, _wait_thr|
58
+ git_command = string.split(" ").dup.unshift("git")
59
+ Open3.popen2(default_env, *git_command) do |_stdin, stdout, _wait_thr|
59
60
  stdout.read.rstrip
60
61
  end
61
62
  end
@@ -1,4 +1,4 @@
1
1
  module Danger
2
- VERSION = "8.4.2".freeze
2
+ VERSION = "9.2.0".freeze
3
3
  DESCRIPTION = "Like Unit Tests, but for your Team Culture.".freeze
4
4
  end
data/lib/danger.rb CHANGED
@@ -25,6 +25,7 @@ module Danger
25
25
  if Gem::Specification.find_all_by_name(GEM_NAME).empty?
26
26
  raise "Couldn't find gem directory for 'danger'"
27
27
  end
28
+
28
29
  return Gem::Specification.find_by_name(GEM_NAME).gem_dir
29
30
  end
30
31
 
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: 8.4.2
4
+ version: 9.2.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: 2021-11-10 00:00:00.000000000 Z
12
+ date: 2023-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: claide
@@ -40,33 +40,33 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.9.2
42
42
  - !ruby/object:Gem::Dependency
43
- name: git
43
+ name: colored2
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.7'
48
+ version: '3.1'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.7'
55
+ version: '3.1'
56
56
  - !ruby/object:Gem::Dependency
57
- name: colored2
57
+ name: cork
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '3.1'
62
+ version: '0.1'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '3.1'
69
+ version: '0.1'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: faraday
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.9.0
77
77
  - - "<"
78
78
  - !ruby/object:Gem::Version
79
- version: '2.0'
79
+ version: '3.0'
80
80
  type: :runtime
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
@@ -86,7 +86,7 @@ dependencies:
86
86
  version: 0.9.0
87
87
  - - "<"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.0'
89
+ version: '3.0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: faraday-http-cache
92
92
  requirement: !ruby/object:Gem::Requirement
@@ -102,95 +102,95 @@ dependencies:
102
102
  - !ruby/object:Gem::Version
103
103
  version: '2.0'
104
104
  - !ruby/object:Gem::Dependency
105
- name: kramdown
105
+ name: git
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.3'
110
+ version: '1.7'
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: '2.3'
117
+ version: '1.7'
118
118
  - !ruby/object:Gem::Dependency
119
- name: kramdown-parser-gfm
119
+ name: kramdown
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.0'
124
+ version: '2.3'
125
125
  type: :runtime
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.0'
131
+ version: '2.3'
132
132
  - !ruby/object:Gem::Dependency
133
- name: octokit
133
+ name: kramdown-parser-gfm
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '4.7'
138
+ version: '1.0'
139
139
  type: :runtime
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '4.7'
145
+ version: '1.0'
146
146
  - !ruby/object:Gem::Dependency
147
- name: terminal-table
147
+ name: no_proxy_fix
148
148
  requirement: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '1'
153
- - - "<"
154
- - !ruby/object:Gem::Version
155
- version: '4'
152
+ version: '0'
156
153
  type: :runtime
157
154
  prerelease: false
158
155
  version_requirements: !ruby/object:Gem::Requirement
159
156
  requirements:
160
157
  - - ">="
161
158
  - !ruby/object:Gem::Version
162
- version: '1'
163
- - - "<"
164
- - !ruby/object:Gem::Version
165
- version: '4'
159
+ version: '0'
166
160
  - !ruby/object:Gem::Dependency
167
- name: cork
161
+ name: octokit
168
162
  requirement: !ruby/object:Gem::Requirement
169
163
  requirements:
170
164
  - - "~>"
171
165
  - !ruby/object:Gem::Version
172
- version: '0.1'
166
+ version: '5.0'
173
167
  type: :runtime
174
168
  prerelease: false
175
169
  version_requirements: !ruby/object:Gem::Requirement
176
170
  requirements:
177
171
  - - "~>"
178
172
  - !ruby/object:Gem::Version
179
- version: '0.1'
173
+ version: '5.0'
180
174
  - !ruby/object:Gem::Dependency
181
- name: no_proxy_fix
175
+ name: terminal-table
182
176
  requirement: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - ">="
185
179
  - !ruby/object:Gem::Version
186
- version: '0'
180
+ version: '1'
181
+ - - "<"
182
+ - !ruby/object:Gem::Version
183
+ version: '4'
187
184
  type: :runtime
188
185
  prerelease: false
189
186
  version_requirements: !ruby/object:Gem::Requirement
190
187
  requirements:
191
188
  - - ">="
192
189
  - !ruby/object:Gem::Version
193
- version: '0'
190
+ version: '1'
191
+ - - "<"
192
+ - !ruby/object:Gem::Version
193
+ version: '4'
194
194
  description: Stop Saying 'You Forgot To…' in Code Review
195
195
  email:
196
196
  - orta.therox@gmail.com
@@ -206,6 +206,7 @@ files:
206
206
  - lib/assets/DangerfileTemplate
207
207
  - lib/danger.rb
208
208
  - lib/danger/ci_source/appcenter.rb
209
+ - lib/danger/ci_source/appcircle.rb
209
210
  - lib/danger/ci_source/appveyor.rb
210
211
  - lib/danger/ci_source/azure_pipelines.rb
211
212
  - lib/danger/ci_source/bamboo.rb
@@ -243,7 +244,6 @@ files:
243
244
  - lib/danger/ci_source/surf.rb
244
245
  - lib/danger/ci_source/teamcity.rb
245
246
  - lib/danger/ci_source/travis.rb
246
- - lib/danger/ci_source/vsts.rb
247
247
  - lib/danger/ci_source/xcode_cloud.rb
248
248
  - lib/danger/ci_source/xcode_server.rb
249
249
  - lib/danger/clients/rubygems_client.rb
@@ -271,6 +271,7 @@ files:
271
271
  - lib/danger/comment_generators/gitlab.md.erb
272
272
  - lib/danger/comment_generators/gitlab_inline.md.erb
273
273
  - lib/danger/comment_generators/vsts.md.erb
274
+ - lib/danger/comment_generators/vsts_inline.md.erb
274
275
  - lib/danger/core_ext/file_list.rb
275
276
  - lib/danger/core_ext/string.rb
276
277
  - lib/danger/danger_core/dangerfile.rb
@@ -335,14 +336,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
335
336
  requirements:
336
337
  - - ">="
337
338
  - !ruby/object:Gem::Version
338
- version: 2.4.0
339
+ version: 2.7.0
339
340
  required_rubygems_version: !ruby/object:Gem::Requirement
340
341
  requirements:
341
342
  - - ">="
342
343
  - !ruby/object:Gem::Version
343
344
  version: '0'
344
345
  requirements: []
345
- rubygems_version: 3.1.2
346
+ rubyforge_project:
347
+ rubygems_version: 2.7.6.2
346
348
  signing_key:
347
349
  specification_version: 4
348
350
  summary: Like Unit Tests, but for your Team Culture.
@@ -1,73 +0,0 @@
1
- require "danger/request_sources/github/github"
2
- require "danger/request_sources/vsts"
3
-
4
- module Danger
5
- # ### CI Setup
6
- #
7
- # You need to go to your project's build definition. Then add a "Command Line" Task with the "Tool" field set to "bundle"
8
- # and the "Arguments" field set to "exec danger".
9
- #
10
- # ### Token Setup
11
- #
12
- # #### GitHub
13
- #
14
- # You need to add the `DANGER_GITHUB_API_TOKEN` environment variable, to do this, go to your build definition's variables tab.
15
- #
16
- # Make sure that `DANGER_GITHUB_API_TOKEN` is not set to secret since vsts does not expose secret variables while building.
17
- #
18
- # #### VSTS
19
- #
20
- # You need to add the `DANGER_VSTS_API_TOKEN` and `DANGER_VSTS_HOST` environment variable, to do this,
21
- # go to your build definition's variables tab. The `DANGER_VSTS_API_TOKEN` is your vsts personal access token.
22
- # Instructions for creating a personal access token can be found [here](https://www.visualstudio.com/en-us/docs/setup-admin/team-services/use-personal-access-tokens-to-authenticate).
23
- # For the `DANGER_VSTS_HOST` variable the suggested value is `$(System.TeamFoundationCollectionUri)$(System.TeamProject)`
24
- # which will automatically get your vsts domain and your project name needed for the vsts api.
25
- #
26
- # Make sure that `DANGER_VSTS_API_TOKEN` is not set to secret since vsts does not expose secret variables while building.
27
- #
28
- class VSTS < CI
29
- class << self
30
- def github_slug(env)
31
- env["BUILD_REPOSITORY_NAME"]
32
- end
33
-
34
- def vsts_slug(env)
35
- project_name = env["SYSTEM_TEAMPROJECT"]
36
- repo_name = env["BUILD_REPOSITORY_NAME"]
37
-
38
- "#{project_name}/#{repo_name}"
39
- end
40
- end
41
-
42
- def self.validates_as_ci?(env)
43
- has_all_variables = ["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "BUILD_REPOSITORY_PROVIDER"].all? { |x| env[x] && !env[x].empty? }
44
-
45
- is_support_source_control = ["GitHub", "TfsGit"].include?(env["BUILD_REPOSITORY_PROVIDER"])
46
-
47
- has_all_variables && is_support_source_control
48
- end
49
-
50
- def self.validates_as_pr?(env)
51
- has_all_variables = ["BUILD_SOURCEBRANCH", "BUILD_REPOSITORY_URI", "BUILD_REASON", "BUILD_REPOSITORY_NAME"].all? { |x| env[x] && !env[x].empty? }
52
-
53
- has_all_variables && env["BUILD_REASON"] == "PullRequest"
54
- end
55
-
56
- def supported_request_sources
57
- @supported_request_sources ||= [Danger::RequestSources::GitHub, Danger::RequestSources::VSTS]
58
- end
59
-
60
- def initialize(env)
61
- case env["BUILD_REPOSITORY_PROVIDER"]
62
- when "GitHub"
63
- self.repo_slug = self.class.github_slug(env)
64
- when "TfsGit"
65
- self.repo_slug = self.class.vsts_slug(env)
66
- end
67
-
68
- repo_matches = env["BUILD_SOURCEBRANCH"].match(%r{refs\/pull\/([0-9]+)\/merge})
69
- self.pull_request_id = repo_matches[1] unless repo_matches.nil?
70
- self.repo_url = env["BUILD_REPOSITORY_URI"]
71
- end
72
- end
73
- end