mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 22:03:30 +03:00
Redirect to branch page if there is a conflict
This commit is contained in:
parent
ed75059ee7
commit
aab5684be2
@ -11,6 +11,7 @@
|
||||
import * as toasts from '$lib/utils/toasts';
|
||||
import { BaseBranchService } from '$lib/vbranches/baseBranch';
|
||||
import { BranchController } from '$lib/vbranches/branchController';
|
||||
import { VirtualBranchService } from '$lib/vbranches/virtualBranch';
|
||||
import { marked } from 'marked';
|
||||
import type { PullRequest } from '$lib/github/types';
|
||||
import { goto } from '$app/navigation';
|
||||
@ -21,6 +22,7 @@
|
||||
const project = getContext(Project);
|
||||
const remotesService = getContext(RemotesService);
|
||||
const baseBranchService = getContext(BaseBranchService);
|
||||
const virtualBranchService = getContext(VirtualBranchService);
|
||||
|
||||
let remoteName = structuredClone(pullrequest.repoName) || '';
|
||||
let createRemoteModal: Modal | undefined;
|
||||
@ -49,7 +51,22 @@
|
||||
await branchController.createvBranchFromBranch(
|
||||
`refs/remotes/${remoteName}/${pullrequest.targetBranch}`
|
||||
);
|
||||
goto(`/${project.id}/board`);
|
||||
await virtualBranchService.reload();
|
||||
const vbranch = await virtualBranchService.getByUpstreamSha(pullrequest.sha);
|
||||
|
||||
// This is a little absurd, but it makes it soundly typed
|
||||
if (!vbranch) {
|
||||
goto(`/${project.id}/board`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Active seems to be a more reliable metric to determine whether to go to the branch page
|
||||
if (vbranch.active) {
|
||||
goto(`/${project.id}/board`);
|
||||
} else {
|
||||
goto(`/${project.id}/stashed/${vbranch.id}`);
|
||||
}
|
||||
|
||||
createRemoteModal?.close();
|
||||
} finally {
|
||||
loading = false;
|
||||
|
@ -139,6 +139,15 @@ export class VirtualBranchService {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
async getByUpstreamSha(upstreamSha: string) {
|
||||
return await firstValueFrom(
|
||||
this.branches$.pipe(
|
||||
timeout(10000),
|
||||
map((branches) => branches?.find((b) => b.upstream?.sha == upstreamSha))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function subscribeToVirtualBranches(projectId: string, callback: (branches: Branch[]) => void) {
|
||||
|
Loading…
Reference in New Issue
Block a user