radicle: validations

Instead of returning the unsigned references, the validation of a
repository's remotes returns the set of validation errors. The caller
is then expected to handle these validation errors appropriately, for
example, by logging them and re-raising an error.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2023-11-06 12:06:13 +01:00
committed by cloudhead
parent dfdf2e20cc
commit b503aa6be4
8 changed files with 124 additions and 44 deletions
+8 -1
View File
@@ -106,7 +106,14 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
identity.update("Publish repository", "", &doc, &signer)?;
repo.sign_refs(&signer)?;
repo.set_identity_head()?;
repo.validate()?;
let validations = repo.validate()?;
if !validations.is_empty() {
for err in validations {
term::error(format!("Error: validation error {err}"));
}
anyhow::bail!("fatal error: repository storage is corrupt");
}
term::success!(
"Repository is now {}",