From patchwork Thu Nov 4 14:03:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 47051 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A643385803F for ; Thu, 4 Nov 2021 14:03:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 346C2385840A for ; Thu, 4 Nov 2021 14:03:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 346C2385840A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E70261FD57 for ; Thu, 4 Nov 2021 14:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1636034585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nxbnpzADOF0NtECt+9jzoQh632v2tVS+POOxbdzYyb4=; b=KdRauOFdW9P4cI5Ld7PUf+SWjak+pa1jcLrxqEjeH2NWa3QNePLNoA8HUs23TcpOT/Z4yO nzB2HTcvoNErPBDVVXvRI4F8NoyoUEl0JaoZgdiFnArgb77/R2U01YlHdvh9u7xHrEpNyp 3t5aLSLzoTSaWLUB54KYInhBti3W67k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1636034585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nxbnpzADOF0NtECt+9jzoQh632v2tVS+POOxbdzYyb4=; b=PV+2dU4wMYTNHDT207G7en2AsJLTp6qrgOBS9zNKbtjVYzWGFj2SZcd9suIcfaLKuACM8v pCmSUXF1gZpe6ADg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D942E13BD9 for ; Thu, 4 Nov 2021 14:03:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NaMENBnog2GIQQAAMHmgww (envelope-from ) for ; Thu, 04 Nov 2021 14:03:05 +0000 Message-ID: <02c86b39-d02b-1ef0-a099-eba09ec24dee@suse.cz> Date: Thu, 4 Nov 2021 15:03:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Add -v option for git_check_commit.py. To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Pushed. 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. --- 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: