From fe7035367c003296bfcc059c68be1e718baa3785 Mon Sep 17 00:00:00 2001 From: bbhtt Date: Fri, 20 Sep 2024 08:52:18 +0530 Subject: [PATCH] archive_eol: Use last commit time on default branch instead of pushed_at pushed_at counts all branches so if x-checker is making new PRs it won't be countted even if the repo is inactive --- .github/scripts/archive_eol.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/scripts/archive_eol.py b/.github/scripts/archive_eol.py index 65ab0a1..6c69e6c 100644 --- a/.github/scripts/archive_eol.py +++ b/.github/scripts/archive_eol.py @@ -113,15 +113,24 @@ def main() -> None: refname = eols[count] try: repo = g.get_repo(f"flathub/{refname}") - if not repo.archived and repo.pushed_at < earliest: - print( - "Archiving: {} Repo is in EOL list. Last push: {}, earlier than: {}".format( - repo.html_url, repo.pushed_at.isoformat(), earliest.isoformat() - ) + if not repo.archived: + default_branch = repo.default_branch + branch = repo.get_branch(default_branch) + last_commit = repo.get_commit(branch.commit.sha) + last_commit_time = last_commit.commit.committer.date.astimezone( + datetime.timezone.utc ) - desc = "This repo is archived as the app is EOL." - repo.edit(description=desc) - repo.edit(archived=True) + if last_commit_time < earliest: + print( + "Archiving: {} Repo is in EOL list. Last push: {}, earlier than: {}".format( + repo.html_url, + last_commit_time.isoformat(), + earliest.isoformat(), + ) + ) + desc = "This repo is archived as the app is EOL." + repo.edit(description=desc) + repo.edit(archived=True) except UnknownObjectException: pass except RateLimitExceededException: