Add confirmation prompt before commiting a release
This commit is contained in:
parent
40e51f00d7
commit
affb7fbd01
1 changed files with 23 additions and 8 deletions
31
src/main.rs
31
src/main.rs
|
@ -4,6 +4,7 @@ use forgejo_api::Auth::Token;
|
||||||
use forgejo_api::Forgejo;
|
use forgejo_api::Forgejo;
|
||||||
use forgejo_api::structs::CreateReleaseOption;
|
use forgejo_api::structs::CreateReleaseOption;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
|
||||||
|
@ -36,9 +37,7 @@ enum ReleaseSubCommands {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Another sub-subcommand
|
/// Another sub-subcommand
|
||||||
List {
|
List { alias: String },
|
||||||
alias: String,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_new_release(
|
async fn handle_new_release(
|
||||||
|
@ -69,10 +68,23 @@ async fn handle_new_release(
|
||||||
e.to_string()
|
e.to_string()
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
if target.is_none() {
|
||||||
|
println!("Target not provided for creating a release.");
|
||||||
|
println!("Please confirm by typing 'yes' that you want to create automatically with the latest commit.");
|
||||||
|
|
||||||
|
let mut input = String::new();
|
||||||
|
io::stdin()
|
||||||
|
.read_line(&mut input)
|
||||||
|
.expect("Failed to read line");
|
||||||
|
if input.trim().to_lowercase() != "yes" {
|
||||||
|
return Err("Release creation cancelled by user.".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let option = CreateReleaseOption {
|
let option = CreateReleaseOption {
|
||||||
tag_name: tag.to_string(),
|
tag_name: tag.to_string(),
|
||||||
name: Some(format!("{}", tag)),
|
name: Some(format!("{}", tag)),
|
||||||
body: Some(format!("Release notes for {}", tag)),
|
body: Some(format!("Release {}", tag)),
|
||||||
hide_archive_links: Some(false),
|
hide_archive_links: Some(false),
|
||||||
target_commitish: target.clone(),
|
target_commitish: target.clone(),
|
||||||
draft: None,
|
draft: None,
|
||||||
|
@ -119,10 +131,13 @@ async fn handle_list_releases(config: &config::Config, alias: &str) -> Result<()
|
||||||
pre_release: None,
|
pre_release: None,
|
||||||
limit: Some(100),
|
limit: Some(100),
|
||||||
};
|
};
|
||||||
let result_query = forgejo.repo_list_releases(&repo.owner, &repo.repo, query).await.map_err(|e| {
|
let result_query = forgejo
|
||||||
eprintln!("Failed to list releases: {}", e);
|
.repo_list_releases(&repo.owner, &repo.repo, query)
|
||||||
e.to_string()
|
.await
|
||||||
})?;
|
.map_err(|e| {
|
||||||
|
eprintln!("Failed to list releases: {}", e);
|
||||||
|
e.to_string()
|
||||||
|
})?;
|
||||||
|
|
||||||
for release in result_query.1 {
|
for release in result_query.1 {
|
||||||
println!(
|
println!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue