infra/services/hound/update-hound.py

68 lines
1.6 KiB
Python
Raw Normal View History

#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3Packages.python -p python3Packages.requests
import json
2022-12-31 07:24:17 +01:00
import requests
2022-10-13 07:03:39 +10:00
disallowed_repos = [
2022-12-31 07:24:17 +01:00
"NixOS/nixops-dashboard", # empty repo causes an error
]
2022-10-13 07:03:39 +10:00
allowed_forks = [
2022-12-31 07:24:17 +01:00
"nix-community/acpi_call",
"nix-community/bundix",
"nix-community/luarocks-nix",
"nix-community/nix-doom-emacs",
"nix-community/nix-straight.el",
"nix-community/travis-build",
"nix-community/vagrant-nixos-plugin",
"NixOS/calamares-nixos-extensions",
]
def all_for_org(org):
resp = {}
2022-12-31 07:24:17 +01:00
next_url = "https://api.github.com/orgs/{}/repos".format(org)
while next_url is not None:
repo_resp = requests.get(next_url)
2022-12-31 07:24:17 +01:00
if "next" in repo_resp.links:
next_url = repo_resp.links["next"]["url"]
else:
next_url = None
repos = repo_resp.json()
2022-12-31 07:24:17 +01:00
resp.update(
{
"{}-{}".format(org, repo["name"]): {
"url": repo["clone_url"],
}
for repo in repos
if repo["full_name"] not in disallowed_repos
if repo["archived"] is False
if repo["fork"] is False or repo["full_name"] in allowed_forks
}
2022-12-31 07:24:17 +01:00
)
return resp
2022-12-31 07:24:17 +01:00
repos = {**all_for_org("NixOS"), **all_for_org("nix-community")}
print(
json.dumps(
{
"max-concurrent-indexers": 1,
"dbpath": "/var/lib/hound/data",
"repos": repos,
"vcs-config": {"git": {"detect-ref": True}},
2021-02-20 12:57:20 +01:00
},
2022-12-31 07:24:17 +01:00
indent=4,
sort_keys=True,
)
)