danger-missing_codeowners 1.0.3 → 1.2.0

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: c96c6f07f74d912ae60feb08a802ebd4a1aa7807ece970520614c77a5847ec13
4
- data.tar.gz: a872b00996c8a7c42e3d73c648fb792a3e22acadb340cc53ff8865f54d43408c
3
+ metadata.gz: fcd83e0d8b50b255205c5ecfbceed72c29db635c92fc27d2f2b9420b6ba5a8a6
4
+ data.tar.gz: 43a2e6402320a69e456f6c19524c8388b2be03195bf25656157fea8840069f66
5
5
  SHA512:
6
- metadata.gz: 0ee3995c868961f7431b131748fe39e2b4f24689dd1fe1563e3de74bb33a6bb512fbc0a955029083933ae664193022f929dfc3040c9a8447a5affe62940a1388
7
- data.tar.gz: 52a36f59123b2ff15bc68af51a2f2bd93efab45c6f4c3d7e25f525cab493b326db3e8f7886c3690a4e1d4677a415b825f28524cdc4a93ac5bfccf55240515961
6
+ metadata.gz: fac672eff7a5197a07065fcfd8ab2c5b7546d4ed33071e2a6d4e00fa6366f8579d9e4fd9af726ba03ac8776c571af6bc02c8d624c24a3ed5792102567821cc97
7
+ data.tar.gz: b82d354dcc331dc13abb1958374edb8dc72c55a71eb056bd8f1a4f846682101167a17fdb1af9c6576aea3a3d412e357b23c218beb5fad7797e3367865a7c99c2
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-missing_codeowners (1.0.3)
4
+ danger-missing_codeowners (1.2.0)
5
5
  danger-plugin-api (~> 1.0)
6
6
  pathspec (~> 1.0.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.0)
12
- public_suffix (>= 2.0.2, < 5.0)
11
+ addressable (2.8.4)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
13
  ast (2.4.2)
14
- claide (1.0.3)
14
+ claide (1.1.0)
15
15
  claide-plugins (0.9.2)
16
16
  cork
17
17
  nap
@@ -20,46 +20,32 @@ GEM
20
20
  colored2 (3.1.2)
21
21
  cork (0.3.0)
22
22
  colored2 (~> 3.1)
23
- danger (8.4.2)
23
+ danger (9.3.0)
24
24
  claide (~> 1.0)
25
25
  claide-plugins (>= 0.9.2)
26
26
  colored2 (~> 3.1)
27
27
  cork (~> 0.1)
28
- faraday (>= 0.9.0, < 2.0)
28
+ faraday (>= 0.9.0, < 3.0)
29
29
  faraday-http-cache (~> 2.0)
30
- git (~> 1.7)
30
+ git (~> 1.13.0)
31
31
  kramdown (~> 2.3)
32
32
  kramdown-parser-gfm (~> 1.0)
33
33
  no_proxy_fix
34
- octokit (~> 4.7)
34
+ octokit (~> 5.0)
35
35
  terminal-table (>= 1, < 4)
36
36
  danger-plugin-api (1.0.0)
37
37
  danger (> 2.0)
38
38
  diff-lcs (1.4.4)
39
- faraday (1.8.0)
40
- faraday-em_http (~> 1.0)
41
- faraday-em_synchrony (~> 1.0)
42
- faraday-excon (~> 1.1)
43
- faraday-httpclient (~> 1.0.1)
44
- faraday-net_http (~> 1.0)
45
- faraday-net_http_persistent (~> 1.1)
46
- faraday-patron (~> 1.0)
47
- faraday-rack (~> 1.0)
48
- multipart-post (>= 1.2, < 3)
39
+ faraday (2.7.5)
40
+ faraday-net_http (>= 2.0, < 3.1)
49
41
  ruby2_keywords (>= 0.0.4)
50
- faraday-em_http (1.0.0)
51
- faraday-em_synchrony (1.0.0)
52
- faraday-excon (1.1.0)
53
- faraday-http-cache (2.2.0)
42
+ faraday-http-cache (2.5.0)
54
43
  faraday (>= 0.8)
