2020-10-06 10:49:10 +02:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i python3 -p python3Packages.python -p python3Packages.requests
|
|
|
|
|
|
|
|
import json
|
2023-01-16 09:17:23 +10:00
|
|
|
import os
|
2022-12-31 07:24:17 +01:00
|
|
|
|
|
|
|
import requests
|
2020-10-06 10:49:10 +02:00
|
|
|
|
2023-01-16 09:17:23 +10:00
|
|
|
github_token = os.environ.get("GITHUB_TOKEN")
|
|
|
|
|
2022-10-13 07:03:39 +10:00
|
|
|
disallowed_repos = [
|
2023-01-16 09:19:37 +10:00
|
|
|
"nix-community/dream2nix-auto-test",
|
|
|
|
"nix-community/image-spec",
|
|
|
|
"nix-community/nix",
|
|
|
|
"nix-community/nixpkgs",
|
|
|
|
"nix-community/nsncd",
|
|
|
|
"nix-community/rkwifibt",
|
2022-12-31 07:24:17 +01:00
|
|
|
"NixOS/nixops-dashboard", # empty repo causes an error
|
|
|
|
]
|
2022-10-13 07:03:39 +10:00
|
|
|
|
2020-10-06 10:49:10 +02:00
|
|
|
|
2020-10-06 19:20:34 +02:00
|
|
|
def all_for_org(org):
|
2020-10-06 10:49:10 +02:00
|
|
|
|
|
|
|
resp = {}
|
|
|
|
|
2022-12-31 07:24:17 +01:00
|
|
|
next_url = "https://api.github.com/orgs/{}/repos".format(org)
|
2020-10-06 10:49:10 +02:00
|
|
|
while next_url is not None:
|
2023-01-16 09:17:23 +10:00
|
|
|
|
|
|
|
if github_token is not None:
|
|
|
|
headers = {"Authorization": f"token {github_token}"}
|
|
|
|
repo_resp = requests.get(next_url, headers=headers)
|
|
|
|
else:
|
|
|
|
repo_resp = requests.get(next_url)
|
2020-10-06 10:49:10 +02:00
|
|
|
|
2022-12-31 07:24:17 +01:00
|
|
|
if "next" in repo_resp.links:
|
|
|
|
next_url = repo_resp.links["next"]["url"]
|
2020-10-06 10:49:10 +02:00
|
|
|
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
|
2020-10-06 10:49:10 +02:00
|
|
|
}
|
2022-12-31 07:24:17 +01:00
|
|
|
)
|
2020-10-06 10:49:10 +02: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
|
|
|
},
|
2023-03-09 13:58:22 +10:00
|
|
|
indent=2,
|
2022-12-31 07:24:17 +01:00
|
|
|
sort_keys=True,
|
|
|
|
)
|
|
|
|
)
|