fix gitea.py

This commit is contained in:
2025-04-08 09:45:38 +02:00
parent c2747e884d
commit 90776bfeef
2 changed files with 17 additions and 16 deletions

View File

@ -80,24 +80,24 @@ def change_to_gitea(doit, *repos):
dirty = True dirty = True
if write_when_new(doit, '.git/hooks/pre-commit', PRE_COMMIT_HOOK): if write_when_new(doit, '.git/hooks/pre-commit', PRE_COMMIT_HOOK):
dirty = True dirty = True
if doit: dothis = False
dothis = False try:
try: if parser.get('credential', 'helper') != str(gitdir / hooks / 'get_gitea_token'):
if parser.get('credential', 'helper') != str(gitdir / hooks / 'get_gitea_token'):
dothis = True
print('need to change gitea credential helper')
except Exception:
dothis = True dothis = True
print('missing gitea credential helper') print('need to change gitea credential helper')
try: except Exception as e:
if parser.get('remote "origin"', 'url') != GITEA_URL % repo: dothis = True
dothis = True print('missing gitea credential helper', e)
print('need to change remote url') try:
except Exception: if parser.get('remote "origin"', 'url') != GITEA_URL % repo:
dothis = True dothis = True
print('missing remote url') print('need to change remote url')
if dothis: except Exception:
dirty = True dothis = True
print('missing remote url')
if dothis:
dirty = True
if doit:
os.system(f'git config credential.helper "{os.getcwd()}/.git/hooks/get_gitea_token"') os.system(f'git config credential.helper "{os.getcwd()}/.git/hooks/get_gitea_token"')
os.system(f'git remote set-url origin {GITEA_URL}') os.system(f'git remote set-url origin {GITEA_URL}')
finally: finally:

View File

@ -19,6 +19,7 @@ from pathlib import Path
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from ipaddress import IPv4Interface from ipaddress import IPv4Interface
from os.path import getmtime from os.path import getmtime
from gitea import change_to_gitea
def exit(): def exit():