55
- faraday-httpclient (1.0.1)
56
- faraday-net_http (1.0.1)
57
- faraday-net_http_persistent (1.2.0)
58
- faraday-patron (1.0.0)
59
- faraday-rack (1.0.0)
44
+ faraday-net_http (3.0.2)
60
45
  ffi (1.15.3)
61
46
  formatador (0.3.0)
62
- git (1.9.1)
47
+ git (1.13.2)
48
+ addressable (~> 2.8)
63
49
  rchardet (~> 1.8)
64
50
  guard (2.18.0)
65
51
  formatador (>= 0.2.4)
@@ -75,7 +61,7 @@ GEM
75
61
  guard (~> 2.1)
76
62
  guard-compat (~> 1.1)
77
63
  rspec (>= 2.99.0, < 4.0)
78
- kramdown (2.3.1)
64
+ kramdown (2.4.0)
79
65
  rexml
80
66
  kramdown-parser-gfm (1.1.0)
81
67
  kramdown (~> 2.0)
@@ -84,16 +70,15 @@ GEM
84
70
  rb-inotify (>= 0.9.7)
85
71
  lumberjack (1.2.8)
86
72
  method_source (1.0.0)
87
- multipart-post (2.1.1)
88
73
  nap (1.1.0)
89
74
  nenv (0.3.0)
90
75
  no_proxy_fix (0.1.2)
91
76
  notiffany (0.1.3)
92
77
  nenv (~> 0.1)
93
78
  shellany (~> 0.0)
94
- octokit (4.21.0)
95
- faraday (>= 0.9)
96
- sawyer (~> 0.8.0, >= 0.5.3)
79
+ octokit (5.6.1)
80
+ faraday (>= 1, < 3)
81
+ sawyer (~> 0.9)
97
82
  open4 (1.3.4)
98
83
  parallel (1.20.1)
99
84
  parser (3.0.2.0)
@@ -102,7 +87,7 @@ GEM
102
87
  pry (0.14.1)
103
88
  coderay (~> 1.1)
104
89
  method_source (~> 1.0)
105
- public_suffix (4.0.6)
90
+ public_suffix (5.0.1)
106
91
  rainbow (3.0.0)
107
92
  rake (10.5.0)
108
93
  rb-fsevent (0.11.0)
@@ -137,9 +122,9 @@ GEM
137
122
  parser (>= 3.0.1.1)
138
123
  ruby-progressbar (1.11.0)
139
124
  ruby2_keywords (0.0.5)
140
- sawyer (0.8.2)
125
+ sawyer (0.9.2)
141
126
  addressable (>= 2.3.5)
142
- faraday (> 0.8, < 2.0)
127
+ faraday (>= 0.17.3, < 3)
143
128
  shellany (0.0.1)
144
129
  terminal-table (3.0.2)
145
130
  unicode-display_width (>= 1.1.1, < 3)
@@ -148,6 +133,8 @@ GEM
148
133
  yard (0.9.26)
149
134
 
150
135
  PLATFORMS
136
+ arm64-darwin-21
137
+ ruby
151
138
  x86_64-darwin-20
152
139
 
153
140
  DEPENDENCIES
@@ -163,4 +150,4 @@ DEPENDENCIES
163
150
  yard
164
151
 
165
152
  BUNDLED WITH
166
- 2.2.28
153
+ 2.2.29
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MissingCodeowners
4
- VERSION = "1.0.3"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -40,6 +40,12 @@ module Danger
40
40
  # @return [Bool]
41
41
  attr_accessor :verbose
42
42
 
43
+ # The list of files to ignore. These are naive prefixes, so `foo/`
44
+ # will match `foo/bar`. No globbing.
45
+ #
46
+ # @return [Array<String>]
47
+ attr_accessor :ignored_files
48
+
43
49
  # Verifies files for missing owners.
44
50
  # Generates a `markdown` list of warnings for the prose in a corpus of
45
51
  # .markdown and .md files.
@@ -47,16 +53,23 @@ module Danger
47
53
  # @param [String] files
