Skip to content

Commit

Permalink
_cli: files always take precedence over digests
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Oct 2, 2024
1 parent 8153906 commit 7d3c48c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sigstore/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,19 @@ def _add_shared_verify_input_options(group: argparse._ArgumentGroup) -> None:
)

def file_or_digest(arg: str) -> Hashed | Path:
if arg.startswith("sha256:"):
path = Path(arg)
if path.is_file():
return path
elif arg.startswith("sha256"):
digest = bytes.fromhex(arg[len("sha256:") :])
if len(digest) != 32:
raise ValueError()
raise ValueError
return Hashed(
digest=digest,
algorithm=HashAlgorithm.SHA2_256,
)
else:
return Path(arg)
raise ValueError

group.add_argument(
"files_or_digest",
Expand Down

0 comments on commit 7d3c48c

Please sign in to comment.