forked from yardenshoham/gitea-backporter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close PR if it has not had any activity in the past 2 weeks and has `…
…pr/last-call` (#118) * Close PR if it has not had any activity in the past 2 weeks and has `pr/last-call` As stated in https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md#final-call Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: delvh <dev.lh@web.de>
- Loading branch information
1 parent
9efd33b
commit 52dc43f
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { addComment, closePr, fetchOpenPrsWithLabel } from "./github.ts"; | ||
|
||
export const run = async () => { | ||
// get all issues with the label "pr/last-call" | ||
const issuesWithStatusPrLastCall = await fetchOpenPrsWithLabel( | ||
"pr/last-call", | ||
); | ||
return Promise.all(issuesWithStatusPrLastCall.items.map(handlePr)); | ||
}; | ||
|
||
// close PR if two weeks have passed since it was last updated | ||
const handlePr = async (pr: { | ||
number: number; | ||
updated_at: string; | ||
}) => { | ||
const twoWeeksAgo = (new Date(Date.now() - 1000 * 60 * 60 * 24 * 14)) | ||
.getTime(); | ||
if ((new Date(pr.updated_at)).getTime() < twoWeeksAgo) { | ||
console.log(`Closing PR #${pr.number} due to pr/last-call timeout`); | ||
await addComment( | ||
pr.number, | ||
"This pull request has a last call and has not had any activity in the past two weeks. Consider it to be a [polite refusal](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md#final-call). :tea:", | ||
); | ||
|
||
// close PR | ||
await closePr(pr.number); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters