danger-dangermattic 1.0.0 → 1.0.2

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
  SHA256:
3
- metadata.gz: e85f01a1d938e27470bb45e542e181b976500f6ecd7753f02536e778af12b370
4
- data.tar.gz: 79ec4d88e1bb27c40a72be9b19a70a2a3200aa2eb7a68a7433849550d31f11bf
3
+ metadata.gz: 71795650c10fd356f78fc2869d6b7bf2b00ccd7869e2d028f96d8544d08f36af
4
+ data.tar.gz: a977dc6bd64a8bc05c5c2ef5260ae38f72f89e4c982261676895ce1ce2bcc1ec
5
5
  SHA512:
6
- metadata.gz: a681ba5b47937b6fe5ab6abd568954f8b5e26570e75385a9a3fa719ea6420c7bcd4dd216c90a9a431755270beec609183f161bd6a7ccf4f502af6d31793c1120
7
- data.tar.gz: a3542e84de8347a75760d8501aeac783305e5ff3c665d1209a706100c889aeb0afa959f4b80e66d166fd9c4f881c373f24155333a0a6bf27817b84ecb6b1ceac
6
+ metadata.gz: 59c20e0c9156972b46ec07ce038805619fbd55f0772dd270820860ab221f4ef2f1e35fad58dd8f8e27e28d70e2b83eeff700983415a49b75337932b7f2923aa9
7
+ data.tar.gz: 432b33e4ad2e9ebc7ac7ad03476d4f07ded20456ea57ffb6554184d162d2acbfedcf0b703e50330de6629de33274b161e19c3d6006ae4cfad5dc0b6e47755d2e
@@ -34,13 +34,13 @@ jobs:
34
34
  - name: "☢️ Danger PR Check"
35
35
  env:
36
36
  PR_URL: ${{ github.event.pull_request.html_url }}
