Skip to content

Commit

Permalink
Remove old or inactive repos.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauris authored Sep 19, 2024
1 parent 681fced commit 9177dc2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions add-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,24 @@ def retrieve_repo(name):
except Exception:
warn(f"Error occured while getting {name} repo")
raise
print('.', file=sys.stderr, end='', flush=True)
check_freshness(repo)

# print('.', file=sys.stderr, end='', flush=True)

if is_stale(repo):
raise Exception("Repo is too old or inactive")

return repo


def check_freshness(repo):
def is_stale(repo):
if repo.archived:
warn(f"Repo {repo.full_name} is archived")
elif repo.pushed_at < datetime.utcnow() - timedelta(days=180):
return True
elif repo.pushed_at < datetime.utcnow() - timedelta(days=365):
warn(f"Repo {repo.full_name} has not been pushed to since {repo.pushed_at}")
return True

return False


def parse(line):
Expand All @@ -62,7 +70,7 @@ def parse(line):
try:
row = github_table_row(retrieve_repo(repo_name))
except Exception:
row = ''
row = False
return row
else:
return line.rstrip()
Expand All @@ -71,7 +79,9 @@ def parse(line):
def run():
print('<!--- This file is automatically generated. Do not edit directly. -->')
for line in fileinput.input():
print(parse(line))
parsed = parse(line)
if parsed:
print(parsed)


run()

0 comments on commit 9177dc2

Please sign in to comment.