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 a --no-confirmation option #158

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions src/publishMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ module Args = struct
and `descr`). This can be useful on legacy repositories, but is \
deprecated."

let no_confirmation =
value & flag &
info ["no-confirmation"] ~docs ~doc:
"Skip all confirmations. This should only ever be used in very special circumstances, like automated publishing CI workflows where measures to ensure the submission has been reviewed have already taken place."
end

let identical f = function
Expand Down Expand Up @@ -650,7 +654,7 @@ let to_files ?(split=false) ~packages_dir meta_opams =
let main_term root =
let run
args force tag version dry_run output_patch no_browser repo
target_branch packages_dir title msg split =
target_branch packages_dir title msg split no_confirmation =
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 @@ -661,6 +665,13 @@ let main_term root =
([], [], [], [], [])
args
in
if no_confirmation then
if OpamStd.Sys.tty_in then
OpamConsole.error_and_exit `Bad_arguments
"'--no-confirmation' is not allowed in interactive mode. Please \
review before submitting"
else
OpamCoreConfig.update ~confirm_level:`unsafe_yes ();
kit-ty-kate marked this conversation as resolved.
Show resolved Hide resolved
let meta_opams =
get_opams force dirs opams urls projects tag names version
in
Expand All @@ -685,7 +696,8 @@ let main_term root =
let open Args in
Term.(const run
$ src_args $ force $ tag $ version $ dry_run $ output_patch $ no_browser
$ repo $ target_branch $ packages_dir $ title $ msg_file $ split)
$ repo $ target_branch $ packages_dir $ title $ msg_file $ split
$ no_confirmation)


let main_info =
Expand Down
3 changes: 2 additions & 1 deletion src/publishSubmit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ let add_files_and_pr
(fst repo) (snd repo) (OpamFilename.to_string out)
end;
if output_patch <> None || dry_run then OpamStd.Sys.exit_because `Success;
if not (OpamConsole.confirm "\nFile a pull-request for this patch ?") then
if not (OpamConsole.confirm ~require_unsafe_yes:true
"\nFile a pull-request for this patch ?") then
OpamStd.Sys.exit_because `Aborted;
let url =
GH.pull_request title user token repo ~text:message branch target_branch
Expand Down