Skip to main content

parse_verify_target

Function parse_verify_target 

Source
pub fn parse_verify_target(raw_target: &str) -> VerifyTarget
Expand description

Determine whether raw_target is a Git reference or an attestation path.

Rules (evaluated in order):

  1. “-” → stdin attestation
  2. Path exists on disk → attestation file
  3. Contains “..” (range notation) → git ref
  4. Is “HEAD” or matches ^[0-9a-f]{4,40}$ → git ref
  5. Otherwise → git ref (assume the user knows what they’re typing)

Args:

  • raw_target - Raw CLI input string.

Usage:

let t = parse_verify_target("HEAD");
assert!(matches!(t, VerifyTarget::GitRef(_)));