Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/renderer/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push & PR erstellen"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push & Create PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push y crear PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9416,6 +9416,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push et créer une PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/ja/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9415,6 +9415,10 @@ msgstr "プッシュ ({0})"
msgid "Push ({ahead})"
msgstr "プッシュ ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "プッシュして PR を作成"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "プッシュ ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/ko/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "푸시({0})"
msgid "Push ({ahead})"
msgstr "푸시({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "푸시 및 PR 작성"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "푸시 ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/pl/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push i utwórz PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/pt-BR/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push e criar PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/ru/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push и создать PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/tr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push Et ve PR Oluştur"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/uk/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Push ({0})"
msgid "Push ({ahead})"
msgstr "Push ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push і створити PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Push ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/vi/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9417,6 +9417,10 @@ msgstr "Đẩy ({0})"
msgid "Push ({ahead})"
msgstr "Đẩy ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "Push & Tạo PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "Đẩy ↑{ahead}"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/locales/zh-CN/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -9416,6 +9416,10 @@ msgstr "推 ({0})"
msgid "Push ({ahead})"
msgstr "推 ({ahead})"

#: src/renderer/views/GitReviewOverlay/parts/GitReviewSidebar/parts/CommitSyncPanel.tsx
msgid "Push & Create PR"
msgstr "推送并创建 PR"

#: src/renderer/views/MainView/parts/Sidebar/parts/SyncBadge.tsx
msgid "Push ↑{ahead}"
msgstr "推送 ↑{ahead}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export function GitReviewSidebar(props: {
handleGenerateMessage,
handleSyncOrPush,
handleSyncAction,
handlePushAndCreatePr,
handleMergeOnly,
handleMergeAndRemove,
handlePullFromSource,
Expand Down Expand Up @@ -559,6 +560,7 @@ export function GitReviewSidebar(props: {
handleGenerateMessage={handleGenerateMessage}
handleSyncOrPush={handleSyncOrPush}
handleSyncAction={handleSyncAction}
handlePushAndCreatePr={handlePushAndCreatePr}
hasTracking={hasTracking}
handlePullFromSource={handlePullFromSource}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function renderPanel(overrides?: Partial<Parameters<typeof CommitSyncPanel>[0]>)
handleGenerateMessage: vi.fn<() => Promise<void>>(),
handleSyncOrPush: vi.fn<() => Promise<void>>(),
handleSyncAction: vi.fn<() => Promise<void>>(),
handlePushAndCreatePr: vi.fn<() => Promise<void>>(),
handlePullFromSource: vi.fn<() => Promise<void>>(),
};
renderWithI18n(<CommitSyncPanel {...props} {...overrides} />);
Expand Down Expand Up @@ -160,3 +161,26 @@ describe("CommitSyncPanel in-button step status", () => {
expect(screen.getByRole("button", { name: "Commit" })).toBeDisabled();
});
});

// Committed-but-not-pushed is the gap between the commit split-button (which
// offers "Commit & Create PR") and the PR section (which offers "Create PR"
// once pushed): the push row has to carry the chained action there.
describe("CommitSyncPanel push options", () => {
const pushedAhead = {
hasRemote: true,
hasTracking: true,
needsPush: true,
ahead: 2,
} as const;

it("offers Push & Create PR while a pushable branch can still open a PR", () => {
renderPanel({ ...pushedAhead, canCreatePr: true });
expect(screen.getByText("Push & Create PR")).toBeInTheDocument();
});

it("omits Push & Create PR when no PR can be opened", () => {
renderPanel({ ...pushedAhead, canCreatePr: false });
expect(screen.queryByText("Push & Create PR")).not.toBeInTheDocument();
expect(screen.getAllByText("Push (2)").length).toBeGreaterThan(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function CommitSyncPanel(props: {
handleGenerateMessage: () => Promise<void>;
handleSyncOrPush: () => Promise<void>;
handleSyncAction: (key: GitSyncCommand) => Promise<void>;
handlePushAndCreatePr: () => Promise<void>;
handlePullFromSource: () => Promise<void>;
}) {
const {
Expand Down Expand Up @@ -92,6 +93,7 @@ export function CommitSyncPanel(props: {
handleGenerateMessage,
handleSyncOrPush,
handleSyncAction,
handlePushAndCreatePr,
handlePullFromSource,
} = props;
const { t } = useLingui();
Expand Down Expand Up @@ -323,10 +325,15 @@ export function CommitSyncPanel(props: {
const showPull = hasTracking && behind > 0;
const showPush = ahead > 0 || !hasTracking;
const showSyncBoth = hasTracking && ahead > 0 && behind > 0;
// Committed but not pushed yet: offer the chained push + PR here too,
// so the flow the commit split-button offers before committing (and
// the PR section offers after pushing) stays reachable in between.
const showPushPr = showPush && canCreatePr;
const showPullFromSourceItem = Boolean(
showPullFromSource && sourceBranch && sourceAhead > 0,
);
const hasSyncOptions = showPull || showPush || showSyncBoth || showPullFromSourceItem;
const hasSyncOptions =
showPull || showPush || showPushPr || showSyncBoth || showPullFromSourceItem;

const primaryButton = (
<Button
Expand Down Expand Up @@ -389,6 +396,10 @@ export function CommitSyncPanel(props: {
void handlePullFromSource();
return;
}
if (key === "push-pr") {
void handlePushAndCreatePr();
return;
}
void handleSyncAction(key as GitSyncCommand);
}}
>
Expand Down Expand Up @@ -422,6 +433,16 @@ export function CommitSyncPanel(props: {
<Label>{ahead > 0 ? t`Push (${ahead})` : t`Push`}</Label>
</Dropdown.Item>
) : null}
{showPushPr ? (
<Dropdown.Item
id="push-pr"
textValue={t`Push & Create PR`}
isDisabled={actionInFlight}
>
<GitPullRequest className="size-3.5" />
<Label>{t`Push & Create PR`}</Label>
</Dropdown.Item>
) : null}
{showSyncBoth ? (
<Dropdown.Item id="sync" textValue={t`Sync`} isDisabled={actionInFlight}>
<ArrowUpDown className="size-3.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,35 @@ describe("useGitReviewActions action phase", () => {
expect(bridgeMock.ghCreatePr).not.toHaveBeenCalled();
});

// "Push & Create PR" is the same single-user-action chain for an
// already-committed branch: one continuous status walk, and never a PR
// attempt after a failed push.
it("keeps one continuous phase across push and PR creation", async () => {
const actions = renderActions();
const { seen, stop } = recordPhases();

await act(async () => {
await actions.current.handlePushAndCreatePr();
});
stop();

expect(seen).toEqual(["pushing", "creating-pr", null]);
expect(bridgeMock.ghCreatePr).toHaveBeenCalledTimes(1);
});

// A failed push must release the slot and hold off on creating the PR.
it("clears the phase when the chained flow fails at the push step", async () => {
runGitSyncCommandMock.mockRejectedValueOnce(new Error("push failed"));
const actions = renderActions();

await act(async () => {
await actions.current.handlePushAndCreatePr();
});

expect(useGitReviewActionStore.getState().panels[STORE_KEY]?.actionPhase).toBeNull();
expect(bridgeMock.ghCreatePr).not.toHaveBeenCalled();
});

// Every sync-menu entry reports a phase, so none of them can race a commit.
it.each([
["pull", "pulling"],
Expand Down
Loading