Skip to content

Commit

Permalink
fix: Dump full upstream name for a branch
Browse files Browse the repository at this point in the history
  • Loading branch information
siketyan committed Dec 31, 2023
1 parent f12c2b8 commit ccadabd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cmd/sync/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Cmd {
config.git.strategy.checkout.checkout_branch(
&path,
&b.name,
format!("{}/{}", &b.remote, &b.name),
Some(b.upstream.to_string()),
)?;

info!("Successfully checked out a branch: {}", &b.name);
Expand Down
9 changes: 3 additions & 6 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::path::Path;
#[derive(Deserialize, Serialize)]
pub struct BranchRef {
pub name: String,
pub remote: String,
pub upstream: String,
}

#[derive(Deserialize, Serialize)]
Expand Down Expand Up @@ -108,18 +108,15 @@ impl Repository {
},
};

let upstream_name = upstream.name()?.unwrap().to_string();
let reference = upstream.into_reference();
if head != &reference {
bail!("Branch is not synced");
}

Ok(Ref::Branch(BranchRef {
name: name.to_string(),
remote: repo
.branch_remote_name(reference.name().unwrap())?
.as_str()
.unwrap()
.to_string(),
upstream: upstream_name,
}))
} else if head.is_tag() {
bail!("HEAD is a tag");
Expand Down

0 comments on commit ccadabd

Please sign in to comment.