Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-browser flag #110

Merged
merged 3 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/publishMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ module Args = struct
info ["n";"dry-run"] ~docs ~doc:
"Show what would be submitted, but don't file a pull-request"

let no_browser =
value & flag &
info ["no-browser"] ~docs ~doc:
"Disables opening the browser after submitting a pull-request"

let repo =
value & opt repo_conv ("ocaml", "opam-repository") &
info ["repo"] ~docs ~docv:"REPO" ~doc:
Expand Down Expand Up @@ -603,7 +608,7 @@ let to_files ?(split=false) ~packages_dir meta_opams =
|> List.rev

let main_term root =
let run args force tag version dry_run repo target_branch packages_dir title msg split =
let run args force tag version dry_run no_browser repo target_branch packages_dir title msg split =
let dirs, opams, urls, projects, names =
List.fold_left (fun (dirs, opams, urls, projects, names) -> function
| `Dir d -> (dirs @ [d], opams, urls, projects, names)
Expand All @@ -626,13 +631,14 @@ let main_term root =
PublishSubmit.submit
root
~dry_run
~no_browser
repo target_branch pr_title pr_body
(OpamPackage.Map.keys meta_opams)
files
in
let open Args in
Term.(pure run
$ src_args $ force $ tag $ version $ dry_run
$ src_args $ force $ tag $ version $ dry_run $ no_browser
$ repo $ target_branch $ packages_dir $ title $ msg_file $ split)


Expand Down
20 changes: 11 additions & 9 deletions src/publishSubmit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ let update_mirror root repo branch =
git_command ~dir ["reset"; "origin"/branch; "--hard"]

let add_files_and_pr
root ?(dry_run=false) repo user token title message
root ?(dry_run=false) ?(no_browser=false) repo user token title message
branch target_branch files =
let mirror = repo_dir root repo in
let () =
Expand Down Expand Up @@ -324,14 +324,16 @@ let add_files_and_pr
GH.pull_request title user token repo ~text:message branch target_branch
in
OpamConsole.msg "Pull-requested: %s\n" url;
try
let auto_open =
if OpamStd.Sys.(os () = Darwin) then "open" else "xdg-open"
in
OpamSystem.command [auto_open; url]
with OpamSystem.Command_not_found _ -> ()
if not no_browser then begin
try
let auto_open =
if OpamStd.Sys.(os () = Darwin) then "open" else "xdg-open"
in
OpamSystem.command [auto_open; url]
with OpamSystem.Command_not_found _ -> ()
end

let submit root ?dry_run repo target_branch title msg packages files =
let submit root ?dry_run ?no_browser repo target_branch title msg packages files =
(* Prepare the repo *)
let mirror_dir = repo_dir root repo in
let user, token =
Expand All @@ -346,4 +348,4 @@ let submit root ?dry_run repo target_branch title msg packages files =
(* pull-request processing *)
update_mirror root repo target_branch;
let branch = user_branch packages in
add_files_and_pr root ?dry_run repo user token title msg branch target_branch files
add_files_and_pr root ?dry_run ?no_browser repo user token title msg branch target_branch files