-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgengee-update
executable file
·69 lines (56 loc) · 2.42 KB
/
gengee-update
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
# -*- coding: utf-8 -*-
from gengee import common, database, pull, __version__ as version
from gengee.portage import *
from github import Github
import requests
keywords = ["bump", "revbump", "verbump", "drop", "eapi", "use", "license", "security", "static", "cross", "fix"]
config = common.getConfig()
repo_path = getRepoPath()
current_db = database.Database(config["dbpath"])
updated_db = database.Database(config["dbpath"])
# check if we can use existing db for cache
try:
current_db.read()
except (FileNotFoundError, SyntaxError, ValueError):
print("no valid existing db found")
pass
# connect to Github or die trying
try:
g = Github(config["github_token"], user_agent="Gengee/PyGithub")
r = g.get_repo("gentoo/gentoo")
except Exception as e:
print(str(e))
exit()
# harvest and update db with PR's
for pullrequest in r.get_pulls('open'):
print(str(pullrequest.number) + " :: " + pullrequest.title)
PR = pull.Pull()
PR.loadGH(pullrequest)
PR.setKeywords(keywords)
# check if we can use PR data from previous run
if current_db.checkCacheStatus(PR,PR.p["updated_ts"]) and common.checkCompatibleDatabase(version,current_db.db["version"]):
PR.p["eclasses"] = current_db.getPullAttribute(PR.nr,"eclasses")
PR.p["packages"] = current_db.getPullAttribute(PR.nr,"packages")
PR.p["ebuilds"] = current_db.getPullAttribute(PR.nr,"ebuilds")
PR.p["manifest"] = current_db.getPullAttribute(PR.nr,"manifest")
PR.p["commits"] = current_db.getPullAttribute(PR.nr,"commits")
PR.p["bugs"] = current_db.getPullAttribute(PR.nr,"bugs")
else:
# conditional retrieval of extra's
if PR.p["file_count"] < config["file_scan_max"]:
PR.setFileData(pullrequest.get_files())
if PR.p["commit_count"] < 20:
PR.setCommitData(pullrequest.get_commits())
# retrieve maintainers from portage repo
for package in PR.p["packages"]:
PR.p["maintainers"] = getMaintainers(package,repo_path)
# retrieving bugzilla status
for bug in PR.p["bugs"]:
r = requests.get("https://bugs.gentoo.org/rest/bug/" + bug + "?include_fields=status,resolution")
bugdata = r.json()
PR.p["bugs"][bug] = bugdata["bugs"][0]["status"] + "/" + bugdata["bugs"][0]["resolution"]
# todo, perhaps track dupe_of in case of DUPLICATE
updated_db.addPull(PR.nr,PR.p)
# and write
updated_db.write(version)