Skip to content

Commit

Permalink
🐛 Fix wrong upstream name
Browse files Browse the repository at this point in the history
  • Loading branch information
sjquant committed Dec 12, 2022
1 parent 99f25ed commit 8651a22
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gitutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ pub fn push_tag(remote: &mut git2::Remote, tag: &str) -> Result<(), git2::Error>

pub fn push_branch(remote: &mut git2::Remote, branch: &mut Branch) -> Result<(), git2::Error> {
let branch_name = branch.name().unwrap().expect("Failed to get branch name").to_string();
branch.set_upstream(Some(branch_name.as_str()))?;
let remote_name = remote.name().unwrap();
let upstream_name = format!("{}/{}", remote_name, branch_name.as_str());
println!("Pushing branch '{}' to remote...", branch_name);
let mut po = push_options();
let refspec = format!("refs/heads/{}:refs/heads/{}", branch_name, branch_name);
remote.push(&[&refspec], Some(&mut po))?;
branch.set_upstream(Some(&upstream_name))?;
println!("Successfully pushed branch '{}' to remote.", branch_name);
Result::Ok(())
}
Expand Down

0 comments on commit 8651a22

Please sign in to comment.