feat(git): add upstream tracking and local-only branch UI

This release adds upstream tracking for branches and a local-only
indicator in the UI.
The Git integration now exposes upstreams and supports publish flows.
This enables publishing and remote-tracking configuration.

- Introduces upstream tracking and local-only branch UI markers
- Updates toolbar to reflect publish-local state and status indicators
- Bumps version to 2026.8.3 and updates changelog
This commit is contained in:
Christoph Brandau
2026-08-13 19:32:26 +02:00
parent f43fe00873
commit b6b9964a93
11 changed files with 420 additions and 45 deletions
+36 -23
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { Check, Cherry, ChevronDown, ChevronRight, EllipsisVertical, GitBranch, GitMerge, LoaderCircle, RotateCcw, StickyNote, Tag, X } from "@lucide/svelte";
import { Check, Cherry, ChevronDown, ChevronRight, CloudOff, EllipsisVertical, GitBranch, GitMerge, LoaderCircle, RotateCcw, StickyNote, Tag, X } from "@lucide/svelte";
import type { FileStatusKind, GitCommit, GitCommitFile } from "../types";
interface GraphSegment {
@@ -30,6 +30,7 @@
kind: CommitRefKind;
current: boolean;
trackedRemote: string;
localOnly: boolean;
representedBranches: string[];
}
@@ -57,6 +58,7 @@
interface Props {
commits: GitCommit[];
localBranchNames: string[];
localBranchUpstreams: Record<string, string>;
remoteBranchNames: string[];
activeBranch: string;
activeUpstream: string;
@@ -84,6 +86,7 @@
let {
commits = [],
localBranchNames = [],
localBranchUpstreams = {},
remoteBranchNames = [],
activeBranch = "",
activeUpstream = "",
@@ -541,20 +544,17 @@
return !localBranchNameSet.has(label) && /(?:^|\/)HEAD(?:\s*->|$)/.test(ref);
}
function branchNameWithoutRemote(branch: string): string {
const slash = branch.indexOf("/");
return slash === -1 ? branch : branch.slice(slash + 1);
}
function remoteName(branch: string): string {
return branch.split("/", 1)[0] ?? branch;
}
function configuredUpstreamForBranch(local: string): string {
return localBranchUpstreams[local] ?? (local === activeBranch ? activeUpstream : "");
}
function matchingRemoteBranch(local: string, remoteBranches: string[]): string {
if (local === activeBranch && activeUpstream && remoteBranches.includes(activeUpstream)) {
return activeUpstream;
}
return remoteBranches.find((remote) => branchNameWithoutRemote(remote) === local) ?? "";
const configuredUpstream = configuredUpstreamForBranch(local);
return configuredUpstream && remoteBranches.includes(configuredUpstream) ? configuredUpstream : "";
}
function compareBranchDecorations(left: CommitBranchDecoration, right: CommitBranchDecoration): number {
@@ -594,6 +594,7 @@
const remainingRemote = [...remote];
const branches: CommitBranchDecoration[] = [...local].map((label) => {
const configuredUpstream = configuredUpstreamForBranch(label);
const trackedRemote = matchingRemoteBranch(label, remainingRemote);
if (trackedRemote) remainingRemote.splice(remainingRemote.indexOf(trackedRemote), 1);
return {
@@ -601,6 +602,7 @@
kind: "local",
current: label === activeBranch,
trackedRemote,
localOnly: !configuredUpstream,
representedBranches: trackedRemote ? [label, trackedRemote] : [label],
};
});
@@ -611,6 +613,7 @@
kind: "head",
current: true,
trackedRemote: "",
localOnly: false,
representedBranches: [],
});
}
@@ -620,6 +623,7 @@
kind: "remote" as const,
current: false,
trackedRemote: "",
localOnly: false,
representedBranches: [label],
})));
@@ -657,6 +661,7 @@
}
function branchDecorationTitle(branch: CommitBranchDecoration): string {
if (branch.localOnly) return `${branch.label} · Local only — not published yet`;
if (branch.trackedRemote) return `${branch.label} · up to date with ${branch.trackedRemote}`;
const status = branchStatusLabel(branch);
if (status) return `${branch.label} · ${status}`;
@@ -851,19 +856,26 @@
<div class="commit-ref-area">
<div class="commit-ref-strip" aria-label="Commit references">
{#if refSummary.primaryBranch}
<span
class="compact-ref-chip branch"
class:current={refSummary.primaryBranch.current}
class:remote={refSummary.primaryBranch.kind === "remote"}
title={branchDecorationTitle(refSummary.primaryBranch)}
>
<GitBranch class="compact-ref-branch-icon" size={10} aria-hidden="true" />
<span>{refSummary.primaryBranch.label}</span>
{#if branchStatusLabel(refSummary.primaryBranch)}
<small class:up-to-date={Boolean(refSummary.primaryBranch.trackedRemote)}>
{#if refSummary.primaryBranch.trackedRemote}<Check size={9} aria-hidden="true" />{/if}
{branchStatusLabel(refSummary.primaryBranch).replace(/^✓\s*/, "")}
</small>
<span class="branch-ref-cluster" class:local-only={refSummary.primaryBranch.localOnly}>
<span
class="compact-ref-chip branch"
class:current={refSummary.primaryBranch.current}
class:remote={refSummary.primaryBranch.kind === "remote"}
title={branchDecorationTitle(refSummary.primaryBranch)}
>
<GitBranch class="compact-ref-branch-icon" size={10} aria-hidden="true" />
<span>{refSummary.primaryBranch.label}</span>
{#if branchStatusLabel(refSummary.primaryBranch)}
<small class:up-to-date={Boolean(refSummary.primaryBranch.trackedRemote)}>
{#if refSummary.primaryBranch.trackedRemote}<Check size={9} aria-hidden="true" />{/if}
{branchStatusLabel(refSummary.primaryBranch).replace(/^✓\s*/, "")}
</small>
{/if}
</span>
{#if refSummary.primaryBranch.localOnly}
<span class="compact-ref-local-marker" title="This branch exists only locally and has not been published yet">
<CloudOff size={9} aria-hidden="true" />LOCAL
</span>
{/if}
</span>
{/if}
@@ -899,6 +911,7 @@
<i aria-hidden="true"></i>{branch.label}
{#if branch.current}<small>Current</small>{/if}
{#if branch.trackedRemote}<small>{branch.trackedRemote}</small>{/if}
{#if branch.localOnly}<small class="local-only"><CloudOff size={9} aria-hidden="true" />Local only</small>{/if}
</span>
{/each}
</div>