Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

monopam/status: accept empty repos as 'exists'

[git ls-remote --exit-code] returns 0 when refs are present, 2 when the
remote is reachable but empty, and 128 when unreachable. Drop [--heads]
and treat exit 2 as reachable so a freshly-provisioned repo with no
branches no longer appears under 'Remote missing'.

+9 -7
+9 -7
lib/git_cli.ml
··· 54 54 let ls_remote_retry_config = 55 55 Retry.config ~max_retries:2 ~backoff_factor:0.3 ~backoff_max:4.0 () 56 56 57 + (* [git ls-remote --exit-code] returns 0 if the remote has any refs, 2 if the 58 + remote is reachable but empty (a freshly created repo with no branches), and 59 + 128 if the remote is unreachable. A freshly provisioned repo counts as 60 + "exists". *) 57 61 let ls_remote_exists ~clock ~proc ~fs ~url = 58 62 let cwd = Eio.Path.(fs / "/") in 59 63 let result_ref = ref None in 60 - (* Under parallel contention against the git host, a request occasionally 61 - fails with a transient non-zero exit and succeeds on retry. Retry on 62 - any non-zero outcome; [Retry] applies exponential backoff. *) 63 - let should_retry (r : cmd_result) = r.exit_code <> 0 in 64 + let reachable (r : cmd_result) = r.exit_code = 0 || r.exit_code = 2 in 65 + let should_retry r = not (reachable r) in 64 66 let attempt () = 65 - let r = run_git ~proc ~cwd [ "ls-remote"; "--exit-code"; "--heads"; url ] in 67 + let r = run_git ~proc ~cwd [ "ls-remote"; "--exit-code"; url ] in 66 68 result_ref := Some r; 67 - if r.exit_code = 0 then Ok () else Error r 69 + if reachable r then Ok () else Error r 68 70 in 69 71 let _ = 70 72 Retry.with_retry_result ~clock ~config:ls_remote_retry_config ~should_retry 71 73 attempt 72 74 in 73 - match !result_ref with Some r -> r.exit_code = 0 | None -> false 75 + match !result_ref with Some r -> reachable r | None -> false 74 76 75 77 let run_git_ok ~proc ~cwd args = 76 78 let result = run_git ~proc ~cwd args in