commit:     9e52de6f3e238d832b86b5abe196e6e3439ce2bd
Author:     Martin Mokry <martin-kokos <AT> users <DOT> noreply <DOT> github 
<DOT> com>
AuthorDate: Tue Feb  4 10:09:40 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Feb  7 19:26:26 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=9e52de6f

git: suggest clearing cache on `git log` error

In some cases, the cache gets corrupted, showing:

pkgcheck scan: error: failed running git log: fatal: Invalid revision range 
<hash>..origin/HEAD

Recommend clearing the cache with `pkgcheck cache -R` as a workaround.

Signed-off-by: Martin Mokry <martin-kokos <AT> protonmail.com>
Closes: https://github.com/pkgcore/pkgcheck/pull/729
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/addons/git.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/pkgcheck/addons/git.py b/src/pkgcheck/addons/git.py
index 1874e8a6..e3de52c0 100644
--- a/src/pkgcheck/addons/git.py
+++ b/src/pkgcheck/addons/git.py
@@ -126,7 +126,12 @@ class GitLog:
         if not self._running:
             if self.proc.poll() or not line:
                 error = self.proc.stderr.read().decode().strip()
-                raise GitError(f"failed running git log: {error}")
+                if "Invalid revision range" in error:
+                    raise GitError(
+                        f"failed running git log: {error}\nTry clearing the 
cache: pkgcheck cache -R"
+                    )
+                else:
+                    raise GitError(f"failed running git log: {error}")
             self._running = True
             self.git_config.close()
 

Reply via email to