Compare commits
1 Commits
master
...
update-fla
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83a864607c |
12
flake.lock
generated
12
flake.lock
generated
@@ -3,11 +3,11 @@
|
|||||||
"nix": {
|
"nix": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1768160797,
|
"lastModified": 1772065213,
|
||||||
"narHash": "sha256-TVKn52SoKq8mMyW/x3NPPskGVurFdnGGV0DGvnL0gak=",
|
"narHash": "sha256-DbYpmZAD6aebwxepBop5Ub4S39sLg9UIJziTbeD832k=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nix",
|
"repo": "nix",
|
||||||
"rev": "fb562abba93fb15f66a71a9fc1d94bb1ea21a2d4",
|
"rev": "0769726d44b0782fecbd7b9749e24320c77af317",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1768332487,
|
"lastModified": 1772934839,
|
||||||
"narHash": "sha256-Q0bSMhDIhb/S7r+XRyuPy58kEXa0rmpw5j99ubJzovg=",
|
"narHash": "sha256-6mMYkB7BTTsc4thtCFbh3Aj5yth3EPI6L9L5DR6tpWc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6b0609442afc4ce51ff1466e7db555c2e2fc28d4",
|
"rev": "d351a3bce30b8f0d0a36281754b62942977fabe5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
#/usr/bin/env python3
|
|
||||||
|
|
||||||
#imports
|
|
||||||
import os
|
|
||||||
import json
|
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
||||||
import urllib.request
|
|
||||||
|
|
||||||
#Vars
|
|
||||||
baseurl="git.dynamicdiscord.de"
|
|
||||||
owner="ahtlon"
|
|
||||||
repo="infrastructure"
|
|
||||||
host="127.0.0.1"
|
|
||||||
port=27364
|
|
||||||
|
|
||||||
def _get_api_response():
|
|
||||||
###https://docs.gitea.com/api/1.21/#tag/repository/operation/repoListPullRequests
|
|
||||||
###GET /api/v1/repos/{owner}/{repo}/pulls
|
|
||||||
url=(f"https://{baseurl}/api/v1/repos/{owner}/{repo}/pulls?state=open")
|
|
||||||
headers={"Accept": "application/json"}
|
|
||||||
req=urllib.request.Request(url, headers=headers)
|
|
||||||
with urllib.request.urlopen(req) as resp:
|
|
||||||
return json.loads(resp.read().decode("utf-8"))
|
|
||||||
|
|
||||||
def _parse_response():
|
|
||||||
target_repo_url=f"https://{baseurl}/{owner}/{repo}.git"
|
|
||||||
pulls: dict={}
|
|
||||||
response=_get_api_response()
|
|
||||||
for pr in response:
|
|
||||||
pr["target_repo_url"]=target_repo_url
|
|
||||||
pulls[str(pr["number"])]=pr
|
|
||||||
return pulls
|
|
||||||
|
|
||||||
class PullsHandler(BaseHTTPRequestHandler):
|
|
||||||
_VALID_PATHS={"/", "/gitea-pulls-sorted.json"}
|
|
||||||
|
|
||||||
def do_GET(self):
|
|
||||||
if self.path not in self._VALID_PATHS:
|
|
||||||
self.send_error(404, "Not Found")
|
|
||||||
return
|
|
||||||
|
|
||||||
answer=dict(_parse_response())
|
|
||||||
|
|
||||||
body=json.dumps(answer, indent=2, sort_keys=True).encode("utf-8")
|
|
||||||
|
|
||||||
self.send_response(200)
|
|
||||||
self.send_header("Content-Type", "application/json; charset=utf-8")
|
|
||||||
self.send_header("Content-Length", str(len(body)))
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(body)
|
|
||||||
|
|
||||||
def log_message(self, fmt, *args):
|
|
||||||
print(
|
|
||||||
f"[gitea-translator] {self.address_string()} - {fmt % args}",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
print(
|
|
||||||
f"[gitea-translator] Starting, pulling from {baseurl}/{owner}/{repo}",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
server=HTTPServer((host, port), PullsHandler)
|
|
||||||
print(
|
|
||||||
f"[gitea-translator] online @ {host}:{port}",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
server.serve_forever()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user