Skip to content

Commit 261ee3d

Browse files
committed
Add default response to prompt on CI
1 parent 864900c commit 261ee3d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/bin/josh_sync.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ fn load_context(config_path: &Path, rust_version_path: &Path) -> anyhow::Result<
131131

132132
fn maybe_create_gh_pr(repo: &str, title: &str, description: &str) -> anyhow::Result<bool> {
133133
if which::which("gh").is_ok()
134-
&& prompt("Do you want to create a rustc pull PR using the `gh` tool?")
134+
&& prompt(
135+
"Do you want to create a rustc pull PR using the `gh` tool?",
136+
false,
137+
)
135138
{
136139
std::process::Command::new("gh")
137140
.args(&[

src/utils.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ pub fn ensure_clean_git_state() {
4040
}
4141

4242
/// Ask a prompt to user and return true if they responded with `y`.
43-
pub fn prompt(prompt: &str) -> bool {
43+
/// Returns `default_response` on CI.
44+
pub fn prompt(prompt: &str, default_response: bool) -> bool {
4445
// Do not run interactive prompts on CI
4546
if std::env::var("GITHUB_ACTIONS").as_deref() == Ok("1") {
46-
return false;
47+
return default_response;
4748
}
4849

4950
println!("{prompt} [y/n]");

0 commit comments

Comments
 (0)