public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4901] Add -v option for git_check_commit.py.
@ 2021-11-04 14:03 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-11-04 14:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:af1bfcc04ca1c80af4fc1cda75c6c1d8509c8bd0

commit r12-4901-gaf1bfcc04ca1c80af4fc1cda75c6c1d8509c8bd0
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Nov 4 14:58:27 2021 +0100

    Add -v option for git_check_commit.py.
    
    Doing so, one can see:
    $ git gcc-verify a50914d2111c72d2cd5cb8cf474133f4f85a25f6 -v
    Checking a50914d2111c72d2cd5cb8cf474133f4f85a25f6: FAILED
    ERR: unchanged file mentioned in a ChangeLog: "gcc/common.opt"
    ERR: unchanged file mentioned in a ChangeLog (did you mean "gcc/testsuite/g++.dg/pr102955.C"?): "gcc/testsuite/gcc.dg/pr102955.c"
    - gcc/testsuite/gcc.dg/pr102955.c
    ?                ^^             ^
    
    + gcc/testsuite/g++.dg/pr102955.C
    ?                ^^             ^
    
    contrib/ChangeLog:
    
            * gcc-changelog/git_check_commit.py: Add -v option.
            * gcc-changelog/git_commit.py: Print verbose diff for wrong
            filename.

Diff:
---
 contrib/gcc-changelog/git_check_commit.py | 4 ++++
 contrib/gcc-changelog/git_commit.py       | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py
index 9a4c5d448fb..d6aff3cef91 100755
--- a/contrib/gcc-changelog/git_check_commit.py
+++ b/contrib/gcc-changelog/git_check_commit.py
@@ -29,6 +29,8 @@ parser.add_argument('-g', '--git-path', default='.',
                     help='Path to git repository')
 parser.add_argument('-p', '--print-changelog', action='store_true',
                     help='Print final changelog entires')
+parser.add_argument('-v', '--verbose', action='store_true',
+                    help='Print verbose information')
 args = parser.parse_args()
 
 retval = 0
@@ -41,6 +43,8 @@ for git_commit in parse_git_revisions(args.git_path, args.revisions):
     else:
         for error in git_commit.errors:
             print('ERR: %s' % error)
+            if args.verbose and error.details:
+                print(error.details)
         retval = 1
 
 exit(retval)
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 60377b68ba1..27a1d59b211 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -197,9 +197,10 @@ def decode_path(path):
 
 
 class Error:
-    def __init__(self, message, line=None):
+    def __init__(self, message, line=None, details=None):
         self.message = message
         self.line = line
+        self.details = details
 
     def __repr__(self):
         s = self.message
@@ -687,9 +688,11 @@ class GitCommit:
         for file in sorted(mentioned_files - changed_files):
             msg = 'unchanged file mentioned in a ChangeLog'
             candidates = difflib.get_close_matches(file, changed_files, 1)
+            details = None
             if candidates:
                 msg += f' (did you mean "{candidates[0]}"?)'
-            self.errors.append(Error(msg, file))
+                details = '\n'.join(difflib.Differ().compare([file], [candidates[0]])).rstrip()
+            self.errors.append(Error(msg, file, details))
         for file in sorted(changed_files - mentioned_files):
             if not self.in_ignored_location(file):
                 if file in self.new_files:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-04 14:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 14:03 [gcc r12-4901] Add -v option for git_check_commit.py Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).