hive-forge: defer repo resolution to the accessor, not construction
This commit is contained in:
parent
cc2503d9c7
commit
fe7bf81d4a
14 changed files with 57 additions and 35 deletions
|
|
@ -82,7 +82,7 @@ fn resolve_run_id(client: &Client, repo: &str, run_number: u64) -> Result<i64> {
|
|||
/// download fails (network, or a non-2xx status such as `404` for an
|
||||
/// unknown artifact name), or if the output path can't be written.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
let run_id = resolve_run_id(client, repo, args.run)?;
|
||||
let url = client.web_url(&format!(
|
||||
"/{repo}/actions/runs/{run_id}/artifacts/{}",
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ fn persisted_logs(client: &Client, repo: &str, args: &Args) -> Result<bool> {
|
|||
/// (network, an unknown run number, or a non-2xx), if a requested `--step`
|
||||
/// is out of range, or if both sources yield no log content.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
let stream_path = format!("/{repo}/actions/runs/{}/jobs/{}", args.run, args.job);
|
||||
|
||||
// `--step` only has meaning against the live streamer's per-step
|
||||
|
|
@ -259,7 +259,10 @@ fn no_log_message(client: &Client, args: &Args) -> String {
|
|||
ones) or that the dispatch that was meant to create it actually \
|
||||
landed.",
|
||||
args.run,
|
||||
client.repo(),
|
||||
// `run` already resolved a repo successfully before calling
|
||||
// this far into the log lookup, so this can't actually be
|
||||
// absent — the fallback text is defensive, not a real path.
|
||||
client.repo().unwrap_or("<unknown repo>"),
|
||||
),
|
||||
// The existence lookup itself failed (network, auth) — don't let a
|
||||
// secondary failure mask the original "no log" finding.
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ pub struct Args {
|
|||
/// missing its ref), or if the dispatch POST fails (network, or a non-2xx
|
||||
/// such as `404` for an unknown workflow file or branch).
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
let (workflow, branch) = match (args.pr, args.run, args.branch.as_deref()) {
|
||||
(Some(pr), _, _) => (args.workflow.clone(), branch_for_pr(client, pr)?),
|
||||
(_, Some(run), _) => resolve_run(client, repo, run, &args.workflow)?,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
}
|
||||
|
||||
if runs.is_empty() {
|
||||
println!("no matching runs in {}", client.repo());
|
||||
println!("no matching runs in {}", client.repo()?);
|
||||
return Ok(());
|
||||
}
|
||||
for run in &runs {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ pub struct Args {
|
|||
/// Returns an error if the `git clone` shellout fails (bad repo, auth
|
||||
/// rejected, network) or the destination can't be derived.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
let dest = match args.dest {
|
||||
Some(d) => d,
|
||||
None => repo
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub struct Args {
|
|||
/// writing the response to stdout.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let body = body::resolve_required(args.body.as_deref(), args.body_file.as_deref(), "comment")?;
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
|
||||
if !args.force {
|
||||
// Degrade open: a transport failure checking notifications must
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ pub struct Args {
|
|||
}
|
||||
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
// Truncation info: what sits outside the window we're about to show.
|
||||
// A `--tail` window has nothing after it (it ends at the thread's
|
||||
// current end); a `--limit`/default window has nothing before it (it
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
// Guard the add path only — withdrawing a request is always safe.
|
||||
// Re-requesting from someone who already reviewed dismisses that review
|
||||
// instead of no-op'ing (see the module doc-comment above).
|
||||
if let Some(existing) = super::latest_reviews(client, client.repo(), args.number)?
|
||||
if let Some(existing) = super::latest_reviews(client, client.repo()?, args.number)?
|
||||
.into_iter()
|
||||
.find(|r| r.login == args.user && !r.superseded())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ pub struct Args {
|
|||
/// merge POST itself returns a non-2xx (e.g. Forgejo `405` when the PR cannot
|
||||
/// be merged).
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
let (owner, name) = client.owner_repo()?;
|
||||
let idx = index(args.number)?;
|
||||
let pull = client
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ pub struct Args {
|
|||
/// not-ready verdict is NOT an error — it's reported and reflected in
|
||||
/// the process exit code instead.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
match (args.pr, args.sha) {
|
||||
(Some(pr), _) => pr_status(client, repo, pr),
|
||||
(None, Some(sha)) => sha_status(client, &sha),
|
||||
|
|
@ -192,7 +192,7 @@ pub(crate) fn fetch_combined_in(client: &Client, repo: &str, sha: &str) -> Resul
|
|||
/// Statuses ride as their API-shape JSON so the render helpers stay
|
||||
/// pure `Value` walkers.
|
||||
fn fetch_combined(client: &Client, sha: &str) -> Result<(String, Vec<Value>)> {
|
||||
let combined = fetch_combined_in(client, client.repo(), sha)?;
|
||||
let combined = fetch_combined_in(client, client.repo()?, sha)?;
|
||||
Ok((combined.state, combined.statuses))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ pub struct Args {
|
|||
/// permission on the repo, token missing/invalid) and any I/O error from
|
||||
/// writing the confirmation to stdout.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
let (owner, name) = client.owner_repo()?;
|
||||
let perm = args.permission.as_api();
|
||||
client
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub struct Args {
|
|||
}
|
||||
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let repo = client.repo()?;
|
||||
// Reading the thread clears its unread notification so the
|
||||
// read-before-comment guard (in `comment`) lets a reply through.
|
||||
notify::mark_read_best_effort(client, repo, args.number);
|
||||
|
|
|
|||
Loading…
Reference in a new issue