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: 137525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1724542vqo; Tue, 5 Sep 2023 07:38:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmBDrIUr57ulD42stS8FaHei092tIxGTDUdV38DqkY2hg+bpu7kGZi+r6Lz+EGub7sCRzu X-Received: by 2002:a05:6512:3688:b0:500:903f:6084 with SMTP id d8-20020a056512368800b00500903f6084mr6340lfs.63.1693924729273; Tue, 05 Sep 2023 07:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693924729; cv=none; d=google.com; s=arc-20160816; b=lUlAzbzMfHCjiJaXb83VUNZOHAoBVKeo/d4ibOUQNUemo6OELB/+Q3MvIpP1lwDPJ5 OSWvkAI1az+bBpDnzb6nbETMt2ve3PMWgyLnHJpI9iwNxgnavZQkoUF096oj4ayARadn wVycYxWTKVRQPwneLwTa3lqwP90qOkltMHDg2BOsH+VjPbUdAtH+w7W74TSyGBNNxiCe oYkcgqc6nuTyJYJIThjH+man2nuThfHpkRXPMjYiji8PSE4Yt/aeQObUcMBWHKZstqjx TblxNsUjpBf951pZ7eK8eh26tiSof9fbBX4ISJV/zxa04Wbai2U2AayvcEbLBVv87OdT +pxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=JvnFYoqNZulUYma4uSpC6pFhQ3tJp10b2Qc+qSPztwA=; fh=q5xLwBLWPe1Oq2s+e4Z3aqirjlnd5IAxqply7KwGFyE=; b=IwRq3JrBg+9bZvzLw5Vs2olCbu437H0XEOOrb/L2vjNyYTZxhAEZ2myE4FTR0wnbXb PWaa+hTQYRScnf297Rsq6XA1kDb4Ez1pqsn1hfCjMIPAotoZxODbJ71pKoxGOk8GO+KA AupBIIR/lQ0LuthhyLVBMLVHZrN4FEyaDxanLhDT4r8t3ExSz7jknAsTjygapQhH+nWN qMKQukquh/pyTnNE1aJTX0y8C2HOrAZARaKkJ1Bw0pyusWmtRGq7brZc/AzZDkH5Hz7p EaXDGtyYuKF9bYpVR87PIuLWX7F3oSW1w6HoinBaHvJuuGEyNsfimsBaj+yRWF6slhIQ KY8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a18-20020aa7cf12000000b0052888e27fe8si7685881edy.690.2023.09.05.07.38.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 07:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B67DB3856DC6 for ; Tue, 5 Sep 2023 14:38:32 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776208816637074699 X-GMAIL-MSGID: 1776208816637074699 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():