diff --git a/packages/app/src/git/policy.test.ts b/packages/app/src/git/policy.test.ts index f9cde8948..a9365e5ca 100644 --- a/packages/app/src/git/policy.test.ts +++ b/packages/app/src/git/policy.test.ts @@ -252,6 +252,38 @@ describe("git-actions-policy", () => { }); }); + it("keeps pull-and-push unavailable when the branch only has outgoing commits", () => { + const actions = buildGitActions( + createInput({ + hasRemote: true, + aheadOfOrigin: 2, + behindOfOrigin: 0, + }), + ); + const action = actions.secondary.find((entry) => entry.id === "pull-and-push"); + + expect(action).toMatchObject({ + label: "Pull and push", + unavailableMessage: expect.any(String), + }); + }); + + it("keeps pull-and-push unavailable when the branch only has incoming commits", () => { + const actions = buildGitActions( + createInput({ + hasRemote: true, + aheadOfOrigin: 0, + behindOfOrigin: 2, + }), + ); + const action = actions.secondary.find((entry) => entry.id === "pull-and-push"); + + expect(action).toMatchObject({ + label: "Pull and push", + unavailableMessage: expect.any(String), + }); + }); + it("explains why pull-and-push is unavailable when the branch is in sync", () => { const actions = buildGitActions(createInput({ hasRemote: true })); const action = actions.secondary.find((entry) => entry.id === "pull-and-push"); diff --git a/packages/app/src/git/policy.ts b/packages/app/src/git/policy.ts index 69d09323e..36e91c02d 100644 --- a/packages/app/src/git/policy.ts +++ b/packages/app/src/git/policy.ts @@ -616,6 +616,12 @@ function getPullAndPushUnavailableMessage(input: BuildGitActionsInput): string | if (input.behindOfOrigin === 0 && input.aheadOfOrigin === 0) { return "Pull and push isn't available because this branch is already in sync"; } + if (input.behindOfOrigin === 0) { + return "Pull and push isn't available because there are no incoming changes to pull first"; + } + if (input.aheadOfOrigin === 0) { + return "Pull and push isn't available because there is nothing new to send after pulling"; + } return undefined; }