Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
5adf8cbe
Unverified
Commit
5adf8cbe
authored
4 years ago
by
Kenneth Chew
Browse files
Options
Downloads
Patches
Plain Diff
audit: add additional (in)valid empty files, refactor empty file check
parent
844e8653
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/formula_cellar_checks.rb
+18
-17
18 additions, 17 deletions
Library/Homebrew/formula_cellar_checks.rb
with
18 additions
and
17 deletions
Library/Homebrew/formula_cellar_checks.rb
+
18
−
17
View file @
5adf8cbe
...
...
@@ -275,42 +275,43 @@ module FormulaCellarChecks
"Python formulae that are keg-only should not create `pip3` and `wheel3` symlinks."
end
INVALID_EMPTY_FILE_NAMES
=
%w[AUTHORS ChangeLog changes COPYING NEWS README TODO]
.
freeze
INVALID_EMPTY_FILE_NAMES
=
%w[AUTHORS ChangeLog changes COPYING
LICENSE
NEWS README TODO]
.
freeze
INVALID_EMPTY_FILE_EXTENSIONS
=
%w[.html .md .rst .txt]
.
freeze
INVALID_EMPTY_FILE_
LOCATION
S
=
%w[bin libexec share/man share/doc]
.
freeze
INVALID_EMPTY_FILE_
DIRECTORIE
S
=
%w[bin libexec share/man share/doc]
.
freeze
# Names and extensions to ignore, even if they are in a location within prefix given above
VALID_EMPTY_FILE_NAMES
=
%w[__init__
.p
y REQUESTED]
.
freeze
VALID_EMPTY_FILE_EXTENSIONS
=
%w[.
stamp
]
.
freeze
VALID_EMPTY_FILE_NAMES
=
%w[__init__
empt
y REQUESTED]
.
freeze
VALID_EMPTY_FILE_EXTENSIONS
=
%w[.
gitkeep .keep .keepme .stamp .typed
]
.
freeze
def
check_empty_files
(
prefix
)
return
unless
prefix
.
directory?
empty_files
=
[]
prefix
.
children
.
each
do
|
f
|
next
if
INVALID_EMPTY_FILE_NAMES
.
none?
(
File
.
basename
(
f
))
&&
INVALID_EMPTY_FILE_EXTENSIONS
.
none?
(
File
.
extname
(
f
))
empty_files
=
prefix
.
children
.
select
do
|
f
|
next
if
INVALID_EMPTY_FILE_NAMES
.
exclude?
(
f
.
basename
(
".*"
).
to_s
)
&&
INVALID_EMPTY_FILE_EXTENSIONS
.
exclude?
(
f
.
extname
)
next
unless
File
.
zero?
(
f
)
empty_files
<<
f
true
end
INVALID_EMPTY_FILE_LOCATIONS
.
each
do
|
loc
|
next
unless
(
prefix
/
loc
).
directory?
INVALID_EMPTY_FILE_DIRECTORIES
.
each
do
|
dir
|
path
=
prefix
/
dir
next
unless
path
.
directory?
# search all directories in INVALID_EMPTY_FILE_LOCATIONS and their subdirectories
Dir
.
glob
(
prefix
/
loc
/
"**/*"
).
each
do
|
f
|
next
if
VALID_EMPTY_FILE_NAMES
.
any?
(
File
.
basename
(
f
))
||
VALID_EMPTY_FILE_EXTENSIONS
.
any?
(
File
.
extname
(
f
))
next
unless
File
.
zero?
(
f
)
Pathname
.
glob
(
path
/
"**/*"
).
each
do
|
p
|
# Any files in the "valid" list should be skipped because they are expected to be empty
next
if
VALID_EMPTY_FILE_NAMES
.
include?
(
p
.
basename
(
".*"
).
to_s
)
next
if
VALID_EMPTY_FILE_EXTENSIONS
.
include?
(
p
.
extname
)
next
unless
File
.
zero?
(
p
)
empty_files
<<
f
empty_files
<<
p
end
end
return
if
empty_files
.
empty?
<<~
EOS
Suspicious
empty files were installed.
Unexpected
empty files were installed.
The offending files are:
#{
empty_files
*
"
\n
"
}
EOS
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment