Skip to content

Commit 8450b45

Browse files
committed
test variables
Signed-off-by: exploreriii <[email protected]>
1 parent 395a36e commit 8450b45

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

.github/scripts/linked_issue_enforce.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
// dryRun env var: any case-insensitive 'true' value will enable dry-run
44
const dryRun = (process.env.DRY_RUN || 'false').toString().toLowerCase() === 'true';
5-
const daysBeforeClose = parseInt(process.env.DAYS_BEFORE_CLOSE || '3', 10);
5+
// const daysBeforeClose = parseInt(process.env.DAYS_BEFORE_CLOSE || '3', 10);
6+
const daysBeforeClose = Number(process.env.DAYS_BEFORE_CLOSE || '0.0035');
7+
68
const requireAuthorAssigned = (process.env.REQUIRE_AUTHOR_ASSIGNED || 'true').toLowerCase() === 'true';
79

10+
// const getDaysOpen = (pr) =>
11+
// Math.floor((Date.now() - new Date(pr.created_at)) / (24 * 60 * 60 * 1000));
12+
813
const getDaysOpen = (pr) =>
9-
Math.floor((Date.now() - new Date(pr.created_at)) / (24 * 60 * 60 * 1000));
14+
(Date.now() - new Date(pr.created_at)) / (24 * 60 * 60 * 1000);
1015

1116
// Check if the PR author is assigned to the issue
1217
const isAuthorAssigned = (issue, login) => {
@@ -97,27 +102,26 @@ async function closePR(github, pr, owner, repo, reason) {
97102
module.exports = async ({ github, context }) => {
98103
try {
99104
const { owner, repo } = context.repo;
100-
const prs = await github.paginate(github.rest.pulls.list, {
101-
owner, repo, state: 'open', per_page: 100
102-
});
103-
104-
console.log(`Evaluating ${prs.length} open PRs\n`);
105-
106-
for (const pr of prs) {
107-
const days = getDaysOpen(pr);
108-
if (days < daysBeforeClose)
109-
{
110-
console.log(`PR #${pr.number} link: ${pr.html_url} is only ${days} days old. Skipping.`);
111-
continue;
112-
}
105+
const prs = await github.paginate(github.rest.pulls.list, {
106+
owner, repo, state: 'open', per_page: 100
107+
});
108+
109+
console.log(`Evaluating ${prs.length} open PRs\n`);
113110

114-
const { valid, reason } = await validatePR(github, pr, owner, repo);
115-
if (valid) {
116-
console.log(`PR #${pr.number} link: ${pr.html_url} is Valid ✓.`);
117-
} else {
118-
await closePR(github, pr, owner, repo, reason);
111+
for (const pr of prs) {
112+
const days = getDaysOpen(pr);
113+
if (days < daysBeforeClose) {
114+
console.log(`PR #${pr.number} link: ${pr.html_url} is only ${days} days old. Skipping.`);
115+
continue;
116+
}
117+
118+
const { valid, reason } = await validatePR(github, pr, owner, repo);
119+
if (valid) {
120+
console.log(`PR #${pr.number} link: ${pr.html_url} is Valid ✓.`);
121+
} else {
122+
await closePR(github, pr, owner, repo, reason);
123+
}
119124
}
120-
}
121125
} catch (err) {
122126
console.error('Unexpected error:', err.message);
123127
}

0 commit comments

Comments
 (0)