-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for .lintignore. #67
Conversation
315223a
to
504eccb
Compare
59fe2fb
to
9adc07e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a different approach than transforming the globs into regex. I've outlined one option in the specific comment. I would also accept simply making the .lintignore file actually regex in the first place.
Otherwise LGTM
@@ -171,6 +171,27 @@ lint_files() { | |||
exit $lint_result | |||
} | |||
|
|||
filter_out() { | |||
local globs="$1" | |||
if [ -n "$globs" -a -r "$globs" ]; then |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
while read -r filename; do | ||
# Remove comments. Remove empty lines. Expand directories (e.g. "bin/" -> "bin/.*"). And then regexify globs. | ||
# These regexes are then passed to grep to filter out matching elements from stdin: | ||
echo "${filename}" | tee -a "$files_in" | grep -vEf <(sed '/^#.*$/d ; /^\s*$/d ; s/^\(.*\/\)$/\1*/g ; s/\([.|]\)/\\\1/g ; s/\?/./g ; s/\*/.*/g ; s/\(.*\)/\^\1\$/g' "$globs") | tee -a "$files_out" |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
rm -f "$files_in" "$files_out" | ||
else | ||
# No globs blacklist was provided: simply propagate stdin to stdout: | ||
while read -r filename; do echo "${filename}"; done |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
8b15aee
to
d9f6532
Compare
@ekimekim: I've made a few changes following your first review:
It should be simpler overall, or at least more readable, but I wouldn't mind a second pass from your end. |
d9f6532
to
003bbd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits (and it looks like a mid-review change might have eaten some?) but one important thing to fix.
filter_out() { | ||
local patterns="$1" | ||
if [ -n "$patterns" ] && [ -r "$patterns" ]; then | ||
local patterns=$(sed '/^#.*$/d ; /^\s*$/d' $patterns) # Remove blank lines and comments before we start iterating. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
[ -n "$DEBUG" ] && echo >&2 "> Filters:" && echo >&2 "$patterns" | ||
local filtered_out=() | ||
while read -r filename; do | ||
matches_any "$filename" "$patterns" && filtered_out+=("$filename") || echo "$filename" |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
local patterns="$2" | ||
IFS=$'\n' # Make newlines the only separator. | ||
set -f # Disable globbing so $patterns can be treated as is. | ||
for pattern in $patterns; do |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Yes, just force-pushed |
Lint-ing all of Weave Net is currently not desirable because: * it would create conflicts on many branches, * it would pollute the git history, * etc. and because `lint` currently lints all files except `./vendor`, this breaks Weave Net's build. As a result, Weave Net is not using the latest commit in `build-tools`'s `master` branch, which is also source of problems: * it limits standardisation of projects across Weaveworks, * it limits the ability to use the latest features of `build-tools`, * it complexifies merging changes in `build-tools` (e.g. #53 and weaveworks/weave#2694 for weaveworks/weave#2647), * etc. This change adds the ability to optionally process a `.lintignore` file, which can contain any number of `GLOB`s then used to filter out files one does not want to lint, a-la `.gitignore`. This, coupled with a `.lintignore` file in Weave Net will then enable Weave Net to use the latest version of `build-tools`.
003bbd9
to
a59884f
Compare
Lint-ing all of Weave Net is currently not desirable because:
and because
lint
currently lints all files except./vendor
, this breaks Weave Net's build.As a result, Weave Net is not using the latest commit in
build-tools
'smaster
branch, which is also source of problems:build-tools
,build-tools
(e.g. Testing MVP #53 and Testing MVP weave#2694 for Epic - Improve development & testing infrastructure weave#2647),This change adds the ability to optionally process a
.lintignore
file, which can contain any number ofGLOB
s then used to filter out files one does not want to lint, a-la.gitignore
.This, coupled with a
.lintignore
file in Weave Net will then enable Weave Net to use the latest version ofbuild-tools
.