Show PR action when auto-merge is enabled
This commit is contained in:
@@ -692,6 +692,7 @@ describe("git-actions-policy", () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(actions.primary).toMatchObject({ id: "pr", label: "View PR" });
|
||||||
expect(actions.secondary).toEqual(
|
expect(actions.secondary).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
|
|||||||
@@ -342,6 +342,9 @@ function getPrimaryActionId(input: BuildGitActionsInput): GitActionId | null {
|
|||||||
if (canEnablePrAutoMerge(input)) {
|
if (canEnablePrAutoMerge(input)) {
|
||||||
return getDefaultEnablePullRequestAutoMergeActionId(input);
|
return getDefaultEnablePullRequestAutoMergeActionId(input);
|
||||||
}
|
}
|
||||||
|
if (hasEnabledPrAutoMerge(input)) {
|
||||||
|
return "pr";
|
||||||
|
}
|
||||||
if (!input.isOnBaseBranch && input.aheadCount > 0) {
|
if (!input.isOnBaseBranch && input.aheadCount > 0) {
|
||||||
return "merge-branch";
|
return "merge-branch";
|
||||||
}
|
}
|
||||||
@@ -554,6 +557,16 @@ function canEnablePrAutoMerge(input: BuildGitActionsInput): boolean {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasEnabledPrAutoMerge(input: BuildGitActionsInput): boolean {
|
||||||
|
return (
|
||||||
|
input.githubFeaturesEnabled &&
|
||||||
|
input.hasPullRequest &&
|
||||||
|
input.pullRequestUrl !== null &&
|
||||||
|
hasPullRequestGithubFacts(input.pullRequestGithub) &&
|
||||||
|
input.pullRequestGithub.autoMergeRequest !== null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function getPullUnavailableMessage(input: BuildGitActionsInput): string | undefined {
|
function getPullUnavailableMessage(input: BuildGitActionsInput): string | undefined {
|
||||||
if (!input.hasRemote) {
|
if (!input.hasRemote) {
|
||||||
return "Pull isn't available here because this branch is not connected to a remote yet";
|
return "Pull isn't available here because this branch is not connected to a remote yet";
|
||||||
|
|||||||
Reference in New Issue
Block a user