mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-06-09 14:41:54 -07:00
Track local ref SHAs on pull for incremental bundle generation on remote
This commit is contained in:
@@ -433,7 +433,21 @@ class ReticulumGitClient():
|
||||
batch = fetch_queue[:ref_batch_size]
|
||||
fetch_queue = fetch_queue[ref_batch_size:]
|
||||
|
||||
refs_list = [{"sha": sha, "ref": ref} for sha, ref in batch]
|
||||
refs_list = []
|
||||
for sha, ref in batch:
|
||||
ref_entry = {"sha": sha, "ref": ref}
|
||||
try:
|
||||
# Attempt to get local ref SHA for incremental bundle generation on remote
|
||||
result = subprocess.run(["git", "rev-parse", ref], capture_output=True, text=True, check=False)
|
||||
if result.returncode == 0:
|
||||
local_sha = result.stdout.strip()
|
||||
if local_sha != sha: ref_entry["have"] = local_sha
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not resolve local SHA for {ref} during fetch enumeration, getting full history for this ref: {e}", RNS.LOG_WARNING)
|
||||
|
||||
refs_list.append(ref_entry)
|
||||
|
||||
ref_names = [ref for _, ref in batch]
|
||||
RNS.log(f"Fetching batch of {len(refs_list)} refs: {ref_names}", RNS.LOG_DEBUG)
|
||||
|
||||
|
||||
@@ -520,7 +520,12 @@ class ReticulumGitNode():
|
||||
RNS.log(f"Created {tmp_path} for {link}", RNS.LOG_DEBUG)
|
||||
|
||||
bundle_path = os.path.join(tmp_path, "fetch.bundle")
|
||||
execv = ["git", "bundle", "create", "--no-progress", bundle_path] + ref_names
|
||||
execv = ["git", "bundle", "create", "--no-progress", bundle_path]
|
||||
|
||||
for r in refs:
|
||||
execv.append(r["ref"])
|
||||
if "have" in r and r["have"]: execv.append(f"^{r['have']}")
|
||||
|
||||
result = subprocess.run(execv, cwd=repository_path, capture_output=True, check=False)
|
||||
if result.returncode != 0: return self.RES_REMOTE_FAIL.to_bytes(1, "big") + result.stderr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user