aboutsummaryrefslogtreecommitdiff
path: root/tools/import-gh-to-gitea/archive-projects.py
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-03-06 06:29:24 -0800
committerFranck Cuny <franck@fcuny.net>2024-03-06 06:29:24 -0800
commit1e4a5aa09c1c8f43722c9c260f011398799a8e8f (patch)
treecd73e0fb8ba53bd21cee6ccf2dcc85639bbbb93f /tools/import-gh-to-gitea/archive-projects.py
parentset correct git email in the profiles (diff)
downloadinfra-1e4a5aa09c1c8f43722c9c260f011398799a8e8f.tar.gz
rename `tools` to `packages` to follow convention
The convention is to use `pkgs` or `packages` for overlays and definition of custom packages. Since I'm already using `pkg` for go, I prefer to use `packages` for my scripts.
Diffstat (limited to 'tools/import-gh-to-gitea/archive-projects.py')
-rwxr-xr-xtools/import-gh-to-gitea/archive-projects.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/tools/import-gh-to-gitea/archive-projects.py b/tools/import-gh-to-gitea/archive-projects.py
deleted file mode 100755
index 41bd898..0000000
--- a/tools/import-gh-to-gitea/archive-projects.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-
-import requests
-
-
-def main(api_token):
- s = requests.Session()
- s.headers.update({"Authorization": f"token {api_token}"})
- s.headers.update({"Accept": "application/json"})
- s.headers.update({"Content-Type": "application/json"})
-
- not_done = True
- page = 1
- while not_done:
- url = f"https://git.fcuny.net/api/v1/user/repos?page={page}&limit=10"
- res = s.get(
- url,
- timeout=5,
- )
- res.raise_for_status()
-
- repos = res.json()
- if len(repos) == 0:
- not_done = False
- else:
- page = page + 1
-
- for repo in repos:
- if repo.get("owner").get("login") == "attic":
- if repo.get("archived") is False:
- name = repo.get("name")
- data = {"archived": True}
- res = s.patch(
- f"https://git.fcuny.net/api/v1/repos/attic/{name}", json=data
- )
- res.raise_for_status()
- print(f"set {name} to archived: {res.status_code}")
-
-
-if __name__ == "__main__":
- argp = argparse.ArgumentParser()
- argp.add_argument("-t", "--token-file", nargs=1, type=argparse.FileType("r"))
-
- args = argp.parse_args()
- api_token = args.token_file[0].readline().strip()
-
- main(api_token)