Skip to content

Commit c93d5b8

Browse files
committed
cargo: Use force checkout if git sources in cache differ
Fixes #414
1 parent 1518aca commit c93d5b8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cargo/flatpak-cargo-generator.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,15 @@ def fetch_git_repo(git_url: str, commit: str) -> str:
133133
head = rev_parse_proc.stdout.decode().strip()
134134
if head[:COMMIT_LEN] != commit[:COMMIT_LEN]:
135135
subprocess.run(["git", "fetch", "origin", commit], cwd=clone_dir, check=True)
136-
subprocess.run(["git", "checkout", commit], cwd=clone_dir, check=True)
136+
try:
137+
subprocess.run(["git", "checkout", commit], cwd=clone_dir, check=True)
138+
except subprocess.CalledProcessError:
139+
logging.info(
140+
"Checking out commit %s failed for %s. Trying to force checkout the requested commit",
141+
commit,
142+
git_url,
143+
)
144+
subprocess.run(["git", "checkout", "-f", commit], cwd=clone_dir, check=True)
137145

138146
# Get the submodules as they might contain dependencies. This is a noop if
139147
# there are no submodules in the repository

0 commit comments

Comments
 (0)