From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/
Date: Fri, 17 Feb 2023 10:10:18 +0000 (UTC) [thread overview]
Message-ID: <1676628259.fcdd1698e17876d0f45bf07de09320275b512898.arthurzam@gentoo> (raw)
commit: fcdd1698e17876d0f45bf07de09320275b512898
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 17 10:04:19 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 17 10:04:19 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=fcdd1698
InvalidCommitTag: fix false positive for advanced fixes format
Support more advanced format for Fixes and Reverts, which can have
explanation text after the commit hash, and can end in a dot.
Resolves: https://github.com/pkgcore/pkgcheck/issues/546
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/git.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py
index 4a9466c6..23f984b4 100644
--- a/src/pkgcheck/checks/git.py
+++ b/src/pkgcheck/checks/git.py
@@ -507,7 +507,7 @@ class InvalidCommitTag(results.CommitResult, results.Style):
.. [#] https://www.gentoo.org/glep/glep-0066.html#commit-messages
"""
- def __init__(self, tag, value, error, **kwargs):
+ def __init__(self, tag: str, value: str, error: str, **kwargs):
super().__init__(**kwargs)
self.tag, self.value, self.error = tag, value, error
@@ -571,18 +571,19 @@ class GitCommitMessageCheck(GentooRepoCheck, GitCommitsCheck):
_source = GitCommitsSource
known_results = frozenset(
- [
+ {
MissingSignOff,
InvalidCommitTag,
InvalidCommitMessage,
BadCommitSummary,
- ]
+ }
)
# mapping between known commit tags and verification methods
known_tags = {}
_commit_footer_regex = re.compile(r"^(?P<tag>[a-zA-Z0-9_-]+): (?P<value>.*)$")
_git_cat_file_regex = re.compile(r"^(?P<object>.+?) (?P<status>.+)$")
+ _commit_ref_regex = re.compile(r"^(?P<object>[0-9a-fA-F]+?)( \(.+?\))?\.?$")
# categories exception for rule of having package version in summary
skipped_categories = frozenset(
@@ -642,15 +643,23 @@ class GitCommitMessageCheck(GentooRepoCheck, GitCommitsCheck):
@verify_tags("Fixes", "Reverts")
def _commit_tag(self, tag, values, commit: git.GitCommit):
"""Verify referenced commits exist for Fixes/Reverts tags."""
- self.git_cat_file.stdin.write("\n".join(values) + "\n")
+ commits: dict[str, str] = {}
+ for value in values:
+ if mo := self._commit_ref_regex.match(value):
+ commits[mo.group("object")] = value
+ else:
+ yield InvalidCommitTag(tag, value, "invalid format", commit=commit)
+ self.git_cat_file.stdin.write("\n".join(commits.keys()) + "\n")
if self.git_cat_file.poll() is None:
- for _ in range(len(values)):
+ for _ in range(len(commits)):
line = self.git_cat_file.stdout.readline().strip()
if mo := self._git_cat_file_regex.match(line):
value = mo.group("object")
status = mo.group("status")
if not status.startswith("commit "):
- yield InvalidCommitTag(tag, value, f"{status} commit", commit=commit)
+ yield InvalidCommitTag(
+ tag, commits[value], f"{status} commit", commit=commit
+ )
def feed(self, commit: git.GitCommit):
if len(commit.message) == 0:
next reply other threads:[~2023-02-17 10:10 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 10:10 Arthur Zamarin [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-08 16:25 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/ Arthur Zamarin
2025-03-01 19:15 Arthur Zamarin
2025-02-28 7:10 Arthur Zamarin
2025-02-22 8:30 Arthur Zamarin
2025-01-25 11:27 Arthur Zamarin
2024-07-06 16:28 Arthur Zamarin
2024-07-04 20:06 Arthur Zamarin
2024-05-09 19:39 Arthur Zamarin
2024-05-08 16:32 Arthur Zamarin
2024-03-01 21:06 Arthur Zamarin
2023-12-10 20:07 Arthur Zamarin
2023-12-08 18:38 Arthur Zamarin
2023-12-08 17:52 Arthur Zamarin
2023-11-05 13:22 Arthur Zamarin
2023-11-01 19:20 Arthur Zamarin
2023-09-14 17:02 Arthur Zamarin
2023-09-14 17:02 Arthur Zamarin
2023-09-01 16:42 Arthur Zamarin
2023-08-29 18:58 Arthur Zamarin
2023-08-03 17:28 Arthur Zamarin
2023-08-02 11:59 Arthur Zamarin
2023-07-15 10:17 Arthur Zamarin
2023-06-24 7:52 Arthur Zamarin
2023-05-12 17:21 Arthur Zamarin
2023-03-24 13:56 Arthur Zamarin
2023-03-18 15:04 Arthur Zamarin
2023-03-11 7:18 Arthur Zamarin
2023-03-04 18:24 Arthur Zamarin
2023-02-18 18:33 Arthur Zamarin
2023-02-16 18:44 Arthur Zamarin
2023-02-05 17:56 Arthur Zamarin
2023-02-05 17:18 Arthur Zamarin
2023-01-31 17:08 Arthur Zamarin
2023-01-31 16:44 Arthur Zamarin
2023-01-24 18:57 Arthur Zamarin
2023-01-20 15:01 Arthur Zamarin
2023-01-20 15:01 Arthur Zamarin
2023-01-20 13:20 Arthur Zamarin
2023-01-14 20:31 Arthur Zamarin
2022-12-27 19:15 Arthur Zamarin
2022-12-13 19:59 Arthur Zamarin
2022-10-29 18:46 Arthur Zamarin
2022-10-29 5:43 Arthur Zamarin
2022-10-12 18:06 Arthur Zamarin
2022-10-07 12:42 Arthur Zamarin
2022-10-05 16:46 Arthur Zamarin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1676628259.fcdd1698e17876d0f45bf07de09320275b512898.arthurzam@gentoo \
--to=arthurzam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox