Homebrew bottle builder and tap manager for OCaml monorepos
0
fork

Configure Feed

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

Fix bottler: skip git pull on empty tap repos

git pull --ff-only fails when the remote tap repo has no commits
(empty repo, no main branch). Check rev-parse origin/main first;
if it fails, skip the pull.

+19 -5
+19 -5
lib/homebrew.ml
··· 642 642 let tap_path = Fpath.v config.tap.local_path in 643 643 if Bos.OS.Dir.exists tap_path = Ok true then ( 644 644 Log.info (fun m -> m "Pulling tap..."); 645 - let* _ = 646 - Bos.OS.Cmd.run 647 - Bos.Cmd.(v "git" % "-C" % config.tap.local_path % "pull" % "--ff-only") 648 - |> Result.map_error (fun (`Msg e) -> e) 645 + (* Check if remote has any commits before pulling — empty repos have no 646 + branch to pull from and git pull --ff-only fails. *) 647 + let has_remote_commits = 648 + Bos.OS.Cmd.run_status 649 + Bos.Cmd.( 650 + v "git" % "-C" % config.tap.local_path % "rev-parse" % "--verify" 651 + % "origin/main") 652 + = Ok (`Exited 0) 649 653 in 650 - Ok ()) 654 + if has_remote_commits then 655 + let* _ = 656 + Bos.OS.Cmd.run 657 + Bos.Cmd.( 658 + v "git" % "-C" % config.tap.local_path % "pull" % "--ff-only") 659 + |> Result.map_error (fun (`Msg e) -> e) 660 + in 661 + Ok () 662 + else ( 663 + Log.info (fun m -> m "Remote tap is empty — skipping pull"); 664 + Ok ())) 651 665 else ( 652 666 Log.info (fun m -> m "Cloning tap..."); 653 667 let* _ =