Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ the index, or `--include-untracked` to select a new, non-ignored file. The
command preserves the real index and applies the usual secret preflight.
It cannot be combined with pushed-commit, range or pull-request review.

`proofline status` also says whether `proofline review` can run in this
checkout: the repository is connected, setup is finished, and a ready
environment links the repository. Open setup blockers are the reason when it
cannot. Setup needs `setup:write`; without it, status says it cannot tell.
`--json` prints the same report for agents. The exit code still reflects only
the token.

Read all recorded runs with `proofline history --repo owner/name --pr 7`.
`proofline rerun REVIEW_ID` requests the original immutable subject and waits;
`--no-wait` returns its link. Reruns require `reviews:rerun`.
Expand Down
8 changes: 8 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub enum ApiError {
origin: String,
status: u16,
detail: String,
/// The `refusal.reason` of a review request that created nothing.
refusal: Option<String>,
},
#[error("could not reach {origin}: {reason}")]
Transport { origin: String, reason: String },
Expand Down Expand Up @@ -119,6 +121,7 @@ impl ApiError {
struct Problem {
title: Option<String>,
detail: Option<String>,
refusal: Option<serde_json::Value>,
}

/// A response that arrived with an HTTP status, and its bounded body.
Expand Down Expand Up @@ -269,6 +272,10 @@ impl Http {

pub fn problem(&self, reply: &Reply) -> ApiError {
let parsed = serde_json::from_slice::<Problem>(&reply.body).ok();
let refusal = parsed
.as_ref()
.and_then(|problem| problem.refusal.as_ref()?.get("reason")?.as_str())
.map(str::to_owned);
let detail = parsed
.and_then(|problem| problem.detail.or(problem.title))
.map_or_else(
Expand All @@ -285,6 +292,7 @@ impl Http {
origin: self.origin.to_string(),
status: reply.status.as_u16(),
detail,
refusal,
}
}

Expand Down
18 changes: 14 additions & 4 deletions src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use crate::outcome::{self, Outcome};
use crate::render::location;
use crate::severity::Severity;
use crate::text::one_line;
use crate::{RepositoryArgs, Verdict, connect, connected_repository, preflight, read_review, say};
use crate::{
RepositoryArgs, Verdict, connect, connected_repository, preflight, read_review, refused, say,
};

/// Identifies a script this CLI wrote. Uninstall removes a hook only when its
/// whole text is the script this version writes, so an edited hook stays.
Expand Down Expand Up @@ -485,14 +487,17 @@ async fn request(
deadline: tokio::time::Instant,
) -> Report {
let requested = async {
let (_, repository_id) = connected_repository(api, repository).await?;
let (name, repository_id) = connected_repository(api, repository).await?;
let request = PatchReviewRequest {
base_commit_sha: changes.base_commit_sha,
patch: changes.patch,
trigger_source: Some(hook.trigger_source()),
verify_finding_ids: Vec::new(),
};
let requested = api.request_patch_review(repository_id, &request).await?;
let requested = api
.request_patch_review(repository_id, &request)
.await
.map_err(|error| refused(error, api.origin(), &name))?;
let (_, detail, state) =
read_review(api, requested.review_id, Some(deadline), false).await?;
anyhow::Ok((requested.review_id, detail, state))
Expand Down Expand Up @@ -550,7 +555,12 @@ fn conclude(
gap = true;
say(&format!(
"Proofline could not review {label}: {}",
one_line(reason)
reason
.lines()
.filter(|line| !line.trim().is_empty())
.map(one_line)
.collect::<Vec<_>>()
.join("; ")
));
}
Report::Read {
Expand Down
Loading