mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-20 08:01:46 +03:00
Merge pull request #4800 from gitbutlerapp/update-change-reference-for-branch
add api for updating change references
This commit is contained in:
commit
717078dc44
@ -118,7 +118,7 @@ export class BranchController {
|
||||
/*
|
||||
* Pushes a change reference to (converted to a git reference to a commit) to the remote
|
||||
* @param branchId
|
||||
* @param reference in the format refs/remotes/origin/my-branch (must be remote)
|
||||
* @param reference in the format refs/remotes/origin/my-branch (must be remote, must already exist)
|
||||
* @param changeId The change id that is being pushed
|
||||
*/
|
||||
async pushChangeReference(branchId: string, referenceName: string, withForce: boolean = false) {
|
||||
@ -134,6 +134,25 @@ export class BranchController {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates a change reference to point to a new change
|
||||
* @param branchId
|
||||
* @param reference in the format refs/remotes/origin/my-branch (must be remote, must already exist)
|
||||
* @param newChangeId The change id to point the reference to
|
||||
*/
|
||||
async updateChangeReference(branchId: string, referenceName: string, newChangeId: string) {
|
||||
try {
|
||||
await invoke<void>('update_change_reference', {
|
||||
projectId: this.projectId,
|
||||
branchId: branchId,
|
||||
name: referenceName,
|
||||
newChangeId: newChangeId
|
||||
});
|
||||
} catch (err) {
|
||||
showError('Failed to update change reference', err);
|
||||
}
|
||||
}
|
||||
|
||||
async updateBranchRemoteName(branchId: string, upstream: string) {
|
||||
try {
|
||||
await invoke<void>('update_virtual_branch', {
|
||||
|
@ -401,6 +401,17 @@ impl VirtualBranchActions {
|
||||
gitbutler_repo::push_change_reference(&ctx, branch_id, name, with_force, &helper)
|
||||
}
|
||||
|
||||
pub fn update_change_reference(
|
||||
&self,
|
||||
project: &Project,
|
||||
branch_id: BranchId,
|
||||
name: ReferenceName,
|
||||
new_change_id: String,
|
||||
) -> Result<ChangeReference> {
|
||||
let ctx = open_with_verify(project)?;
|
||||
gitbutler_repo::update_change_reference(&ctx, branch_id, name, new_change_id)
|
||||
}
|
||||
|
||||
pub fn reorder_commit(
|
||||
&self,
|
||||
project: &Project,
|
||||
|
@ -175,6 +175,7 @@ fn main() {
|
||||
virtual_branches::commands::insert_blank_commit,
|
||||
virtual_branches::commands::create_change_reference,
|
||||
virtual_branches::commands::push_change_reference,
|
||||
virtual_branches::commands::update_change_reference,
|
||||
virtual_branches::commands::reorder_commit,
|
||||
virtual_branches::commands::update_commit_message,
|
||||
virtual_branches::commands::list_remote_branches,
|
||||
|
@ -428,6 +428,22 @@ pub mod commands {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(projects, windows), err(Debug))]
|
||||
pub fn update_change_reference(
|
||||
windows: State<'_, WindowState>,
|
||||
projects: State<'_, projects::Controller>,
|
||||
project_id: ProjectId,
|
||||
branch_id: BranchId,
|
||||
name: ReferenceName,
|
||||
new_change_id: String,
|
||||
) -> Result<(), Error> {
|
||||
let project = projects.get(project_id)?;
|
||||
VirtualBranchActions.update_change_reference(&project, branch_id, name, new_change_id)?;
|
||||
emit_vbranches(&windows, project_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(projects, windows), err(Debug))]
|
||||
pub fn reorder_commit(
|
||||
|
Loading…
Reference in New Issue
Block a user