37
- RUNNING_ON_FORK: ${{ github.event.pull_request.head.repo.fork }}
37
+ READ_ONLY_MODE: ${{ github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]' }}
38
38
  REMOVE_PREVIOUS_COMMENTS: ${{ inputs.remove-previous-comments }}
39
- DANGER_GITHUB_API_TOKEN: ${{ secrets.github-token }}
39
+ DANGER_GITHUB_API_TOKEN: ${{ secrets.github-token || secrets.GITHUB_TOKEN }}
40
40
  run: |
41
41
  echo "--- 🏃 Running Danger: PR Check"
42
42
 
43
- if [ "$RUNNING_ON_FORK" = true ]; then
43
+ if [ "$READ_ONLY_MODE" = true ]; then
44
44
  danger_output=$(bundle exec danger pr "$PR_URL" --verbose)
45
45
 
46
46
  echo "$danger_output"
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ---
4
4
 
5
+ ## 1.0.2
6
+
7
+ ### Bug Fixes
8
+
9
+ - Clean up and update dependencies. (#62)
10
+
11
+ ## 1.0.1
12
+
13
+ ### Bug Fixes
14
+
15
+ - Fix `tracks_checker` plugin so that only additions / removals in a diff are considered in the check, therefore not including the context parts of the diff. (#58)
16
+
5
17
  ## 1.0.0
6
18
 
7
- After some time being developed and tested across a few repositories, this is our first stable release.
19
+ - After some time being developed and tested across a few repositories, this is our first stable release.
data/Gemfile.lock CHANGED
@@ -1,14 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-dangermattic (0.0.1)
4
+ danger-dangermattic (1.0.2)
5
5
  danger (~> 9.4)
6
- danger-junit (~> 1.0)
7
6
  danger-plugin-api (~> 1.0)
8
7
  danger-rubocop (~> 0.12)
9
- danger-swiftlint (~> 0.35)
10
- danger-xcode_summary (~> 1.0)
11
- rubocop (~> 1.60)
8
+ rubocop (~> 1.61)
12
9
 
13
10
  GEM
14
11
  remote: https://rubygems.org/
@@ -39,21 +36,11 @@ GEM
39
36
  no_proxy_fix
40
37
  octokit (>= 4.0)
41
38
  terminal-table (>= 1, < 4)
42
- danger-junit (1.0.2)
43
- danger (> 2.0)
44
- ox (~> 2.0)
45
39
  danger-plugin-api (1.0.0)
46
40
  danger (> 2.0)
47
41
  danger-rubocop (0.12.0)
48
42
  danger
49
43
  rubocop (~> 1.0)
50
- danger-swiftlint (0.35.0)
51
- danger
52
- rake (> 10)
53
- thor (~> 1.0.0)
54
- danger-xcode_summary (1.2.0)
55
- danger-plugin-api (~> 1.0)
56
- xcresult (~> 0.2)
57
44
  diff-lcs (1.5.1)
58
45
  faraday (2.9.0)
59
46
  faraday-net_http (>= 2.0, < 3.2)
@@ -86,7 +73,7 @@ GEM
86
73
  kramdown-parser-gfm (1.1.0)
87
74
  kramdown (~> 2.0)
88
75
  language_server-protocol (3.17.0.3)
89
- listen (3.8.0)
76
+ listen (3.9.0)
90
77
  rb-fsevent (~> 0.10, >= 0.10.3)
91
78
  rb-inotify (~> 0.9, >= 0.9.10)
92
79
  lumberjack (1.2.10)
@@ -104,7 +91,6 @@ GEM
104
91
  faraday (>= 1, < 3)
105
92
  sawyer (~> 0.9)
106
93
  open4 (1.3.4)
107
- ox (2.14.17)
108
94
  parallel (1.24.0)
109
95
  parser (3.3.0.5)
110
96
  ast (~> 2.4.1)
@@ -134,8 +120,8 @@ GEM
134
120
  rspec-mocks (3.13.0)
135
121
  diff-lcs (>= 1.2.0, < 2.0)
136
122
  rspec-support (~> 3.13.0)
137
- rspec-support (3.13.0)
138
- rubocop (1.60.2)
123
+ rspec-support (3.13.1)
124
+ rubocop (1.61.0)
139
125
  json (~> 2.3)
140
126
  language_server-protocol (>= 3.17.0)
141
127
  parallel (~> 1.10)
@@ -146,15 +132,15 @@ GEM
146
132
  rubocop-ast (>= 1.30.0, < 2.0)
147
133
  ruby-progressbar (~> 1.7)
148
134
  unicode-display_width (>= 2.4.0, < 3.0)
149
- rubocop-ast (1.30.0)
150
- parser (>= 3.2.1.0)
135
+ rubocop-ast (1.31.1)
136
+ parser (>= 3.3.0.4)
151
137
  rubocop-capybara (2.20.0)
152
138
  rubocop (~> 1.41)
153
139
  rubocop-factory_bot (2.25.1)
154
140
  rubocop (~> 1.41)
155
141
  rubocop-rake (0.6.0)
156
142
  rubocop (~> 1.0)
157
- rubocop-rspec (2.26.1)
143
+ rubocop-rspec (2.27.1)
158
144
  rubocop (~> 1.40)
159
145
  rubocop-capybara (~> 2.17)
160
146
  rubocop-factory_bot (~> 2.22)
@@ -165,11 +151,10 @@ GEM
165
151
  shellany (0.0.1)
166
152
  terminal-table (3.0.2)
167
153
  unicode-display_width (>= 1.1.1, < 3)
168
- thor (1.0.1)
154
+ thor (1.3.1)
169
155
  unicode-display_width (2.5.0)
170
156
  uri (0.13.0)
171
- xcresult (0.2.1)
172
- yard (0.9.34)
157
+ yard (0.9.36)
173
158
 
174
159
  PLATFORMS
175
160
  arm64-darwin-22
@@ -25,10 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
26
26
 
27
27
  # Danger plugins
28
- spec.add_dependency 'danger-junit', '~> 1.0'
29
28
  spec.add_dependency 'danger-rubocop', '~> 0.12'
30
- spec.add_dependency 'danger-swiftlint', '~> 0.35'
31
- spec.add_dependency 'danger-xcode_summary', '~> 1.0'
32
29
 
33
30
  # General ruby development
34
31
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -38,7 +35,7 @@ Gem::Specification.new do |spec|
38
35
  spec.add_development_dependency 'rspec', '~> 3.4'
39
36
 
40
37
  # Linting code and docs
41
- spec.add_dependency 'rubocop', '~> 1.60'
38
+ spec.add_dependency 'rubocop', '~> 1.61'
42
39
  spec.add_development_dependency 'rubocop-rake'
43
40
  spec.add_development_dependency 'rubocop-rspec'
44
41
  spec.add_development_dependency 'yard'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dangermattic
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.2'
5
5
  end
@@ -81,9 +81,11 @@ module Danger
81
81
  #
82
82
  # @param files [Array<String>] List of file names to check
83
83
  # @param line_matcher [Proc] A callable that takes a line and returns true if it matches the desired pattern
84
- # @param change_type [Symbol, nil] Change type to filter lines (e.g., :added, :removed) or nil for no filter
84
+ # @param change_type [Symbol, Array<Symbol>, nil] Change type(s) to filter lines (e.g., `:added`, `:removed`,
85
+ # `:context`, `[:added, :removed]`, …), or nil for no filter
85
86
  # @return [Array<MatchedData>] Array of MatchedData objects representing matched lines in files
86
87
  def matching_lines_in_diff_files(files:, line_matcher:, change_type: nil)
88
+ change_types = Array(change_type).map(&:to_sym)
87
89
  matched_data = []
88
90
 
89
91
  files.each do |file|
@@ -92,7 +94,7 @@ module Danger
92
94
  diff = danger.git.diff_for_file(file)
93
95
 
94
96
  diff.patch.each_line do |line|
95
- matched_lines << line if line_matcher.call(line) && (change_type.nil? || change_type(diff_line: line) == change_type)
97
+ matched_lines << line if line_matcher.call(line) && (change_type.nil? || change_types.include?(change_type(diff_line: line)))
96
98
  end
97
99
 
98
100
  matched_data << MatchedData.new(file, matched_lines) unless matched_lines.empty?
@@ -63,7 +63,7 @@ module Danger
63
63
  matched_lines = git_utils.matching_lines_in_diff_files(
64
64
  files: git_utils.all_changed_files,
65
65
  line_matcher: ->(line) { tracks_usage_matchers.any? { |tracks_usage_match| line.match(tracks_usage_match) } },
66
- change_type: nil
66
+ change_type: %i[added removed]
67
67
  )
68
68
 
69
69
  !matched_lines.empty?
@@ -68,7 +68,7 @@ module Danger
68
68
  it 'does nothing when there are no changes in Tracks-related files' do
69
69
  modified_files = ['MyClass.swift']
70
70
  allow(@plugin.git_utils).to receive(:all_changed_files).and_return(modified_files)
71
- allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: nil).and_return([])
71
+ allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: %i[added removed]).and_return([])
72
72
 
73
73
  @plugin.check_tracks_changes(tracks_files: track_files, tracks_usage_matchers: tracks_matchers, tracks_label: nil)
74
74
 
@@ -83,12 +83,7 @@ module Danger
83
83
  modified_files = ['MyClass.kt']
84
84
  allow(@plugin.git_utils).to receive(:all_changed_files).and_return(modified_files)
85
85
 
86
- allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: nil) do |args|
87
- analytics_call_in_diff = '- AnalyticsTracker.track("myEvent1")'
88
- expect(args[:line_matcher].call(analytics_call_in_diff)).to be true
89
-
90
- [analytics_call_in_diff]
91
- end
86
+ allow_diff_match(modified_files: modified_files, diff_line: '- AnalyticsTracker.track("myEvent1")', expect_match: true)
92
87
 
