Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Location {
// We need to do this setup in two steps since otherwise
// "gittag:https://github.com/orgs/repo:v1.2.0" would not be parseable
// and split the <url> string itself in two parts
let (mut location_type, remaining) = location.split_once(':').ok_or_else(|| {
let (location_type, remaining) = location.split_once(':').ok_or_else(|| {
format!(
"Invalid location format: '{}'. Expected \
'latesttag:<selector>', or 'gittag/gitcommit/gitbranch/local:...'",
Expand All @@ -135,18 +135,16 @@ impl Location {

// If the remaining part contains another ':', the portion before the last ':'
// is the URL and everything after is the value (handles HTTPS URLs with colons).
let (url, mut selector) = if let Some(colon_pos) = remaining.rfind(':') {
let (url, selector) = if let Some(colon_pos) = remaining.rfind(':') {
(&remaining[..colon_pos], &remaining[colon_pos + 1..])
} else {
(default_url, remaining)
};

// Special case: latesttag resolution into GitTag
let resolved_tag; // must outlive the match below
if location_type == "latesttag" {
resolved_tag = Self::resolve_latest_tag(url, selector)?;
selector = resolved_tag.as_str();
location_type = "gittag";
let tag = Self::resolve_latest_tag(url, selector)?;
return Ok(("gittag".into(), url.into(), tag));
}

Ok((location_type.into(), url.into(), selector.into()))
Expand Down