Skip to content
5 changes: 5 additions & 0 deletions lib/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ export default async function success(pluginConfig, context, { Octokit }) {

if (failComment === false || failTitle === false) {
logger.log("Skip closing issue.");
logger.warn(
`DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.`,
);
} else if (failCommentCondition === false) {
logger.log("Skip closing issue.");
} else {
const srIssues = await findSRIssues(
octokit,
Expand Down
67 changes: 67 additions & 0 deletions test/success.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4355,6 +4355,11 @@ test('Skip closing issues if "failComment" is "false"', async (t) => {
},
);
t.true(t.context.log.calledWith("Skip closing issue."));
t.true(
t.context.warn.calledWith(
"DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.",
),
);
t.true(fetch.done());
});

Expand All @@ -4370,6 +4375,68 @@ test('Skip closing issues if "failTitle" is "false"', async (t) => {
{ name: "GitHub release", url: "https://github.com/release" },
];

const fetch = fetchMock
.sandbox()
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
full_name: `${owner}/${repo}`,
clone_url: `https://api.github.local/${owner}/${repo}.git`,
})
.postOnce("https://api.github.local/graphql", {
data: {
repository: {
commit123: {
oid: "123",
associatedPullRequests: {
pageInfo: {
endCursor: "NI",
hasNextPage: false,
},
nodes: [],
},
},
},
},
});

await success(
pluginConfig,
{
env,
options,
branch: { name: "master" },
commits,
nextRelease,
releases,
logger: t.context.logger,
},
{
Octokit: TestOctokit.defaults((options) => ({
...options,
request: { ...options.request, fetch },
})),
},
);
t.true(t.context.log.calledWith("Skip closing issue."));
t.true(
t.context.warn.calledWith(
"DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.",
),
);
t.true(fetch.done());
});

test('Skip closing issues if "failCommentCondition" is "false"', async (t) => {
const owner = "test_user";
const repo = "test_repo";
const env = { GITHUB_TOKEN: "github_token" };
const pluginConfig = { failCommentCondition: false };
const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` };
const commits = [{ hash: "123", message: "Commit 1 message" }];
const nextRelease = { version: "1.0.0" };
const releases = [
{ name: "GitHub release", url: "https://github.com/release" },
];

const fetch = fetchMock
.sandbox()
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
Expand Down