aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2025-03-26 13:36:23 +0100
committerMax Audron <audron@cocaine.farm>2025-03-26 13:36:23 +0100
commita1e95c48b8be0ab36e3631b582a11d6894551d48 (patch)
treec82ace63837e4efd25a5af4180e4bbd67d3a166b
parentupdate dependencies and rust version (diff)
fix wrong ref being updated on checkout if branch contained slash
-rw-r--r--src/repo/git/mod.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/repo/git/mod.rs b/src/repo/git/mod.rs
index 65f4022..b88a13f 100644
--- a/src/repo/git/mod.rs
+++ b/src/repo/git/mod.rs
@@ -57,8 +57,10 @@ impl Repo {
debug!("got ref to origin: {:?}", origin_ref);
if let Some(origin_ref) = origin_ref.target().try_name() {
- let shortened = origin_ref.shorten().to_owned();
- Ok(shortened.split(|x| *x == b'/').last().unwrap().into())
+ let shortened = origin_ref.shorten().to_string();
+
+ let strip: String = format!("{}/", remote_name.as_bstr());
+ Ok(shortened.strip_prefix(&strip).unwrap().into())
} else {
Err(RepoError::NoDefaultBranch)
}