History

Show push target in Git action progress stages

- Include branch-based remote target in push progress text - Update logic and tests for commit+push and force-push flows

Julius Marminge committed 9 months ago

Commit cc378651 parent a6b9ece3 files · +14 −4Browse files

Unified · Split

3 files
  1. apps/web/src/components/GitActionsControl.logic.test.ts +8 −2
  2. apps/web/src/components/GitActionsControl.logic.ts +4 −2
  3. apps/web/src/components/GitActionsControl.tsx +2 −0
apps/web/src/components/GitActionsControl.logic.test.ts+8−2
@@ -604,8 +604,9 @@ describe("buildGitActionProgressStages", () => { · 603 unmodified lines
604 hasCustomCommitMessage: false,604 hasCustomCommitMessage: false,
605 hasWorkingTreeChanges: true,605 hasWorkingTreeChanges: true,
606 forcePushOnly: true,606 forcePushOnly: true,
607 pushTarget: "origin/feature/test",
607 });608 });
608 assert.deepEqual(stages, ["Pushing..."]);609 assert.deepEqual(stages, ["Pushing to origin/feature/test..."]);
609 });610 });
610 611
611 it("includes commit stages for commit+push when working tree is dirty", () => {612 it("includes commit stages for commit+push when working tree is dirty", () => {
@@ -613,8 +614,13 @@ describe("buildGitActionProgressStages", () => { · 1 unmodified line
613 action: "commit_push",614 action: "commit_push",
614 hasCustomCommitMessage: false,615 hasCustomCommitMessage: false,
615 hasWorkingTreeChanges: true,616 hasWorkingTreeChanges: true,
617 pushTarget: "origin/feature/test",
616 });618 });
617 assert.deepEqual(stages, ["Generating commit message...", "Committing...", "Pushing..."]);619 assert.deepEqual(stages, [
620 "Generating commit message...",
621 "Committing...",
622 "Pushing to origin/feature/test...",
623 ]);
618 });624 });
619});625});
620 626
apps/web/src/components/GitActionsControl.logic.ts+4−2
@@ -48,6 +48,7 @@ export function buildGitActionProgressStages(input: { · 47 unmodified lines
48 hasCustomCommitMessage: boolean;48 hasCustomCommitMessage: boolean;
49 hasWorkingTreeChanges: boolean;49 hasWorkingTreeChanges: boolean;
50 forcePushOnly?: boolean;50 forcePushOnly?: boolean;
51 pushTarget?: string;
51}): string[] {52}): string[] {
52 const shouldIncludeCommitStages =53 const shouldIncludeCommitStages =
53 !input.forcePushOnly && (input.action === "commit" || input.hasWorkingTreeChanges);54 !input.forcePushOnly && (input.action === "commit" || input.hasWorkingTreeChanges);
@@ -56,13 +57,14 @@ export function buildGitActionProgressStages(input: { · 2 unmodified lines
56 : input.hasCustomCommitMessage57 : input.hasCustomCommitMessage
57 ? ["Committing..."]58 ? ["Committing..."]
58 : ["Generating commit message...", "Committing..."];59 : ["Generating commit message...", "Committing..."];
60 const pushStage = input.pushTarget ? `Pushing to ${input.pushTarget}...` : "Pushing...";
59 if (input.action === "commit") {61 if (input.action === "commit") {
60 return commitStages;62 return commitStages;
61 }63 }
62 if (input.action === "commit_push") {64 if (input.action === "commit_push") {
63 return [...commitStages, "Pushing..."];65 return [...commitStages, pushStage];
64 }66 }
65 return [...commitStages, "Pushing...", "Creating PR..."];67 return [...commitStages, pushStage, "Creating PR..."];
66}68}
67 69
68export function summarizeGitResult(result: GitRunStackedActionResult): {70export function summarizeGitResult(result: GitRunStackedActionResult): {
apps/web/src/components/GitActionsControl.tsx+2−0
@@ -226,11 +226,13 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp · 225 unmodified lines
226 if (!confirmed) return;226 if (!confirmed) return;
227 onConfirmed?.();227 onConfirmed?.();
228 228
229 const pushTarget = gitStatus?.branch ? `origin/${gitStatus.branch}` : undefined;
229 const progressStages = buildGitActionProgressStages({230 const progressStages = buildGitActionProgressStages({
230 action,231 action,
231 hasCustomCommitMessage: !!commitMessage?.trim(),232 hasCustomCommitMessage: !!commitMessage?.trim(),
232 hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges,233 hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges,
233 forcePushOnly: forcePushOnlyProgress,234 forcePushOnly: forcePushOnlyProgress,
235 pushTarget,
234 });236 });
235 const progressToastId = toastManager.add({237 const progressToastId = toastManager.add({
236 type: "loading",238 type: "loading",