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.

homebrew: extract set_push_url and ensure_scw_profile (merlint E005)

+31 -39
+31 -39
lib/homebrew.ml
··· 653 653 654 654 (* {1 Release} *) 655 655 656 + let set_push_url config = 657 + Bos.OS.Cmd.run 658 + Bos.Cmd.( 659 + v "git" % "-C" % config.tap.local_path % "remote" % "set-url" 660 + % "--push" % "origin" % config.tap.push_url) 661 + |> Result.map_error (fun (`Msg e) -> e) 662 + |> Result.map (fun _ -> ()) 663 + 656 664 let ensure_tap config = 657 665 let open Result in 658 666 let ( let* ) = bind in ··· 668 676 % "origin/main") 669 677 = Ok (`Exited 0) 670 678 in 671 - (* Always ensure push URL is SSH, even for existing clones *) 672 - let* _ = 673 - Bos.OS.Cmd.run 674 - Bos.Cmd.( 675 - v "git" % "-C" % config.tap.local_path % "remote" % "set-url" 676 - % "--push" % "origin" % config.tap.push_url) 677 - |> Result.map_error (fun (`Msg e) -> e) 678 - in 679 + let* () = set_push_url config in 679 680 if has_remote_commits then 680 681 let* _ = 681 682 Bos.OS.Cmd.run ··· 695 696 v "git" % "clone" % config.tap.clone_url % config.tap.local_path) 696 697 |> Result.map_error (fun (`Msg e) -> e) 697 698 in 698 - (* Set the push URL to SSH so pushes work without HTTPS credentials *) 699 - let* _ = 700 - Bos.OS.Cmd.run 701 - Bos.Cmd.( 702 - v "git" % "-C" % config.tap.local_path % "remote" % "set-url" 703 - % "--push" % "origin" % config.tap.push_url) 704 - |> Result.map_error (fun (`Msg e) -> e) 705 - in 699 + let* () = set_push_url config in 706 700 Ok ()) 707 701 708 702 let commit_and_push_tap config = ··· 895 889 Log.app (fun m -> m "Platform: %s" (platform_to_string (detect_platform ()))); 896 890 Ok () 897 891 898 - let login config = 899 - let open Result in 900 - let ( let* ) = bind in 901 - (* Check required tools *) 902 - let* _scw = check_cmd "scw" in 903 - let* _rclone = check_cmd "rclone" in 904 - (* Configure scw profile — skip if it already exists *) 905 - let profile = config.storage.profile in 892 + let ensure_scw_profile profile = 906 893 let profile_exists = 907 894 Bos.OS.Cmd.run_status 908 895 Bos.Cmd.( 909 896 v "scw" % "config" % "get" % "access-key" % "--profile" % profile) 910 897 = Ok (`Exited 0) 911 898 in 912 - let* _ = 913 - if profile_exists then ( 914 - Log.app (fun m -> m "Scaleway profile '%s' already configured." profile); 915 - Ok ()) 916 - else ( 917 - Log.app (fun m -> m "Setting up Scaleway profile '%s'..." profile); 918 - Log.app (fun m -> m ""); 919 - Log.app (fun m -> 920 - m 921 - "Get your credentials from: \ 922 - https://console.scaleway.com/iam/api-keys"); 923 - Log.app (fun m -> m ""); 924 - Bos.OS.Cmd.run Bos.Cmd.(v "scw" % "init" % "--profile" % profile) 925 - |> Result.map_error (fun (`Msg e) -> e)) 926 - in 899 + if profile_exists then ( 900 + Log.app (fun m -> m "Scaleway profile '%s' already configured." profile); 901 + Ok ()) 902 + else ( 903 + Log.app (fun m -> m "Setting up Scaleway profile '%s'..." profile); 904 + Log.app (fun m -> m ""); 905 + Log.app (fun m -> 906 + m "Get your credentials from: https://console.scaleway.com/iam/api-keys"); 907 + Log.app (fun m -> m ""); 908 + Bos.OS.Cmd.run Bos.Cmd.(v "scw" % "init" % "--profile" % profile) 909 + |> Result.map_error (fun (`Msg e) -> e) 910 + |> Result.map (fun _ -> ())) 911 + 912 + let login config = 913 + let open Result in 914 + let ( let* ) = bind in 915 + let* _scw = check_cmd "scw" in 916 + let* _rclone = check_cmd "rclone" in 917 + let profile = config.storage.profile in 918 + let* () = ensure_scw_profile profile in 927 919 (* Generate rclone config from scw profile *) 928 920 Log.app (fun m -> m "Generating rclone configuration..."); 929 921 let* _ =