From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7A99F15802F for ; Sat, 11 Mar 2023 07:14:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9AEBDE079E; Sat, 11 Mar 2023 07:14:19 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 78492E079E for ; Sat, 11 Mar 2023 07:14:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 91018340C72 for ; Sat, 11 Mar 2023 07:14:18 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DA85A8BC for ; Sat, 11 Mar 2023 07:14:16 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1678518629.7410c137c57c645b5e502f279eb183a14d7ef216.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, tests/checks/ X-VCS-Repository: proj/pkgcore/pkgcheck X-VCS-Files: src/pkgcheck/checks/git.py tests/checks/test_git.py X-VCS-Directories: src/pkgcheck/checks/ tests/checks/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 7410c137c57c645b5e502f279eb183a14d7ef216 X-VCS-Branch: master Date: Sat, 11 Mar 2023 07:14:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 292efdc6-06b6-474d-b7e1-a0dc647e2ed2 X-Archives-Hash: 24bf7693dc62c235b180eac92239df68 commit: 7410c137c57c645b5e502f279eb183a14d7ef216 Author: Arthur Zamarin gentoo org> AuthorDate: Sat Mar 11 07:10:29 2023 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Sat Mar 11 07:10:29 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=7410c137 GitPkgCommitsCheck: fix modification check for added ebuild in pkgset When commit range has modification for multiple versions, with one of them modifying a newly added version in the same range, it wouldn't find the correct base commit and fail. Fix it by grouping based on fullver. The test is special with time.sleep, since I need the commits be in different seconds, otherwise the sorting by time might be bad. Resolves: https://github.com/pkgcore/pkgcheck/issues/563 Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcheck/checks/git.py | 6 +++++- tests/checks/test_git.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py index 7309a08f..aec3b05f 100644 --- a/src/pkgcheck/checks/git.py +++ b/src/pkgcheck/checks/git.py @@ -497,7 +497,11 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): yield from self.rename_checks(list(pkg_map["R"])) # run modified package checks if modified := [pkg for pkg in pkg_map["M"] if pkg not in pkg_map["D"]]: - yield from self.modified_checks(modified, list(pkg_map["A"])) + version_modifications = defaultdict(list) + for pkg in modified: + version_modifications[pkg.fullver].append(pkg) + for modified in version_modifications.values(): + yield from self.modified_checks(modified, pkg_map["A"]) for git_pkg in pkgset: # remaining checks are irrelevant for removed packages diff --git a/tests/checks/test_git.py b/tests/checks/test_git.py index 7eb7907a..03687451 100644 --- a/tests/checks/test_git.py +++ b/tests/checks/test_git.py @@ -1,5 +1,6 @@ import os import textwrap +import time from datetime import datetime, timedelta from unittest.mock import patch @@ -736,6 +737,20 @@ class TestGitPkgCommitsCheck(ReportTestCase): self.init_check() self.assertNoReport(self.check, self.source) + def test_modified_added_file(self): + self.child_repo.create_ebuild("cat/pkg-0", homepage="https://gentoo.org") + self.child_git_repo.add_all("cat/pkg: update HOMEPAGE") + time.sleep(1) + self.child_repo.create_ebuild("cat/pkg-1", eapi="7") + self.child_git_repo.add_all("cat/pkg: add 1") + time.sleep(1) + self.child_repo.create_ebuild("cat/pkg-1", eapi="8") + self.child_git_repo.add_all("cat/pkg: bump EAPI") + self.init_check() + r = self.assertReport(self.check, self.source) + expected = git_mod.EAPIChangeWithoutRevbump(pkg=CPV("cat/pkg-1")) + assert r == expected + class TestGitEclassCommitsCheck(ReportTestCase): check_kls = git_mod.GitEclassCommitsCheck