From caf7cdd027ef47e45deed685c8d1c49ba38cf8d2 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Thu, 18 May 2023 16:30:52 -0700 Subject: [PATCH] fix: correct time math Signed-off-by: Zack Koppert --- stale_repos.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stale_repos.py b/stale_repos.py index 2107ac7..f0f3aac 100755 --- a/stale_repos.py +++ b/stale_repos.py @@ -37,7 +37,7 @@ def main(): else: raise ValueError("GH_TOKEN environment variable not set") - # Set the topic + # Set the threshold for inactive days inactive_days_threshold = os.getenv("INACTIVE_DAYS") if not inactive_days_threshold: raise ValueError("INACTIVE_DAYS environment variable not set") @@ -50,10 +50,11 @@ def main(): # Iterate over repos in the org, acquire inactive days, # and print out the repo url and days inactive if it's over the threshold (inactive_days) for repo in gh.repositories_by(organization): - last_push = repo.pushed_at - if last_push is None: + last_push_str = repo.pushed_at + if last_push_str is None: continue - days_inactive = (datetime.now(timezone.utc) - last_push).days + last_push = datetime.fromisoformat(last_push_str[:-1]) + days_inactive = (datetime.now() - last_push).days if days_inactive > int(inactive_days_threshold): print(f"{repo.html_url}: {days_inactive} days inactive")