Skip to content

Commit

Permalink
Merge pull request #110 from phated/open-browser-option
Browse files Browse the repository at this point in the history
Add --no-browser flag
  • Loading branch information
rjbou authored Sep 18, 2020
2 parents 310d295 + ca33424 commit 407046a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
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

0 comments on commit 407046a

Please sign in to comment.