summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-10 02:43:59 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-12 15:44:23 +0300
commit2d5cea862dbc369d848fb1b745e61a34658c3a0f (patch)
tree3bd41a20ae44abb20105d484fff1170a3ff7be66 /utils
parent35f045f9783d22a94de7a8ac173db67e41cfd258 (diff)
utils: checkstyle.py: Add __repr__ method to Commit class
When debugging issues with the Commit class, a __repr__ method proved to be useful to quickly print all the parsed information about a commit. To avoid reimplementing the method over and over again in the future, add it to the class, even if it is not actually used. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/checkstyle.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 2b1e1f6c..c9e41d41 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -248,6 +248,17 @@ class Commit:
stdout=subprocess.PIPE).stdout.decode('utf-8')
self._files = [CommitFile(f) for f in ret.splitlines()]
+ def __repr__(self):
+ return '\n'.join([
+ f'commit {self.commit}',
+ f'Author: {self.author}',
+ f'',
+ f' {self.title}',
+ '',
+ '\n'.join([line and f' {line}' or '' for line in self._body]),
+ 'Trailers:',
+ ] + self.trailers)
+
def files(self, filter='AMR'):
return [f.filename for f in self._files if f.status in filter]