From patchwork Tue Sep 5 14:37:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1829906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rg7R32f6tz1ygc for ; Wed, 6 Sep 2023 00:38:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FA7F385624C for ; Tue, 5 Sep 2023 14:38:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 768533857721 for ; Tue, 5 Sep 2023 14:37:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 768533857721 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.02,229,1688457600"; d="diff'?scan'208";a="18080347" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 05 Sep 2023 06:37:50 -0800 IronPort-SDR: lrSmE/yfzrh5Qdyg7KxnyX1qMgCt44plO3Ccd+pl+azXoI07fyMOCY+xROHsCz6GwJsMZrkmOu oQEw3eGqU71LxlY22ohi3uHBT9xyRnsKwAWq9uurCY9zK6366yaGMqD8fkD6yzMqWzME8zbLuK rCedxlroS0k55EOmXx/xI6EEVRt3XZozPnjo3uTuI8XW6TIO8CJ1ba0G6niQOC4e/GCULMRXBU utnRs4ff1yRX5rMcC/4S1krE3sGd6FN9Z8TfNX6ssJZtUzuX8urMya5NwWhFtlC90y/mPVs42C sDQ= Message-ID: Date: Tue, 5 Sep 2023 16:37:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Content-Language: en-US To: gcc-patches , David Malcolm , =?utf-8?q?Arsen_Arsenovi=C4=87?= From: Tobias Burnus Subject: [Patch] contrib/gcc-changelog: Check whether revert-commit exists X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" That's based on the fail https://gcc.gnu.org/pipermail/gccadmin/2023q3/020349.html and on the discussion on IRC. The problem in for the cron job was that r14-3661-g084a7cf9fb2d9cb98dfbe7d91602c840ec50b002 referenced a commit that did not exist. This was temporarily fixed by Jakub, but it makes sense to detect this in the pre-commit hook. With the patch, contrib/gcc-changelog/git_email.py 0001-Revert-libstdc-Use-GLIBCXX_CHECK_LINKER_FEATURES-for.patch now prints: OK Warnings: Cannot obtain info about reverted commit '46c2e94ca66ed9991c45a6ba6204ed02869efc39' while contrib/gcc-changelog/git_check_commit.py 084a7cf9fb2d9cb98dfbe7d91602c840ec50b002 now fails with: Checking 084a7cf9fb2d9cb98dfbe7d91602c840ec50b002: FAILED ERR: Cannot find to-be-reverted commit: "46c2e94ca66ed9991c45a6ba6204ed02869efc39" (check_email.py always shows the warning, git_check_commit.py only with '-v') Notes: - I am not sure whether a sensible testcase can be added - and, hence, I have not added one. - I have run "pytest-3' but my python is too old and thus might miss some checks which newer pytest/flake8 will find. But at least it did pass here. - I have not tested the cherry-pick + commit does not exist case, which now creates a warning as I did not quickly find a testcase. Comments, remarks, suggestions, approval? Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 contrib/gcc-changelog: Check whether revert-commit exists contrib/ChangeLog: * gcc-changelog/git_commit.py (GitCommit.__init__): Handle commit_to_info_hook = None; otherwise, if None, regard it as error. (to_changelog_entries): Handle commit_to_info_hook = None; if info is None, create a warning for it. * gcc-changelog/git_email.py (GitEmail.__init__): call super() with commit_to_info_hook=None instead of a lamda function. contrib/gcc-changelog/git_commit.py | 14 +++++++++----- contrib/gcc-changelog/git_email.py | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index 4f3131021f2..4d024026f2b 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -329,11 +329,13 @@ class GitCommit: self.revert_commit = m.group('hash') break if self.revert_commit: + # The following happens for get_email.py: + if not self.commit_to_info_hook: + return self.info = self.commit_to_info_hook(self.revert_commit) - - # The following happens for get_email.py: - if not self.info: - return + if not self.info: + self.errors.append(Error('Cannot find to-be-reverted commit', self.revert_commit)) + return self.check_commit_email() @@ -796,12 +798,14 @@ class GitCommit: orig_date = self.original_info.date current_timestamp = orig_date.strftime(DATE_FORMAT) elif self.cherry_pick_commit: - info = self.commit_to_info_hook(self.cherry_pick_commit) + info = (self.commit_to_info_hook + and self.commit_to_info_hook(self.cherry_pick_commit)) # it can happen that it is a cherry-pick for a different # repository if info: timestamp = info.date.strftime(DATE_FORMAT) else: + self.warnings.append(f"Cherry-picked commit not found: '{self.cherry_pick_commit}'") timestamp = current_timestamp elif not timestamp or use_commit_ts: timestamp = current_timestamp diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py index 49f41f2ec99..93808dfabb6 100755 --- a/contrib/gcc-changelog/git_email.py +++ b/contrib/gcc-changelog/git_email.py @@ -89,8 +89,7 @@ class GitEmail(GitCommit): t = 'M' modified_files.append((target if t != 'D' else source, t)) git_info = GitInfo(None, date, author, message, modified_files) - super().__init__(git_info, - commit_to_info_hook=lambda x: None) + super().__init__(git_info, commit_to_info_hook=None) def show_help():