Skip to content

Commit

Permalink
Update peel error logs, and constrain its arguments (#104)
Browse files Browse the repository at this point in the history
* chore: print the number of entries in the directory while peeling

Signed-off-by: jaudiger <[email protected]>

* fix: don't try to peel with a depth of 0

Signed-off-by: jaudiger <[email protected]>

* chore: format the code with cargo fmt

Signed-off-by: jaudiger <[email protected]>

---------

Signed-off-by: jaudiger <[email protected]>
  • Loading branch information
jaudiger authored Jul 21, 2024
1 parent 51862fe commit a8b4b06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/brioche-core/src/bake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ async fn run_bake(brioche: &Brioche, recipe: Recipe, meta: &Arc<Meta>) -> anyhow
Recipe::Peel { directory, depth } => {
let mut result = bake(brioche, *directory, &scope).await?;

if depth == 0 {
anyhow::bail!("must peel at least 1 layer");
}

for _ in 0..depth {
let Artifact::Directory(dir) = result.value else {
anyhow::bail!("tried peeling non-directory artifact");
Expand All @@ -438,7 +442,7 @@ async fn run_bake(brioche: &Brioche, recipe: Recipe, meta: &Arc<Meta>) -> anyhow
};

if entries.next().is_some() {
anyhow::bail!("tried peeling directory with multiple entries");
anyhow::bail!("tried peeling {} entries of {:?}", entries.len() + 2, dir);
}

result = peeled;
Expand Down

0 comments on commit a8b4b06

Please sign in to comment.