93
88
  @plugin.check_tracks_changes(tracks_files: track_files, tracks_usage_matchers: tracks_matchers, tracks_label: tracks_label)
94
89
 
@@ -99,12 +94,7 @@ module Danger
99
94
  modified_files = ['MyClass.kt']
100
95
  allow(@plugin.git_utils).to receive(:all_changed_files).and_return(modified_files)
101
96
 
102
- allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: nil) do |args|
103
- analytics_call_in_diff = '- AnalyticsTracker.track("evento")'
104
- expect(args[:line_matcher].call(analytics_call_in_diff)).to be true
105
-
106
- [analytics_call_in_diff]
107
- end
97
+ allow_diff_match(modified_files: modified_files, diff_line: '+ AnalyticsTracker.track("evento")', expect_match: true)
108
98
 
109
99
  @plugin.check_tracks_changes(tracks_files: track_files, tracks_usage_matchers: tracks_matchers, tracks_label: nil)
110
100
 
@@ -116,12 +106,7 @@ module Danger
116
106
  modified_files = ['MyClass.kt']
117
107
  allow(@plugin.git_utils).to receive(:all_changed_files).and_return(modified_files)
118
108
 
119
- allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: nil) do |args|
120
- analytics_call_in_diff = '- AnalyticsTracker.track("myEvent1")'
121
- expect(args[:line_matcher].call(analytics_call_in_diff)).to be true
122
-
123
- [analytics_call_in_diff]
124
- end
109
+ allow_diff_match(modified_files: modified_files, diff_line: '- AnalyticsTracker.track("evento")', expect_match: true)
125
110
 
