From 5fe7df23dbc1356aec6106f401d7ea49b6d8c8b4 Mon Sep 17 00:00:00 2001 From: Kivi Kaitaniemi Date: Sun, 28 Jul 2024 11:10:46 +0300 Subject: [PATCH] Show full PKGBUILD if a commit id is not found If a git commit id is not found in a PKGBUILD repository, show the full PKGBUILD instead of trying to show a git diff. Fixes #5 --- example/source.py | 3 +++ src/decman/config.py | 6 ++++++ src/decman/lib/fpm.py | 9 ++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/example/source.py b/example/source.py index 5d26ea6..d6d35ef 100644 --- a/example/source.py +++ b/example/source.py @@ -230,6 +230,9 @@ class MyCommands(decman.config.Commands): def git_get_commit_id(self) -> list[str]: return ["git", "rev-parse", "HEAD"] + def git_log_commit_ids(self) -> list[str]: + return ["git", "log", "--format=format:%H"] + def review_file(self, file: str) -> list[str]: return ["less", file] diff --git a/src/decman/config.py b/src/decman/config.py index 89a333f..4e217f7 100644 --- a/src/decman/config.py +++ b/src/decman/config.py @@ -136,6 +136,12 @@ class Commands: """ return ["git", "rev-parse", "HEAD"] + def git_log_commit_ids(self) -> list[str]: + """ + Running this command outputs commit hashes of the repository. + """ + return ["git", "log", "--format=format:%H"] + def review_file(self, file: str) -> list[str]: """ Running this command outputs a file for the user to see. diff --git a/src/decman/lib/fpm.py b/src/decman/lib/fpm.py index 7f14c4f..5303e06 100644 --- a/src/decman/lib/fpm.py +++ b/src/decman/lib/fpm.py @@ -1078,7 +1078,14 @@ before and thus are found in the cache." default=True): latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get( pkgbase) - if latest_reviewed_commit is None: + + git_commit_ids = subprocess.run( + conf.commands.git_log_commit_ids(), + check=True, + stdout=subprocess.PIPE, + ).stdout.decode().strip().split('\n') + + if latest_reviewed_commit is None or latest_reviewed_commit not in git_commit_ids: for file in os.scandir("."): if file.is_file() and not file.name.startswith("."): subprocess.run(conf.commands.review_file(