38 lines
1.3 KiB
Python
Executable file
38 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import time
|
|
|
|
from task import github
|
|
|
|
def issues_review(api, opts):
|
|
now = time.time()
|
|
treshold = opts.age * 86400
|
|
count = 100
|
|
page = 1
|
|
while count == 100:
|
|
issues = api.get("issues?filter=all&page=%i&per_page=%i" % (page, count))
|
|
page += 1
|
|
count = len(issues)
|
|
for issue in issues:
|
|
age = now - time.mktime(time.strptime(issue["updated_at"], "%Y-%m-%dT%H:%M:%SZ"))
|
|
if age >= treshold:
|
|
print("Labelling #%i last updated at %s" % (issue["number"], issue["updated_at"]))
|
|
api.post("issues/%i/labels" % issue["number"], [opts.label])
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Add review label to stale issues')
|
|
parser.add_argument('-a', '--age', metavar='DAYS', default=90,
|
|
help='Label issues whose last update is older than given number of days (default: %(default)s)')
|
|
parser.add_argument('-l', '--label', default=time.strftime('review-%Y-%m'),
|
|
help='Label name (default: %(default)s)')
|
|
parser.add_argument('--repo', help='Work on this GitHub repository (owner/name)')
|
|
opts = parser.parse_args()
|
|
|
|
api = github.GitHub(repo=opts.repo)
|
|
issues_review(api, opts)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|