mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 12:09:33 +01:00
add more success messages
This commit is contained in:
parent
d10b5172be
commit
56f0e8babf
3 changed files with 38 additions and 8 deletions
|
@ -574,8 +574,16 @@ pub async fn close_issue(
|
||||||
unset_due_date: None,
|
unset_due_date: None,
|
||||||
updated_at: None,
|
updated_at: None,
|
||||||
};
|
};
|
||||||
api.issue_edit_issue(repo.owner(), repo.name(), issue, edit)
|
let issue_data = api
|
||||||
|
.issue_edit_issue(repo.owner(), repo.name(), issue, edit)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let issue_title = issue_data
|
||||||
|
.title
|
||||||
|
.as_deref()
|
||||||
|
.ok_or_eyre("issue does not have title")?;
|
||||||
|
|
||||||
|
println!("Closed issue {issue}: \"{issue_title}\"");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
11
src/prs.rs
11
src/prs.rs
|
@ -781,6 +781,17 @@ async fn merge_pr(
|
||||||
let pr_number = pr_info.number.ok_or_eyre("pr does not have number")?;
|
let pr_number = pr_info.number.ok_or_eyre("pr does not have number")?;
|
||||||
api.repo_merge_pull_request(repo.owner(), repo.name(), pr_number, request)
|
api.repo_merge_pull_request(repo.owner(), repo.name(), pr_number, request)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let pr_title = pr_info
|
||||||
|
.title
|
||||||
|
.as_deref()
|
||||||
|
.ok_or_eyre("pr does not have title")?;
|
||||||
|
let pr_base = pr_info.base.as_ref().ok_or_eyre("pr does not have base")?;
|
||||||
|
let base_label = pr_base
|
||||||
|
.label
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_eyre("base does not have label")?;
|
||||||
|
println!("Merged PR #{pr_number} \"{pr_title}\" into `{base_label}`");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ async fn create_release(
|
||||||
let release_opt = forgejo_api::structs::CreateReleaseOption {
|
let release_opt = forgejo_api::structs::CreateReleaseOption {
|
||||||
body,
|
body,
|
||||||
draft: Some(draft),
|
draft: Some(draft),
|
||||||
name: Some(name),
|
name: Some(name.clone()),
|
||||||
prerelease: Some(prerelease),
|
prerelease: Some(prerelease),
|
||||||
tag_name,
|
tag_name,
|
||||||
target_commitish: None,
|
target_commitish: None,
|
||||||
|
@ -259,6 +259,8 @@ async fn create_release(
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Created release {name}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,23 +463,25 @@ async fn create_asset(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
println!("Added attachment `{}` to {}", asset, release);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_asset(
|
async fn delete_asset(
|
||||||
repo: &RepoName,
|
repo: &RepoName,
|
||||||
api: &Forgejo,
|
api: &Forgejo,
|
||||||
release: String,
|
release_name: String,
|
||||||
asset: String,
|
asset_name: String,
|
||||||
) -> eyre::Result<()> {
|
) -> eyre::Result<()> {
|
||||||
let release = find_release(repo, api, &release).await?;
|
let release = find_release(repo, api, &release_name).await?;
|
||||||
let assets = release
|
let assets = release
|
||||||
.assets
|
.assets
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
|
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
|
||||||
let asset = assets
|
let asset = assets
|
||||||
.iter()
|
.iter()
|
||||||
.find(|a| a.name.as_ref() == Some(&asset))
|
.find(|a| a.name.as_ref() == Some(&asset_name))
|
||||||
.ok_or_else(|| eyre!("asset not found"))?;
|
.ok_or_else(|| eyre!("asset not found"))?;
|
||||||
let release_id = release
|
let release_id = release
|
||||||
.id
|
.id
|
||||||
|
@ -487,6 +491,7 @@ async fn delete_asset(
|
||||||
.ok_or_else(|| eyre::eyre!("asset does not have id"))?;
|
.ok_or_else(|| eyre::eyre!("asset does not have id"))?;
|
||||||
api.repo_delete_release_attachment(repo.owner(), repo.name(), release_id, asset_id)
|
api.repo_delete_release_attachment(repo.owner(), repo.name(), release_id, asset_id)
|
||||||
.await?;
|
.await?;
|
||||||
|
println!("Removed attachment `{}` from {}", asset_name, release_name);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,17 +540,23 @@ async fn download_asset(
|
||||||
.to_vec()
|
.to_vec()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let output = output
|
let real_output = output
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.unwrap_or_else(|| std::path::Path::new(&asset));
|
.unwrap_or_else(|| std::path::Path::new(&asset));
|
||||||
tokio::fs::OpenOptions::new()
|
tokio::fs::OpenOptions::new()
|
||||||
.create_new(true)
|
.create_new(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(output)
|
.open(real_output)
|
||||||
.await?
|
.await?
|
||||||
.write_all(file.as_ref())
|
.write_all(file.as_ref())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
if output.is_some() {
|
||||||
|
println!("Downloaded {asset} into {}", real_output.display());
|
||||||
|
} else {
|
||||||
|
println!("Downloaded {asset}");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue