push_virtual_branch: Return the remote reference

Pushing a virtual branch also returns the branch refname
This commit is contained in:
estib 2024-09-10 11:12:30 +02:00
parent 041344bab5
commit f19c2158eb
3 changed files with 6 additions and 6 deletions

View File

@ -413,7 +413,7 @@ pub fn push_virtual_branch(
branch_id: BranchId,
with_force: bool,
askpass: Option<Option<BranchId>>,
) -> Result<()> {
) -> Result<Refname> {
let ctx = open_with_verify(project)?;
assure_open_workspace_mode(&ctx).context("Pushing a branch requires open workspace mode")?;
vbranch::push(&ctx, branch_id, with_force, askpass)

View File

@ -1045,7 +1045,7 @@ pub(crate) fn push(
branch_id: BranchId,
with_force: bool,
askpass: Option<Option<BranchId>>,
) -> Result<()> {
) -> Result<Refname> {
let vb_state = ctx.project().virtual_branches();
let mut vbranch = vb_state.get_branch_in_workspace(branch_id)?;
@ -1092,7 +1092,7 @@ pub(crate) fn push(
.context("failed to write target branch after push")?;
ctx.fetch(remote_branch.remote(), askpass.map(|_| "modal".to_string()))?;
Ok(())
Ok(gitbutler_reference::Refname::Remote(remote_branch))
}
struct IsCommitIntegrated<'repo> {

View File

@ -267,9 +267,9 @@ pub mod commands {
project_id: ProjectId,
branch_id: BranchId,
with_force: bool,
) -> Result<(), Error> {
) -> Result<Refname, Error> {
let project = projects.get(project_id)?;
gitbutler_branch_actions::push_virtual_branch(
let upstream_refname = gitbutler_branch_actions::push_virtual_branch(
&project,
branch_id,
with_force,
@ -277,7 +277,7 @@ pub mod commands {
)
.map_err(|err| err.context(Code::Unknown))?;
emit_vbranches(&windows, project_id);
Ok(())
Ok(upstream_refname)
}
#[tauri::command(async)]