Monorepo management for opam overlays
0
fork

Configure Feed

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

Improve push error UX for non-fast-forward failures

After git filter-repo, commit hashes change even for unrelated
subtrees (the commit topology changes which commits the split
selects). Existing checkouts become stale.

Instead of a generic "check credentials" hint, detect non-fast-forward
push failures and suggest "monopam push --force" with explanation.

+24 -2
+10 -2
lib/ctx.ml
··· 50 50 Some "Check that the remote is configured: git remote -v" 51 51 | Git_error (Git_cli.Branch_not_found _) -> 52 52 Some "Check available branches: git branch -a" 53 - | Git_error (Git_cli.Command_failed (cmd, _)) 53 + | Git_error (Git_cli.Command_failed (cmd, result)) 54 54 when String.starts_with ~prefix:"git push" cmd -> 55 - Some "Check your network connection and git credentials." 55 + if 56 + Astring.String.is_prefix ~affix:"non-fast-forward" result.Git_cli.stderr 57 + || Astring.String.is_prefix ~affix:" ! [rejected]" result.Git_cli.stderr 58 + || Astring.String.is_prefix ~affix:"fetch first" result.Git_cli.stderr 59 + then 60 + Some 61 + "Use 'monopam push --force' to overwrite diverged history (e.g. \ 62 + after git filter-repo)." 63 + else Some "Check your network connection and git credentials." 56 64 | Git_error _ -> None 57 65 | Dirty_state _ -> 58 66 Some
+14
lib/push.ml
··· 45 45 ~refspec ~force:(clean || force) () 46 46 with 47 47 | Ok () -> Ok () 48 + | Error (Git_cli.Command_failed (_, result) as e) 49 + when (not force) 50 + && (Astring.String.is_prefix ~affix:"non-fast-forward" 51 + result.Git_cli.stderr 52 + || Astring.String.is_prefix ~affix:" ! [rejected]" 53 + result.Git_cli.stderr 54 + || Astring.String.is_prefix ~affix:"fetch first" 55 + result.Git_cli.stderr) -> 56 + Log.warn (fun m -> 57 + m 58 + "Push to %s rejected (non-fast-forward). Use --force to \ 59 + overwrite (e.g. after git filter-repo)." 60 + checkout_url); 61 + Error (Ctx.Git_error e) 48 62 | Error e -> Error (Ctx.Git_error e))) 49 63 50 64 (** Resolve the fetch URL for a package: sources.toml entry > dev-repo fallback.