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,15 +80,14 @@ def change_to_gitea(doit, *repos):
dirty = True
if write_when_new(doit, '.git/hooks/pre-commit', PRE_COMMIT_HOOK):
dirty = True
if doit:
dothis = False
try:
if parser.get('credential', 'helper') != str(gitdir / hooks / 'get_gitea_token'):
dothis = True
print('need to change gitea credential helper')
except Exception:
except Exception as e:
dothis = True
print('missing gitea credential helper')
print('missing gitea credential helper', e)
try:
if parser.get('remote "origin"', 'url') != GITEA_URL % repo:
dothis = True
@ -98,6 +97,7 @@ def change_to_gitea(doit, *repos):
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 remote set-url origin {GITEA_URL}')
finally:

View File

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