126
111
  tracks_label = 'TRACKS PR'
127
112
  @plugin.check_tracks_changes(tracks_files: track_files, tracks_usage_matchers: tracks_matchers, tracks_label: tracks_label)
@@ -133,12 +118,34 @@ module Danger
133
118
  modified_files = ['MyClass.kt']
134
119
  allow(@plugin.git_utils).to receive(:all_changed_files).and_return(modified_files)
135
120
 
136
- allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: nil) do |args|
137
- analytics_call_in_diff = '+ AnalyticsHelper.log("event_1")'
138
- expect(args[:line_matcher].call(analytics_call_in_diff)).to be false
121
+ allow_diff_match(modified_files: modified_files, diff_line: '- AnalyticsHelper.log("event_1")', expect_match: false)
122
+
123
+ @plugin.check_tracks_changes(tracks_files: track_files, tracks_usage_matchers: tracks_matchers, tracks_label: nil)
124
+
125
+ expect(@dangerfile).to not_report
126
+ end
127
+
128
+ it 'does nothing when there are matching changes but in the context parts of the diff' do
129
+ modified_file = 'MyClass.kt'
130
+ allow(@plugin.git_utils).to receive(:all_changed_files).and_return([modified_file])
131
+
132
+ tracks_diff = <<~STRINGS
133
+ diff --git a/MyClass.kt b/MyClass.kt
134
+ index 5794d472..772e2b99 100644
135
+ - a/MyClass
136
+ + b/MyClass
137
+ @@ -1,3 +1,6 @@
138
+ AnalyticsTracker.track("myMagicEvent1")
139
+ // call magic
140
+ + AnalyticsHelper.log("event_1")
141
+ + AnalyticsHelper.log("event_2")
142
+ + AnotherUtil.callMagic()
143
+ AnalyticsTracker.track("myMagicEvent2")
144
+ STRINGS
139
145
 
140
- []
141
- end
146
+ diff = GitDiffStruct.new('modified', modified_file, tracks_diff)
147
+
148
+ allow(@plugin.git).to receive(:diff_for_file).with(modified_file).and_return(diff)
142
149
 
143
150
  @plugin.check_tracks_changes(tracks_files: track_files, tracks_usage_matchers: tracks_matchers, tracks_label: nil)
144
151
 
@@ -147,6 +154,17 @@ module Danger
147
154
  end
148
155
  end
149
156
 
157
+ def allow_diff_match(modified_files:, diff_line:, expect_match:)
158
+ allow(@plugin.git_utils).to receive(:matching_lines_in_diff_files).with(files: modified_files, line_matcher: kind_of(Proc), change_type: %i[added removed]) do |args|
159
+ expect(args[:line_matcher].call(diff_line)).to be expect_match
160
+
161
+ result = []
162
+ result.append(diff_line) if expect_match
163
+
164
+ result
165
+ end
166
+ end
167
+
150
168
  def expect_label_checks(tracks_label)
151
169
  expect(@dangerfile.status_report[:messages]).to eq [TracksChecker::TRACKS_PR_INSTRUCTIONS + format(TracksChecker::TRACKS_NO_LABEL_INSTRUCTION_FORMAT, tracks_label)]
152
170
  expect(@dangerfile.status_report[:errors]).to eq [format(TracksChecker::TRACKS_NO_LABEL_MESSAGE_FORMAT, tracks_label)]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-dangermattic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-08 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
- - !ruby/object:Gem::Dependency
42
- name: danger-junit
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: danger-rubocop
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,34 +52,6 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0.12'
69
- - !ruby/object:Gem::Dependency
70
- name: danger-swiftlint
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.35'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.35'
83
- - !ruby/object:Gem::Dependency
84
- name: danger-xcode_summary
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.0'
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: bundler
99
57
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +100,14 @@ dependencies:
142
100
  requirements:
143
101
  - - "~>"
144
102
  - !ruby/object:Gem::Version
145
- version: '1.60'
103
+ version: '1.61'
146
104
  type: :runtime
147
105
  prerelease: false
148
106
  version_requirements: !ruby/object:Gem::Requirement
149
107
  requirements:
150
108
  - - "~>"
151
109
  - !ruby/object:Gem::Version
152
- version: '1.60'
110
+ version: '1.61'
153
111
  - !ruby/object:Gem::Dependency
154
112
  name: rubocop-rake
155
113
  requirement: !ruby/object:Gem::Requirement