[libcamera-devel] [PATCH 0/4] utils: checkstyle.py: Fix Trailer handling

Jacopo Mondi jacopo.mondi at ideasonboard.com
Tue Jul 11 16:32:16 CEST 2023

Hi Kieran

On Tue, Jul 11, 2023 at 02:39:11PM +0100, Kieran Bingham via libcamera-devel wrote:
> Improve the handling of Trailer checking to support pre-commit hooks
> which will run using the 'StagedChanges' and 'Amendment' commit types.
> While there are no trailers to parse for StagedChanges, the existing
> trailers can be checked for Amendment commits. Update the code to
> support this, and also remove a RuntimeError from the checker which can
> be replaced with a usual CommitIssue instance.

It fixes the usage of checkstyle.py when used as pre-commit hook which
used to fail as

Traceback (most recent call last):
  File "libcamera.git/./utils/checkstyle.py", line 1052, in <module>
  File "libcamera.git/./utils/checkstyle.py", line 1042, in main
    issues += check_style(top_level, commit, args.checkers)
  File "libcamera.git/./utils/checkstyle.py", line 935, in check_style
    for issue in checker.check(commit, top_level):
  File "libcamera.git/./utils/checkstyle.py", line 479, in check
    for trailer in commit.trailers:
  File "libcamera.git/./utils/checkstyle.py", line 239, in trailers
    return self._trailers
AttributeError: 'Amendment' object has no attribute '_trailers'. Did you mean: 'trailers'?

Tested-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>

> Kieran Bingham (4):
>   utils: checkstyle.py: Treat Malformed trailers as a CommitIssue
>   utils: checkstyle.py: Initialise staged trailers
>   utils: checkstyle.py: Derive Amendment from Commit
>   utils: checkstyle.py: Check trailers for Amendment commits
>  utils/checkstyle.py | 36 +++++++++++++++++++++++++-----------
>  1 file changed, 25 insertions(+), 11 deletions(-)
> --
> 2.34.1

More information about the libcamera-devel mailing list