-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoclose.py
31 lines (27 loc) · 952 Bytes
/
autoclose.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import os
import sys
import json
import giteapy
import subprocess
from packaging import version
owner = "imlonghao"
repo = "aur"
configuration = giteapy.Configuration()
configuration.host = "https://git.esd.cc/api/v1"
configuration.api_key["token"] = os.environ["GITEA_BOT_TOKEN"]
api_instance = giteapy.IssueApi(giteapy.ApiClient(configuration))
open_issues = api_instance.issue_list_issues(
owner, repo, state="open", labels="out-of-date", page=-1
)
for issue in open_issues:
pkgname = issue.title.split(":")[0]
issue_version = issue.title.split(" ")[-1]
repo_version = subprocess.getoutput(
f"bash -c 'source {pkgname}/PKGBUILD; echo $pkgver'"
)
print(f"{pkgname}: wants {issue_version}, now {repo_version}")
if version.parse(issue_version) <= version.parse(repo_version):
api_instance.issue_edit_issue(
owner, repo, issue.number, body={"state": "closed"}
)