48
54
  # The list of files you want to verify, defaults to nil.
49
55
  # if nil, modified and added files from the diff will be used.
56
+ # @param [String] ignored_files
57
+ # The list of files you want to ignore, defaults to [].
58
+ # The files are treated as prefixes, so `foo/` will match `foo/bar`.
50
59
  #
51
60
  # @return [void]
52
61
  #
53
- def verify(files = nil)
62
+ def verify(*opts, &block)
54
63
  @verify_all_files ||= false
55
64
  @max_number_of_files_to_report ||= 100
56
65
  @severity ||= "error"
57
66
  @verbose ||= false
67
+ @ignored_files ||= opts.first.kind_of?(Hash) ? opts.first[:ignored_files] : []
68
+ files = opts.first.kind_of?(Hash) ? opts.first[:files] : opts.first
58
69
 
59
- files_to_verify = files || files_from_git
70
+ files_to_verify = (files || files_from_git).delete_if do |file|
71
+ @ignored_files.any? { |ignored_file| file.start_with?(ignored_file) }
72
+ end
60
73
 
61
74
  log "Files to verify:"
62
75
  log files_to_verify.join("\n")
@@ -73,8 +86,12 @@ module Danger
73
86
  markdown format_missing_owners_message(@files_missing_codeowners, @max_number_of_files_to_report)
74
87
  danger_message = "Add CODEOWNERS rules to match all files."
75
88
  @severity == "error" ? (fail danger_message) : (warn danger_message)
89
+
90
+ yield @files_missing_codeowners if block
76
91
  else
77
92
  log "No files missing CODEOWNERS."
93
+
94
+ yield [] if block
78
95
  end
79
96
 
80
97
  log "-----"
@@ -75,6 +75,26 @@ module Danger
75
75
  expect(@my_plugin.files_missing_codeowners.length).to eq(0)
76
76
  end
77
77
 
78
+ it "calls the block with an empty array if there are no missing files" do
79
+ allow(@my_plugin).to receive(:git_modified_files).and_return(["any_file.yml", "any_file.go"])
80
+
81
+ @my_plugin.verify do |x|
82
+ expect(x).to eq []
83
+ end
84
+
85
+ expect(@my_plugin.files_missing_codeowners.length).to eq(0)
86
+ end
87
+
88
+ it "calls the block with the list of missing files if there are missing files" do
89
+ allow(@my_plugin).to receive(:git_modified_files).and_return(["myfile"])
90
+
91
+ @my_plugin.verify do |x|
92
+ expect(x).to eq ["myfile"]
93
+ end
94
+
95
+ expect(@my_plugin.files_missing_codeowners.length).to eq(1)
96
+ end
97
+
78
98
  it "fails when there are files without CODEOWNERS rules and severity is error" do
79
99
  @my_plugin.verify_all_files = true
80
100
  allow(@my_plugin).to receive(:git_all_files).and_return(["app/source.swift", ".swiftlint.yml"])
@@ -155,6 +175,15 @@ module Danger
155
175
  expect(@my_plugin.files_missing_codeowners).to include("added_file2.swift")
156
176
  expect(@my_plugin.files_missing_codeowners.length).to eq(1)
157
177
  end
178
+
179
+ it "ignores explicitly ignored files" do
180
+ allow(@my_plugin).to receive(:git_modified_files).and_return(["ignored_file.swift", "added_file.swift"])
181
+
182
+ @my_plugin.verify(ignored_files: ["ignored_file.swift"])
183
+
184
+ expect(@my_plugin.files_missing_codeowners).to include("added_file.swift")
185
+ expect(@my_plugin.files_missing_codeowners.length).to eq(1)
186
+ end
158
187
  end
159
188
 
160
189
  context "and invalid CODEOWNERS file" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-missing_codeowners
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - andre-alves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-24 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  - !ruby/object:Gem::Version
210
210
  version: '0'
211
211
  requirements: []
212
- rubygems_version: 3.0.3
212
+ rubygems_version: 3.2.15
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: A Danger plugin for checking if files have owners.