hive-forge: dedup the --json refusal into refuse_json(), test it, cover attachment-get/artifact-get too
This commit is contained in:
parent
e0ad3a567b
commit
e18497bb70
1 changed files with 58 additions and 27 deletions
|
|
@ -1,11 +1,12 @@
|
|||
//! `tree-sha <ref> [repo]` — print the tree SHA of the commit at a
|
||||
//! branch name or commit SHA.
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use anyhow::Result;
|
||||
use clap::Args as ClapArgs;
|
||||
use forgejo_api::structs::RepoGetSingleCommitQuery;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::verbs::refuse_json;
|
||||
|
||||
#[derive(ClapArgs)]
|
||||
pub struct Args {
|
||||
|
|
@ -14,9 +15,7 @@ pub struct Args {
|
|||
}
|
||||
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
if client.json_mode() {
|
||||
bail!("hive-forge tree-sha: --json is not supported for this verb, only the plain sha");
|
||||
}
|
||||
refuse_json(client.json_mode(), "tree-sha", "only the plain sha")?;
|
||||
let (owner, name) = client.owner_repo()?;
|
||||
// Try branch first; the bash helper silently treats failure as
|
||||
// "not a branch, use the reference as a commit sha directly".
|
||||
|
|
|
|||
Loading…
Reference in a new issue