Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 3ddeb5b

Browse files
author
Alex Ausch
committed
ability to ignore a list of directories/files
1 parent 34d738e commit 3ddeb5b

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

gitlint/__init__.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@
2222
among others. See https://github.com/sk-/git-lint for the complete list.
2323
2424
Usage:
25-
git-lint [-f | --force] [--json] [--last-commit] [FILENAME ...]
25+
git-lint [-f | --force] [--json] [--last-commit] [--ignore=<fn>] [FILENAME ...]
2626
git-lint [-t | --tracked] [-f | --force] [--json] [--last-commit]
2727
git-lint -h | --version
2828
2929
Options:
30-
-h Show the usage patterns.
31-
--version Prints the version number.
32-
-f --force Shows all the lines with problems.
33-
-t --tracked Lints only tracked files.
34-
--json Prints the result as a json string. Useful to use it in
35-
conjunction with other tools.
36-
--last-commit Checks the last checked-out commit. This is mostly useful
37-
when used as: git checkout <revid>; git lint --last-commit.
30+
-h Show the usage patterns.
31+
--ignore=<files> List of files to ignore
32+
--version Prints the version number.
33+
-f --force Shows all the lines with problems.
34+
-t --tracked Lints only tracked files.
35+
--json Prints the result as a json string. Useful to use it in
36+
conjunction with other tools.
37+
--last-commit Checks the last checked-out commit. This is mostly useful
38+
when used as: git checkout <revid>; git lint --last-commit.
3839
"""
3940

4041
from __future__ import unicode_literals
@@ -190,6 +191,10 @@ def main(argv, stdout=sys.stdout, stderr=sys.stderr):
190191
if arguments['--last-commit']:
191192
commit = vcs.last_commit()
192193

194+
ignore_paths = ()
195+
if arguments['--ignore']:
196+
ignore_paths = tuple(arguments['--ignore'].split(','))
197+
193198
if arguments['FILENAME']:
194199
invalid_filenames = find_invalid_filenames(arguments['FILENAME'],
195200
repository_root)
@@ -217,7 +222,10 @@ def main(argv, stdout=sys.stdout, stderr=sys.stderr):
217222
gitlint_config = get_config(repository_root)
218223
json_result = {}
219224

220-
for filename in sorted(modified_files.keys()):
225+
target_filenames = modified_files.keys() if len(ignore_paths) < 1
226+
else [x for x in modified_files.keys()
227+
if not os.path.relpath(x).startswith(ignore_paths)]
228+
for filename in sorted(target_filenames):
221229
rel_filename = os.path.relpath(filename)
222230
if not json_output:
223231
stdout.write('Linting file: %s%s' %

0 commit comments

Comments
 (0)