mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-14 22:13:47 -06:00
fix: bios_integrity stops when git fails
modified_for_git read the stdout of git status without its exit code: a corrupt index printed nothing, the working change read as unmodified, and --apply wrote HEAD's blob over it. Every git call now raises on a non-zero status, and the command exits 2 naming the git error.
This commit is contained in:
1 parent
57ccca640a
commit
afceabaf3c
2 files changed
+27
-2
No files matched your search
@@ -91,8 +91,19 @@ def sha1_of(path: Path) -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
class GitFailed(RuntimeError):
|
||||
"""A git command failed: its empty output says nothing about the file."""
|
||||
|
||||
|
||||
def git(root: Path, *args: str) -> subprocess.CompletedProcess:
|
||||
return subprocess.run(["git", "-C", str(root), *args], capture_output=True, check=False)
|
||||
"""Run git in root. A failure raises: an unreadable index read as an empty
|
||||
status made a session's working change look unmodified, and --apply wrote
|
||||
HEAD's bytes over it."""
|
||||
done = subprocess.run(["git", "-C", str(root), *args], capture_output=True, check=False)
|
||||
if done.returncode:
|
||||
message = done.stderr.decode(errors="replace").strip()
|
||||
raise GitFailed(f"git {' '.join(args)} exited {done.returncode}: {message}")
|
||||
return done
|
||||
|
||||
|
||||
def head_blob(root: Path, path: str) -> str:
|
||||
@@ -197,7 +208,11 @@ def main() -> int:
|
||||
from common import load_database
|
||||
|
||||
root = Path.cwd()
|
||||
report = check(root, load_database(args.db), args.apply)
|
||||
try:
|
||||
report = check(root, load_database(args.db), args.apply)
|
||||
except GitFailed as exc:
|
||||
print(f"ERROR: {exc}. Nothing was restored past this point.", file=sys.stderr)
|
||||
return 2
|
||||
if args.json:
|
||||
print(json.dumps(report.as_dict(), indent=2))
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user