Skip to content

Commit

Permalink
Merge pull request #156 from fabriziosestito/fix/add-latest-tag-when-…
Browse files Browse the repository at this point in the history
…no-tag

fix: add latest tag when no tag is present
  • Loading branch information
fabriziosestito authored Sep 11, 2023
2 parents 3a2020a + e137ca9 commit c6c40fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub async fn fetch_policy(
"registry" | "http" | "https" => Ok(()),
_ => Err(anyhow!("unknown scheme: {}", url.scheme())),
}?;
let (store, destination) = pull_destination(&url, &destination)?;
let (store, mut destination) = pull_destination(&url, &destination)?;
if let Some(store) = store {
store.ensure(&store.policy_full_path(url.as_str(), store::PolicyPath::PrefixOnly)?)?;
}
Expand All @@ -107,6 +107,11 @@ pub async fn fetch_policy(
local_path: destination,
});
}
// If the reference tag is `latest` and the URL does not contain `:latest`
// we need to add it to the destination
if Some("latest") == reference.tag() && !str::ends_with(url.as_str(), ":latest") {
destination = PathBuf::from(destination.to_string_lossy().to_string() + ":latest");
}
}
"http" | "https" => {
if Path::exists(&destination) {
Expand Down

0 comments on commit c6c40fe

Please sign in to comment.