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
This commit is contained in:
Kivi Kaitaniemi
2024-07-28 11:10:46 +03:00
parent 483bf0d676
commit 5fe7df23db
3 changed files with 17 additions and 1 deletions
+3
View File
@@ -230,6 +230,9 @@ class MyCommands(decman.config.Commands):
def git_get_commit_id(self) -> list[str]: def git_get_commit_id(self) -> list[str]:
return ["git", "rev-parse", "HEAD"] 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]: def review_file(self, file: str) -> list[str]:
return ["less", file] return ["less", file]
+6
View File
@@ -136,6 +136,12 @@ class Commands:
""" """
return ["git", "rev-parse", "HEAD"] 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]: def review_file(self, file: str) -> list[str]:
""" """
Running this command outputs a file for the user to see. Running this command outputs a file for the user to see.
+8 -1
View File
@@ -1078,7 +1078,14 @@ before and thus are found in the cache."
default=True): default=True):
latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get( latest_reviewed_commit = self._store.pkgbuild_latest_reviewed_commits.get(
pkgbase) 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("."): for file in os.scandir("."):
if file.is_file() and not file.name.startswith("."): if file.is_file() and not file.name.startswith("."):
subprocess.run(conf.commands.review_file( subprocess.run(conf.commands.review_file(