Files
bircni 4a35b1577d enhance!: rename tea to gt
The CLI becomes gitea-cli, invoked as gt.

- module path gitea.dev/cli, repository gitea.com/gitea/cli
- the binary, completions and man pages are named gt
- environment variables use the GITEA_CLI_ prefix
- the configuration directory, keyring service and git config keys use
  gitea-cli
- release archives, the Docker image and the snap are named gitea-cli
- version builds only from v* tags
- remove the 1.0 migration guide

Signed-off-by: bircni <[email protected]>
2026-10-18 22:57:54 +02:00

46 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Create private PAT fixtures on the disposable CI Gitea instance."""
import base64
import json
import os
import urllib.request
import uuid
from pathlib import Path
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
def main():
url = os.environ["GITEA_CLI_TEST_URL"].rstrip("/")
fixtures = [
("integration", "gt-local-integration-pass", "GITEA_CLI_TEST_TOKEN_FILE"),
("gt-reviewer", "gt-local-reviewer-pass", "GITEA_CLI_TEST_REVIEWER_TOKEN_FILE"),
]
# Do not follow redirects with Basic credentials.
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect())
for user, password, variable in fixtures:
request = urllib.request.Request(
f"{url}/api/v1/users/{user}/tokens",
data=json.dumps({"name": f"gt-ci-{uuid.uuid4().hex}", "scopes": ["all"]}).encode(),
headers={
"Authorization": "Basic " + base64.b64encode(f"{user}:{password}".encode()).decode(),
"Content-Type": "application/json",
},
method="POST",
)
with opener.open(request, timeout=30) as response:
token = json.load(response)["sha1"]
destination = Path(os.environ[variable])
destination.parent.mkdir(parents=True, exist_ok=True)
descriptor = os.open(destination, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
with os.fdopen(descriptor, "w") as output:
output.write(token)
if __name__ == "__main__":
main()