mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 02:26:14 +03:00
Update base branch button feature flagged
This commit is contained in:
parent
6e7aefd5c3
commit
aeea013ba0
@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Spacer from '../shared/Spacer.svelte';
|
||||
import { Project } from '$lib/backend/projects';
|
||||
import CommitCard from '$lib/commit/CommitCard.svelte';
|
||||
import UpdateBaseButton from '$lib/components/UpdateBaseButton.svelte';
|
||||
import { projectMergeUpstreamWarningDismissed } from '$lib/config/config';
|
||||
import { getGitHost } from '$lib/gitHost/interface/gitHost';
|
||||
import { ModeService } from '$lib/modes/service';
|
||||
@ -18,6 +20,7 @@
|
||||
const branchController = getContext(BranchController);
|
||||
const modeService = getContext(ModeService);
|
||||
const gitHost = getGitHost();
|
||||
const project = getContext(Project);
|
||||
|
||||
const mode = modeService.mode;
|
||||
|
||||
@ -36,6 +39,8 @@
|
||||
showInfo('Stashed conflicting branches', infoText);
|
||||
}
|
||||
}
|
||||
|
||||
let updateBaseButton: UpdateBaseButton | undefined;
|
||||
</script>
|
||||
|
||||
<div class="wrapper">
|
||||
@ -46,16 +51,21 @@
|
||||
</div>
|
||||
|
||||
{#if base.upstreamCommits?.length > 0}
|
||||
<UpdateBaseButton bind:this={updateBaseButton} showButton={false} />
|
||||
<Button
|
||||
style="pop"
|
||||
kind="solid"
|
||||
tooltip={`Merges the commits from ${base.branchName} into the base of all applied virtual branches`}
|
||||
disabled={$mode?.type !== 'OpenWorkspace'}
|
||||
onclick={() => {
|
||||
if ($mergeUpstreamWarningDismissed) {
|
||||
updateBaseBranch();
|
||||
if (project.succeedingRebases) {
|
||||
updateBaseButton?.openModal();
|
||||
} else {
|
||||
updateTargetModal.show();
|
||||
if ($mergeUpstreamWarningDismissed) {
|
||||
updateBaseBranch();
|
||||
} else {
|
||||
updateTargetModal.show();
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
@ -1,10 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { Project } from '$lib/backend/projects';
|
||||
import { BaseBranchService } from '$lib/baseBranch/baseBranchService';
|
||||
import CommitCard from '$lib/commit/CommitCard.svelte';
|
||||
import { getGitHost } from '$lib/gitHost/interface/gitHost';
|
||||
import { showInfo } from '$lib/notifications/toasts';
|
||||
import Select from '$lib/select/Select.svelte';
|
||||
import SelectItem from '$lib/select/SelectItem.svelte';
|
||||
import { getContext } from '$lib/utils/context';
|
||||
import { BranchController } from '$lib/vbranches/branchController';
|
||||
import { VirtualBranch } from '$lib/vbranches/types';
|
||||
import {
|
||||
UpstreamIntegrationService,
|
||||
@ -18,9 +21,17 @@
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
import type { Readable } from 'svelte/store';
|
||||
|
||||
interface Props {
|
||||
showButton?: boolean;
|
||||
}
|
||||
|
||||
const { showButton = true }: Props = $props();
|
||||
|
||||
const upstreamIntegrationService = getContext(UpstreamIntegrationService);
|
||||
const baseBranchService = getContext(BaseBranchService);
|
||||
const gitHost = getGitHost();
|
||||
const branchController = getContext(BranchController);
|
||||
const project = getContext(Project);
|
||||
|
||||
const base = baseBranchService.base;
|
||||
|
||||
@ -94,7 +105,7 @@
|
||||
|
||||
let integratingUpstream = $state<'inert' | 'loading' | 'complete'>('inert');
|
||||
|
||||
function openModal() {
|
||||
export function openModal() {
|
||||
modalOpeningState = 'loading';
|
||||
integratingUpstream = 'inert';
|
||||
branchStatuses = upstreamIntegrationService.upstreamStatuses();
|
||||
@ -107,10 +118,18 @@
|
||||
async function integrate() {
|
||||
integratingUpstream = 'loading';
|
||||
await upstreamIntegrationService.integrateUpstream([...results.values()]);
|
||||
await baseBranchService.refresh();
|
||||
integratingUpstream = 'complete';
|
||||
|
||||
modal?.close();
|
||||
}
|
||||
|
||||
async function updateBaseBranch() {
|
||||
let infoText = await branchController.updateBaseBranch();
|
||||
if (infoText) {
|
||||
showInfo('Stashed conflicting branches', infoText);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:this={modal} title="Integrate upstream changes" {onClose} width="small">
|
||||
@ -179,16 +198,24 @@
|
||||
{/snippet}
|
||||
</Modal>
|
||||
|
||||
<Button
|
||||
size="tag"
|
||||
style="error"
|
||||
kind="solid"
|
||||
tooltip="Merge upstream into common base"
|
||||
onclick={openModal}
|
||||
loading={modalOpeningState === 'loading'}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
{#if showButton && ($base?.upstreamCommits.length || 0) > 0}
|
||||
<Button
|
||||
size="tag"
|
||||
style="error"
|
||||
kind="solid"
|
||||
tooltip="Merge upstream into common base"
|
||||
onclick={() => {
|
||||
if (project.succeedingRebases) {
|
||||
openModal();
|
||||
} else {
|
||||
updateBaseBranch();
|
||||
}
|
||||
}}
|
||||
loading={modalOpeningState === 'loading'}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.upstream-commits {
|
||||
|
@ -484,7 +484,6 @@ mod test {
|
||||
};
|
||||
|
||||
use gitbutler_branch::BranchOwnershipClaims;
|
||||
use gitbutler_commit::commit_headers::HasCommitHeaders;
|
||||
use tempfile::tempdir;
|
||||
use uuid::Uuid;
|
||||
|
||||
@ -620,21 +619,9 @@ mod test {
|
||||
let tempdir = tempdir().unwrap();
|
||||
let repository = git2::Repository::init(tempdir.path()).unwrap();
|
||||
let initial_commit = commit_file(&repository, None, &[("foo.txt", "bar")]);
|
||||
let old_target = dbg!(commit_file(
|
||||
&repository,
|
||||
Some(&initial_commit),
|
||||
&[("foo.txt", "baz")]
|
||||
));
|
||||
let branch_head = dbg!(commit_file(
|
||||
&repository,
|
||||
Some(&old_target),
|
||||
&[("foo.txt", "fux")]
|
||||
));
|
||||
let new_target = dbg!(commit_file(
|
||||
&repository,
|
||||
Some(&old_target),
|
||||
&[("foo.txt", "qux")]
|
||||
));
|
||||
let old_target = commit_file(&repository, Some(&initial_commit), &[("foo.txt", "baz")]);
|
||||
let branch_head = commit_file(&repository, Some(&old_target), &[("foo.txt", "fux")]);
|
||||
let new_target = commit_file(&repository, Some(&old_target), &[("foo.txt", "qux")]);
|
||||
|
||||
let branch = make_branch(branch_head.id(), branch_head.tree_id());
|
||||
|
||||
@ -674,14 +661,6 @@ mod test {
|
||||
|
||||
let head_commit = repository.find_commit(head).unwrap();
|
||||
assert_eq!(head_commit.parent(0).unwrap().id(), new_target.id());
|
||||
dbg!(&head_commit);
|
||||
dbg!(head_commit.gitbutler_headers());
|
||||
dbg!(head_commit
|
||||
.tree()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|entry| entry.clone().name().unwrap().to_owned())
|
||||
.collect::<Vec<_>>());
|
||||
assert!(head_commit.is_conflicted());
|
||||
|
||||
let head_tree = repository
|
||||
|
@ -31,7 +31,6 @@ pub fn list_snapshots(
|
||||
#[instrument(skip(projects), err(Debug))]
|
||||
pub fn restore_snapshot(
|
||||
projects: State<'_, projects::Controller>,
|
||||
handle: tauri::AppHandle,
|
||||
project_id: ProjectId,
|
||||
sha: String,
|
||||
) -> Result<(), Error> {
|
||||
|
Loading…
Reference in New Issue
Block a user