summaryrefslogtreecommitdiff
path: root/.gitlab/linters
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-03 12:02:15 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-29 03:46:59 -0400
commit28e527327753ec9971a98ac19e050d9b0664bc40 (patch)
treecec30cd992a87ef8a23098a35bdf1185fd254e79 /.gitlab/linters
parent57dc1565e98d7777c5b2783f947ff6dace311ece (diff)
downloadhaskell-28e527327753ec9971a98ac19e050d9b0664bc40.tar.gz
linters: Add mode to lint given set of files
This makes testing much easier.
Diffstat (limited to '.gitlab/linters')
-rw-r--r--.gitlab/linters/linter.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/.gitlab/linters/linter.py b/.gitlab/linters/linter.py
index 12071ac164..61fe18de33 100644
--- a/.gitlab/linters/linter.py
+++ b/.gitlab/linters/linter.py
@@ -98,11 +98,22 @@ def run_linters(linters: Sequence[Linter],
subdir: str = '.') -> None:
import argparse
parser = argparse.ArgumentParser()
- parser.add_argument('base', help='Base commit')
- parser.add_argument('head', help='Head commit')
+ subparsers = parser.add_subparsers()
+
+ subparser = subparsers.add_parser('commits', help='Lint a range of commits')
+ subparser.add_argument('base', help='Base commit')
+ subparser.add_argument('head', help='Head commit')
+ subparser.set_defaults(get_linted_files=lambda args:
+ get_changed_files(args.base, args.head, subdir))
+
+ subparser = subparsers.add_parser('files', help='Lint a range of commits')
+ subparser.add_argument('file', nargs='+', help='File to lint')
+ subparser.set_defaults(get_linted_files=lambda args: args.file)
+
args = parser.parse_args()
- for path in get_changed_files(args.base, args.head, subdir):
+ linted_files = args.get_linted_files(args)
+ for path in linted_files:
if path.startswith('.gitlab/linters'):
continue
for linter in linters: