Disable pull and push until the branch diverges
This commit is contained in:
@@ -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", () => {
|
it("explains why pull-and-push is unavailable when the branch is in sync", () => {
|
||||||
const actions = buildGitActions(createInput({ hasRemote: true }));
|
const actions = buildGitActions(createInput({ hasRemote: true }));
|
||||||
const action = actions.secondary.find((entry) => entry.id === "pull-and-push");
|
const action = actions.secondary.find((entry) => entry.id === "pull-and-push");
|
||||||
|
|||||||
@@ -616,6 +616,12 @@ function getPullAndPushUnavailableMessage(input: BuildGitActionsInput): string |
|
|||||||
if (input.behindOfOrigin === 0 && input.aheadOfOrigin === 0) {
|
if (input.behindOfOrigin === 0 && input.aheadOfOrigin === 0) {
|
||||||
return "Pull and push isn't available because this branch is already in sync";
|
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;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user