Precommit hook silences ament_uncrustify error
Description
The git pre-commit hook in .git-hooks/pre-commit
doesn't reveal if ament_uncrustify
had an internal error. Instead it says some files were reformatted, which may not be true.
How to Reproduce
- Edit a C++ file and add an open parenthesis
- Stage and commit, with the hook enabled
Then ament_uncrustify
fails to parse the code and bails out before it reformats anything
$ git add src/control/motion_common/src/motion_common/motion_common.cpp; git commit
Checking the following C++ file(s):
--------------------------------------------
- src/control/motion_common/src/motion_common/motion_common.cpp
Running uncrustify
---------------
Some files were reformatted, please check the changes and commit again
Expected behavior
The pre-commit
should report the error by ament_uncrustify
to make it clear why the commit failed.
Running uncrustify
---------------
Output prefix: /tmp/uncrustify_vye9s1zt/
Output suffix: .uncrustify
Parsing: /home/frederik.beaujean/AutowareAuto/src/control/motion_common/src/motion_common/motion_common.cpp as language CPP
parse_cleanup(427): /home/frederik.beaujean/AutowareAuto/src/control/motion_common/src/motion_common/motion_common.cpp, orig_line is 34, Error: Unexpected '}' for 'PAREN_OPEN', which was on line 31
Unmatched BRACE_CLOSE
at orig_line=34, orig_col=1
Try the option 'tok_split_gte = true'
The invocation of 'uncrustify' failed with error code 1: Command '['/opt/ros/dashing/bin/uncrustify', '-c', '/opt/ros/dashing/lib/python3.6/site-packages/ament_uncrustify/configuration/ament_code_style.cfg', '--prefix', '/tmp/uncrustify_vye9s1zt', '--suffix', '.uncrustify', '/home/frederik.beaujean/AutowareAuto/src/control/motion_common/src/motion_common/motion_common.cpp']' returned non-zero exit status 1.