Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
724ecbed7e | ||
|
|
067c5c77a4 |
No files matched your search
@@ -272,11 +272,12 @@ describe("git integration", () => {
|
|||||||
|
|
||||||
await checkoutGitBranch({ cwd: source.path, branch: featureBranch });
|
await checkoutGitBranch({ cwd: source.path, branch: featureBranch });
|
||||||
const core = new GitCoreService();
|
const core = new GitCoreService();
|
||||||
const details = await core.statusDetails(source.path);
|
await vi.waitFor(async () => {
|
||||||
|
const details = await core.statusDetails(source.path);
|
||||||
expect(details.branch).toBe(featureBranch);
|
expect(details.branch).toBe(featureBranch);
|
||||||
expect(details.aheadCount).toBe(0);
|
expect(details.aheadCount).toBe(0);
|
||||||
expect(details.behindCount).toBe(1);
|
expect(details.behindCount).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps checkout successful when upstream refresh fails", async () => {
|
it("keeps checkout successful when upstream refresh fails", async () => {
|
||||||
@@ -320,7 +321,9 @@ describe("git integration", () => {
|
|||||||
await expect(core.checkoutBranch({ cwd: source.path, branch: featureBranch })).resolves.toBe(
|
await expect(core.checkoutBranch({ cwd: source.path, branch: featureBranch })).resolves.toBe(
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect(core.refreshFetchAttempts).toBe(1);
|
await vi.waitFor(() => {
|
||||||
|
expect(core.refreshFetchAttempts).toBe(1);
|
||||||
|
});
|
||||||
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
|
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -362,6 +365,9 @@ describe("git integration", () => {
|
|||||||
|
|
||||||
const core = new FetchRecordingGitCoreService();
|
const core = new FetchRecordingGitCoreService();
|
||||||
await core.checkoutBranch({ cwd: source.path, branch: featureBranch });
|
await core.checkoutBranch({ cwd: source.path, branch: featureBranch });
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(core.fetchArgs).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
|
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
|
||||||
expect(core.fetchArgs).toEqual([
|
expect(core.fetchArgs).toEqual([
|
||||||
@@ -373,6 +379,67 @@ describe("git integration", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns checkout result before background upstream refresh completes", async () => {
|
||||||
|
await using remote = await makeTmpDir();
|
||||||
|
await using source = await makeTmpDir();
|
||||||
|
await git(remote.path, "init --bare");
|
||||||
|
|
||||||
|
await initRepoWithCommit(source.path);
|
||||||
|
const defaultBranch = (await listGitBranches({ cwd: source.path })).branches.find(
|
||||||
|
(branch) => branch.current,
|
||||||
|
)!.name;
|
||||||
|
await git(source.path, `remote add origin ${JSON.stringify(remote.path)}`);
|
||||||
|
await git(source.path, `push -u origin ${defaultBranch}`);
|
||||||
|
|
||||||
|
const featureBranch = "feature/background-refresh";
|
||||||
|
await git(source.path, `checkout -b ${featureBranch}`);
|
||||||
|
await writeFile(path.join(source.path, "feature.txt"), "feature base\n");
|
||||||
|
await git(source.path, "add feature.txt");
|
||||||
|
await git(source.path, "commit -m 'feature base'");
|
||||||
|
await git(source.path, `push -u origin ${featureBranch}`);
|
||||||
|
await git(source.path, `checkout ${defaultBranch}`);
|
||||||
|
|
||||||
|
class SlowRefreshGitCoreService extends GitCoreService {
|
||||||
|
fetchStarted = false;
|
||||||
|
private readonly waitForReleasePromise: Promise<void>;
|
||||||
|
private releaseWait: () => void = () => undefined;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.waitForReleasePromise = new Promise<void>((resolve) => {
|
||||||
|
this.releaseWait = resolve;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseFetch(): void {
|
||||||
|
this.releaseWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
override async git(
|
||||||
|
cwd: string,
|
||||||
|
args: readonly string[],
|
||||||
|
allowNonZeroExit = false,
|
||||||
|
): Promise<void> {
|
||||||
|
if (args[0] === "fetch") {
|
||||||
|
this.fetchStarted = true;
|
||||||
|
await this.waitForReleasePromise;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await super.git(cwd, args, allowNonZeroExit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const core = new SlowRefreshGitCoreService();
|
||||||
|
await expect(core.checkoutBranch({ cwd: source.path, branch: featureBranch })).resolves.toBe(
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(core.fetchStarted).toBe(true);
|
||||||
|
});
|
||||||
|
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
|
||||||
|
core.releaseFetch();
|
||||||
|
});
|
||||||
|
|
||||||
it("throws when branch does not exist", async () => {
|
it("throws when branch does not exist", async () => {
|
||||||
await using tmp = await makeTmpDir();
|
await using tmp = await makeTmpDir();
|
||||||
await initRepoWithCommit(tmp.path);
|
await initRepoWithCommit(tmp.path);
|
||||||
|
|||||||
@@ -587,11 +587,8 @@ export class GitCoreService {
|
|||||||
timeoutMs: 10_000,
|
timeoutMs: 10_000,
|
||||||
fallbackErrorMessage: "git checkout failed",
|
fallbackErrorMessage: "git checkout failed",
|
||||||
});
|
});
|
||||||
try {
|
// Refresh upstream refs in the background so checkout remains responsive.
|
||||||
await this.refreshCheckedOutBranchUpstream(input.cwd);
|
void this.refreshCheckedOutBranchUpstream(input.cwd).catch(() => undefined);
|
||||||
} catch {
|
|
||||||
// Best effort: checkout already succeeded, so avoid surfacing refresh failures.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async initRepo(input: GitInitInput): Promise<void> {
|
async initRepo(input: GitInitInput): Promise<void> {
|
||||||
|
|||||||
@@ -320,6 +320,18 @@ describe("when: branch is behind upstream", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when: branch has diverged from upstream", () => {
|
||||||
|
it("resolveQuickAction returns a disabled sync hint", () => {
|
||||||
|
const quick = resolveQuickAction(status({ aheadCount: 2, behindCount: 1 }), false);
|
||||||
|
assert.deepEqual(quick, {
|
||||||
|
label: "Sync branch",
|
||||||
|
disabled: true,
|
||||||
|
kind: "show_hint",
|
||||||
|
hint: "Branch has diverged from upstream. Rebase/merge first.",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("when: working tree has local changes", () => {
|
describe("when: working tree has local changes", () => {
|
||||||
it("resolveQuickAction returns commit, push, and create PR", () => {
|
it("resolveQuickAction returns commit, push, and create PR", () => {
|
||||||
const quick = resolveQuickAction(status({ hasWorkingTreeChanges: true }), false);
|
const quick = resolveQuickAction(status({ hasWorkingTreeChanges: true }), false);
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ export function resolveQuickAction(
|
|||||||
const hasOpenPr = gitStatus.openPr !== null;
|
const hasOpenPr = gitStatus.openPr !== null;
|
||||||
const isAhead = gitStatus.aheadCount > 0;
|
const isAhead = gitStatus.aheadCount > 0;
|
||||||
const isBehind = gitStatus.behindCount > 0;
|
const isBehind = gitStatus.behindCount > 0;
|
||||||
|
const isDiverged = isAhead && isBehind;
|
||||||
|
|
||||||
if (!hasBranch) {
|
if (!hasBranch) {
|
||||||
return {
|
return {
|
||||||
@@ -203,6 +204,15 @@ export function resolveQuickAction(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDiverged) {
|
||||||
|
return {
|
||||||
|
label: "Sync branch",
|
||||||
|
disabled: true,
|
||||||
|
kind: "show_hint",
|
||||||
|
hint: "Branch has diverged from upstream. Rebase/merge first.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (isBehind) {
|
if (isBehind) {
|
||||||
return {
|
return {
|
||||||
label: "Pull",
|
label: "Pull",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { type GitStatusResult, type GitStackedAction, type NativeApi } from "@t3tools/contracts";
|
import { type GitStatusResult, type GitStackedAction, type NativeApi } from "@t3tools/contracts";
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
|
import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
|
||||||
import { GitHubIcon } from "./Icons";
|
import { GitHubIcon } from "./Icons";
|
||||||
import {
|
import {
|
||||||
@@ -154,6 +154,16 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
const { data: branchList = null } = useQuery(gitBranchesQueryOptions(api, gitCwd));
|
const { data: branchList = null } = useQuery(gitBranchesQueryOptions(api, gitCwd));
|
||||||
// Default to true while loading so we don't flash init controls.
|
// Default to true while loading so we don't flash init controls.
|
||||||
const isRepo = branchList?.isRepo ?? true;
|
const isRepo = branchList?.isRepo ?? true;
|
||||||
|
const currentBranch = branchList?.branches.find((branch) => branch.current)?.name ?? null;
|
||||||
|
const isGitStatusOutOfSync =
|
||||||
|
!!gitStatus?.branch && !!currentBranch && gitStatus.branch !== currentBranch;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isGitStatusOutOfSync) return;
|
||||||
|
void invalidateGitQueries(queryClient);
|
||||||
|
}, [isGitStatusOutOfSync, queryClient]);
|
||||||
|
|
||||||
|
const gitStatusForActions = isGitStatusOutOfSync ? null : gitStatus;
|
||||||
|
|
||||||
const initMutation = useMutation(gitInitMutationOptions({ api, cwd: gitCwd, queryClient }));
|
const initMutation = useMutation(gitInitMutationOptions({ api, cwd: gitCwd, queryClient }));
|
||||||
|
|
||||||
@@ -164,19 +174,19 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
|
|
||||||
const isGitActionRunning = runImmediateGitActionMutation.isPending || pullMutation.isPending;
|
const isGitActionRunning = runImmediateGitActionMutation.isPending || pullMutation.isPending;
|
||||||
const isDefaultBranch = useMemo(() => {
|
const isDefaultBranch = useMemo(() => {
|
||||||
const currentBranch = gitStatus?.branch;
|
const branchName = gitStatusForActions?.branch;
|
||||||
if (!currentBranch) return false;
|
if (!branchName) return false;
|
||||||
const current = branchList?.branches.find((branch) => branch.name === currentBranch);
|
const current = branchList?.branches.find((branch) => branch.name === branchName);
|
||||||
return current?.isDefault ?? (currentBranch === "main" || currentBranch === "master");
|
return current?.isDefault ?? (branchName === "main" || branchName === "master");
|
||||||
}, [branchList?.branches, gitStatus?.branch]);
|
}, [branchList?.branches, gitStatusForActions?.branch]);
|
||||||
|
|
||||||
const gitActionMenuItems = useMemo(
|
const gitActionMenuItems = useMemo(
|
||||||
() => buildMenuItems(gitStatus, isGitActionRunning),
|
() => buildMenuItems(gitStatusForActions, isGitActionRunning),
|
||||||
[gitStatus, isGitActionRunning],
|
[gitStatusForActions, isGitActionRunning],
|
||||||
);
|
);
|
||||||
const quickAction = useMemo(
|
const quickAction = useMemo(
|
||||||
() => resolveQuickAction(gitStatus, isGitActionRunning, isDefaultBranch),
|
() => resolveQuickAction(gitStatusForActions, isGitActionRunning, isDefaultBranch),
|
||||||
[gitStatus, isDefaultBranch, isGitActionRunning],
|
[gitStatusForActions, isDefaultBranch, isGitActionRunning],
|
||||||
);
|
);
|
||||||
const quickActionDisabledReason = quickAction.disabled
|
const quickActionDisabledReason = quickAction.disabled
|
||||||
? (quickAction.hint ?? "This action is currently unavailable.")
|
? (quickAction.hint ?? "This action is currently unavailable.")
|
||||||
@@ -185,14 +195,17 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
const maybeConfirmPushToDefaultBranch = useCallback(
|
const maybeConfirmPushToDefaultBranch = useCallback(
|
||||||
async (action: GitStackedAction): Promise<boolean> => {
|
async (action: GitStackedAction): Promise<boolean> => {
|
||||||
if (!api) return false;
|
if (!api) return false;
|
||||||
if (!requiresDefaultBranchConfirmation(action, isDefaultBranch) || !gitStatus?.branch) {
|
if (
|
||||||
|
!requiresDefaultBranchConfirmation(action, isDefaultBranch) ||
|
||||||
|
!gitStatusForActions?.branch
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return api.dialogs.confirm(
|
return api.dialogs.confirm(
|
||||||
`You're about to push to the default branch "${gitStatus.branch}". Continue?`,
|
`You're about to push to the default branch "${gitStatusForActions.branch}". Continue?`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[api, gitStatus?.branch, isDefaultBranch],
|
[api, gitStatusForActions?.branch, isDefaultBranch],
|
||||||
);
|
);
|
||||||
|
|
||||||
const openExistingPr = useCallback(async () => {
|
const openExistingPr = useCallback(async () => {
|
||||||
@@ -204,7 +217,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const prUrl = gitStatus?.openPr?.url ?? null;
|
const prUrl = gitStatusForActions?.openPr?.url ?? null;
|
||||||
if (!prUrl) {
|
if (!prUrl) {
|
||||||
toastManager.add({
|
toastManager.add({
|
||||||
type: "error",
|
type: "error",
|
||||||
@@ -224,7 +237,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
void promise.catch(() => undefined);
|
void promise.catch(() => undefined);
|
||||||
}, [api, gitStatus?.openPr?.url, threadToastData]);
|
}, [api, gitStatusForActions?.openPr?.url, threadToastData]);
|
||||||
|
|
||||||
const runGitActionWithToast = useCallback(
|
const runGitActionWithToast = useCallback(
|
||||||
async ({
|
async ({
|
||||||
@@ -242,11 +255,13 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
if (!confirmed) return;
|
if (!confirmed) return;
|
||||||
onConfirmed?.();
|
onConfirmed?.();
|
||||||
|
|
||||||
const pushTarget = gitStatus?.branch ? `origin/${gitStatus.branch}` : undefined;
|
const pushTarget = gitStatusForActions?.branch
|
||||||
|
? `origin/${gitStatusForActions.branch}`
|
||||||
|
: undefined;
|
||||||
const progressStages = buildGitActionProgressStages({
|
const progressStages = buildGitActionProgressStages({
|
||||||
action,
|
action,
|
||||||
hasCustomCommitMessage: !!commitMessage?.trim(),
|
hasCustomCommitMessage: !!commitMessage?.trim(),
|
||||||
hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges,
|
hasWorkingTreeChanges: !!gitStatusForActions?.hasWorkingTreeChanges,
|
||||||
forcePushOnly: forcePushOnlyProgress,
|
forcePushOnly: forcePushOnlyProgress,
|
||||||
...(pushTarget ? { pushTarget } : {}),
|
...(pushTarget ? { pushTarget } : {}),
|
||||||
});
|
});
|
||||||
@@ -282,7 +297,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
stopProgressUpdates();
|
stopProgressUpdates();
|
||||||
const resultToast = summarizeGitResult(result);
|
const resultToast = summarizeGitResult(result);
|
||||||
|
|
||||||
const prUrl = result.pr.url ?? gitStatus?.openPr?.url;
|
const prUrl = result.pr.url ?? gitStatusForActions?.openPr?.url;
|
||||||
const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
|
const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
|
||||||
const shouldOfferOpenPrCta =
|
const shouldOfferOpenPrCta =
|
||||||
(action === "commit_push" || action === "commit_push_pr") && !!prUrl && !isDefaultBranch;
|
(action === "commit_push" || action === "commit_push_pr") && !!prUrl && !isDefaultBranch;
|
||||||
@@ -345,9 +360,9 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
api,
|
api,
|
||||||
gitStatus?.branch,
|
gitStatusForActions?.branch,
|
||||||
gitStatus?.hasWorkingTreeChanges,
|
gitStatusForActions?.hasWorkingTreeChanges,
|
||||||
gitStatus?.openPr?.url,
|
gitStatusForActions?.openPr?.url,
|
||||||
isDefaultBranch,
|
isDefaultBranch,
|
||||||
maybeConfirmPushToDefaultBranch,
|
maybeConfirmPushToDefaultBranch,
|
||||||
runImmediateGitActionMutation,
|
runImmediateGitActionMutation,
|
||||||
@@ -517,7 +532,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
{gitActionMenuItems.map((item) => {
|
{gitActionMenuItems.map((item) => {
|
||||||
const disabledReason = getMenuActionDisabledReason(
|
const disabledReason = getMenuActionDisabledReason(
|
||||||
item,
|
item,
|
||||||
gitStatus,
|
gitStatusForActions,
|
||||||
isGitActionRunning,
|
isGitActionRunning,
|
||||||
);
|
);
|
||||||
if (item.disabled && disabledReason) {
|
if (item.disabled && disabledReason) {
|
||||||
@@ -553,19 +568,25 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{gitStatus?.branch === null && (
|
{gitStatusForActions?.branch === null && (
|
||||||
<p className="px-2 py-1.5 text-xs text-warning">
|
<p className="px-2 py-1.5 text-xs text-warning">
|
||||||
Detached HEAD: create and checkout a branch to enable push and PR actions.
|
Detached HEAD: create and checkout a branch to enable push and PR actions.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{gitStatus &&
|
{gitStatusForActions &&
|
||||||
gitStatus.branch !== null &&
|
gitStatusForActions.branch !== null &&
|
||||||
!gitStatus.hasWorkingTreeChanges &&
|
!gitStatusForActions.hasWorkingTreeChanges &&
|
||||||
gitStatus.behindCount > 0 && (
|
gitStatusForActions.behindCount > 0 &&
|
||||||
|
gitStatusForActions.aheadCount === 0 && (
|
||||||
<p className="px-2 py-1.5 text-xs text-warning">
|
<p className="px-2 py-1.5 text-xs text-warning">
|
||||||
Behind upstream. Pull/rebase first.
|
Behind upstream. Pull/rebase first.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{isGitStatusOutOfSync && (
|
||||||
|
<p className="px-2 py-1.5 text-xs text-muted-foreground">
|
||||||
|
Refreshing git status...
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
{gitStatusError && (
|
{gitStatusError && (
|
||||||
<p className="px-2 py-1.5 text-xs text-destructive">{gitStatusError.message}</p>
|
<p className="px-2 py-1.5 text-xs text-destructive">{gitStatusError.message}</p>
|
||||||
)}
|
)}
|
||||||
@@ -594,37 +615,42 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
<div className="space-y-3 rounded-lg border border-input bg-muted/40 p-3 text-xs">
|
<div className="space-y-3 rounded-lg border border-input bg-muted/40 p-3 text-xs">
|
||||||
<div className="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1">
|
<div className="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1">
|
||||||
<span className="text-muted-foreground">Branch</span>
|
<span className="text-muted-foreground">Branch</span>
|
||||||
<span className="font-medium">{gitStatus?.branch ?? "(detached HEAD)"}</span>
|
<span className="font-medium">
|
||||||
|
{gitStatusForActions?.branch ?? "(detached HEAD)"}
|
||||||
|
</span>
|
||||||
{activeDialogAction !== "commit" && (
|
{activeDialogAction !== "commit" && (
|
||||||
<>
|
<>
|
||||||
<span className="text-muted-foreground">Upstream</span>
|
<span className="text-muted-foreground">Upstream</span>
|
||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
{!gitStatus || !gitStatus.hasUpstream
|
{!gitStatusForActions || !gitStatusForActions.hasUpstream
|
||||||
? "No upstream configured"
|
? "No upstream configured"
|
||||||
: gitStatus.aheadCount === 0 && gitStatus.behindCount === 0
|
: gitStatusForActions.aheadCount === 0 &&
|
||||||
|
gitStatusForActions.behindCount === 0
|
||||||
? "Up to date"
|
? "Up to date"
|
||||||
: gitStatus.aheadCount > 0 && gitStatus.behindCount > 0
|
: gitStatusForActions.aheadCount > 0 && gitStatusForActions.behindCount > 0
|
||||||
? `Diverged (+${gitStatus.aheadCount} / -${gitStatus.behindCount})`
|
? `Diverged (+${gitStatusForActions.aheadCount} / -${gitStatusForActions.behindCount})`
|
||||||
: gitStatus.aheadCount > 0
|
: gitStatusForActions.aheadCount > 0
|
||||||
? `Ahead by ${gitStatus.aheadCount}`
|
? `Ahead by ${gitStatusForActions.aheadCount}`
|
||||||
: `Behind by ${gitStatus.behindCount}`}
|
: `Behind by ${gitStatusForActions.behindCount}`}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-muted-foreground">Working tree</span>
|
<span className="text-muted-foreground">Working tree</span>
|
||||||
<span className="font-medium">
|
<span className="font-medium">
|
||||||
{!gitStatus || !gitStatus.hasWorkingTreeChanges
|
{!gitStatusForActions || !gitStatusForActions.hasWorkingTreeChanges
|
||||||
? "Clean"
|
? "Clean"
|
||||||
: `${gitStatus.workingTree.files.length} file(s)`}
|
: `${gitStatusForActions.workingTree.files.length} file(s)`}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-muted-foreground">Diff</span>
|
<span className="text-muted-foreground">Diff</span>
|
||||||
<span className="font-mono">
|
<span className="font-mono">
|
||||||
{!gitStatus || !gitStatus.hasWorkingTreeChanges ? (
|
{!gitStatusForActions || !gitStatusForActions.hasWorkingTreeChanges ? (
|
||||||
"none"
|
"none"
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<span className="text-success">+{gitStatus.workingTree.insertions}</span>
|
<span className="text-success">
|
||||||
|
+{gitStatusForActions.workingTree.insertions}
|
||||||
|
</span>
|
||||||
<span className="text-muted-foreground"> / </span>
|
<span className="text-muted-foreground"> / </span>
|
||||||
<span className="text-destructive">
|
<span className="text-destructive">
|
||||||
-{gitStatus.workingTree.deletions}
|
-{gitStatusForActions.workingTree.deletions}
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -634,13 +660,13 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<p className="text-muted-foreground">Files</p>
|
<p className="text-muted-foreground">Files</p>
|
||||||
{!gitStatus || gitStatus.workingTree.files.length === 0 ? (
|
{!gitStatusForActions || gitStatusForActions.workingTree.files.length === 0 ? (
|
||||||
<p className="font-medium">none</p>
|
<p className="font-medium">none</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<ScrollArea className="h-44 rounded-md border border-input bg-background">
|
<ScrollArea className="h-44 rounded-md border border-input bg-background">
|
||||||
<div className="space-y-1 p-1">
|
<div className="space-y-1 p-1">
|
||||||
{gitStatus.workingTree.files.map((file) => (
|
{gitStatusForActions.workingTree.files.map((file) => (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
key={file.path}
|
key={file.path}
|
||||||
@@ -658,9 +684,13 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
|
|||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
<div className="flex justify-end font-mono">
|
<div className="flex justify-end font-mono">
|
||||||
<span className="text-success">+{gitStatus.workingTree.insertions}</span>
|
<span className="text-success">
|
||||||
|
+{gitStatusForActions.workingTree.insertions}
|
||||||
|
</span>
|
||||||
<span className="text-muted-foreground"> / </span>
|
<span className="text-muted-foreground"> / </span>
|
||||||
<span className="text-destructive">-{gitStatus.workingTree.deletions}</span>
|
<span className="text-destructive">
|
||||||
|
-{gitStatusForActions.workingTree.deletions}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in new issue
Block a user