Commit af71169b authored by intrigeri's avatar intrigeri
Browse files

lint_po: succeed if --cached was passed but no PO files were staged

When having "lint_po --cached" in one's pre-commit hook, any attempt
to create a commit that does not modify any PO file fails with:

  Traceback (most recent call last):
    File "/home/intrigeri/.home/prv-user/.combined/cyber/amnesia/live/git/submodules/jenkins-tools/slaves/lint_po", line 347, in <module>
      main(logging.getLogger())
    File "/home/intrigeri/.home/prv-user/.combined/cyber/amnesia/live/git/submodules/jenkins-tools/slaves/lint_po", line 327, in main
      chain = [(_check_po_file(next(iterator)),),
  StopIteration

  The po files you're trying to commit contain errors. Please fix them and try again.

This is a regression introduced by c957b5b8,
which b37a38ce fixed already, but only for the
case when --cached is *not* passed.

Note that in --cached mode, we don't display a warning: for details,
see 0da94c64.
parent a342116e
......@@ -293,10 +293,11 @@ def main(logger) -> None:
files = list(itertools.filterfalse(lambda f: f.startswith('tmp/'),
args.files))
if not files and not args.cached:
logger.warning("No file to process.\n"
"You may want to add files to operate on."
" See --help for further information.")
if not files:
if not args.cached:
logger.warning("No file to process.\n"
"You may want to add files to operate on."
" See --help for further information.")
sys.exit(0)
for prog in ("i18nspector",):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment