forked from mirrors/jj
cli: delete branch from git remote when pushing locally deleted branch
This commit is contained in:
parent
e57948347e
commit
8b8aff171e
2 changed files with 13 additions and 1 deletions
|
@ -190,6 +190,17 @@ pub fn push_commit(
|
|||
result
|
||||
}
|
||||
|
||||
pub fn delete_remote_branch(
|
||||
git_repo: &git2::Repository,
|
||||
remote_name: &str,
|
||||
remote_branch: &str,
|
||||
) -> Result<(), GitPushError> {
|
||||
// Need to add "refs/heads/" prefix due to https://github.com/libgit2/libgit2/issues/1125
|
||||
let qualified_remote_branch = format!("refs/heads/{}", remote_branch);
|
||||
let refspec = format!(":{}", qualified_remote_branch);
|
||||
push_ref(git_repo, remote_name, &qualified_remote_branch, &refspec)
|
||||
}
|
||||
|
||||
fn push_ref(
|
||||
git_repo: &git2::Repository,
|
||||
remote_name: &str,
|
||||
|
|
|
@ -2615,7 +2615,8 @@ fn cmd_git_push(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: Delete remote branch if the local branch was deleted
|
||||
git::delete_remote_branch(&git_repo, remote_name, branch_name)
|
||||
.map_err(|err| CommandError::UserError(err.to_string()))?;
|
||||
}
|
||||
let mut tx = repo_command.start_transaction("import git refs");
|
||||
git::import_refs(tx.mut_repo(), &git_repo)
|
||||
|
|
Loading…
Reference in a new issue