From dee53857848c288abc9ce3fd50a165e9b07b79c5 Mon Sep 17 00:00:00 2001 From: Mikhail Goncharov Date: Tue, 10 Mar 2020 11:47:09 +0100 Subject: [PATCH] Truncate clang-format comments If clang format diff is longer that 11 lines only show first 10 and add note about omitted ones. for #144 --- scripts/phabtalk/phabtalk.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/phabtalk/phabtalk.py b/scripts/phabtalk/phabtalk.py index 80cbb6a..5c734dc 100755 --- a/scripts/phabtalk/phabtalk.py +++ b/scripts/phabtalk/phabtalk.py @@ -290,6 +290,16 @@ class BuildReport: diffs = _parse_patch(open(p, 'r')) success = len(diffs) == 0 for d in diffs: + lines = d['diff'].splitlines(True) + m = 10 # max number of lines to report. + description = 'please reformat the code\n```\n' + n = len(lines) + cut = n > m + 1 + if cut: + lines = lines[:m] + description += ''.join(lines) + '\n```' + if cut: + description += '\n{} diff lines are omitted. Please check full report.'.format(n - m) self.add_lint({ 'name': 'clang-format', 'severity': 'autofix', @@ -297,7 +307,7 @@ class BuildReport: 'path': d['filename'], 'line': d['line'], 'char': 1, - 'description': 'please reformat the code\n```\n' + d['diff'] + '\n```', + 'description': description, }) comment = section_title('clang-format', success, present) if not success: