WIP: adhesion, forgejo API

This commit is contained in:
Adrien Bourmault 2023-11-04 13:16:04 +01:00
parent 875d8c95f6
commit 2840b6333b
Signed by: neox
GPG Key ID: 2974E1D5F25DFCC8
1 changed files with 5 additions and 8 deletions

View File

@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
import os, requests, json, datetime, shutil, quopri, subprocess, base64, os import os, requests, json, datetime, shutil, quopri, subprocess, base64, os
import time, random, string, dateutil.parser, re, pygitea import time, random, string, dateutil.parser, re
from typing import List from typing import List
from requests.auth import HTTPBasicAuth from requests.auth import HTTPBasicAuth
from requests.auth import HTTPDigestAuth from requests.auth import HTTPDigestAuth
@ -68,13 +68,10 @@ def gestion_read(req):
return response.json() return response.json()
def forgejo_post_issue(owner, repo, title, body, labels): def forgejo_post_issue(owner, repo, title, body, labels):
gt = pygitea.API(GITEA_URL, token=git_get_secret()) import_response: requests.Response = requests.post('https://forge.a-lec.org/api/v1/repos/{}/{}/issues?access_token={}'.format(owner, repo, git_get_secret()), data={
gt_version = gt.get('/version').json() "body":body,
print("Connected to Forgejo, version: " + str(gt_version['version'])) "labels":labels,
import_response: requests.Response = gt.post("/repos/" + owner + "/" + repo + "/issues", json={ "title":title
"body": body,
"labels": labels,
"title": title,
}) })
if not(import_response.ok): if not(import_response.ok):
print("Erreur à l'envoi du ticket {} à {}".format(title, repo)) print("Erreur à l'envoi du ticket {} à {}".format(title, repo))