Skip to content

Commit d77b6f4

Browse files
fix: Check failCommentCondition in "success" step (#1026)
Co-authored-by: Olabode Lawal-Shittabey <[email protected]>
1 parent 005c4e3 commit d77b6f4

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

lib/success.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ export default async function success(pluginConfig, context, { Octokit }) {
265265

266266
if (failComment === false || failTitle === false) {
267267
logger.log("Skip closing issue.");
268+
logger.warn(
269+
`DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.`,
270+
);
271+
} else if (failCommentCondition === false) {
272+
logger.log("Skip closing issue.");
268273
} else {
269274
const srIssues = await findSRIssues(
270275
octokit,

test/success.test.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,6 +4355,11 @@ test('Skip closing issues if "failComment" is "false"', async (t) => {
43554355
},
43564356
);
43574357
t.true(t.context.log.calledWith("Skip closing issue."));
4358+
t.true(
4359+
t.context.warn.calledWith(
4360+
"DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.",
4361+
),
4362+
);
43584363
t.true(fetch.done());
43594364
});
43604365

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

4378+
const fetch = fetchMock
4379+
.sandbox()
4380+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
4381+
full_name: `${owner}/${repo}`,
4382+
clone_url: `https://api.github.local/${owner}/${repo}.git`,
4383+
})
4384+
.postOnce("https://api.github.local/graphql", {
4385+
data: {
4386+
repository: {
4387+
commit123: {
4388+
oid: "123",
4389+
associatedPullRequests: {
4390+
pageInfo: {
4391+
endCursor: "NI",
4392+
hasNextPage: false,
4393+
},
4394+
nodes: [],
4395+
},
4396+
},
4397+
},
4398+
},
4399+
});
4400+
4401+
await success(
4402+
pluginConfig,
4403+
{
4404+
env,
4405+
options,
4406+
branch: { name: "master" },
4407+
commits,
4408+
nextRelease,
4409+
releases,
4410+
logger: t.context.logger,
4411+
},
4412+
{
4413+
Octokit: TestOctokit.defaults((options) => ({
4414+
...options,
4415+
request: { ...options.request, fetch },
4416+
})),
4417+
},
4418+
);
4419+
t.true(t.context.log.calledWith("Skip closing issue."));
4420+
t.true(
4421+
t.context.warn.calledWith(
4422+
"DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.",
4423+
),
4424+
);
4425+
t.true(fetch.done());
4426+
});
4427+
4428+
test('Skip closing issues if "failCommentCondition" is "false"', async (t) => {
4429+
const owner = "test_user";
4430+
const repo = "test_repo";
4431+
const env = { GITHUB_TOKEN: "github_token" };
4432+
const pluginConfig = { failCommentCondition: false };
4433+
const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` };
4434+
const commits = [{ hash: "123", message: "Commit 1 message" }];
4435+
const nextRelease = { version: "1.0.0" };
4436+
const releases = [
4437+
{ name: "GitHub release", url: "https://github.com/release" },
4438+
];
4439+
43734440
const fetch = fetchMock
43744441
.sandbox()
43754442
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {

0 commit comments

Comments
 (0)