feature: agrego soporte para apis gitea

This commit is contained in:
jt
2026-07-08 21:12:06 -03:00
parent c93833769b
commit 87c5ba81c4
6 changed files with 82 additions and 31 deletions
+17 -3
View File
@@ -2,12 +2,14 @@ from git_flow import (
BRANCH_TYPES,
REPOSITORY_TOKEN_FILENAME,
FLOWCONFIG_FILENAME,
FLOWCONFIG_VERSION,
GitFlowError,
)
from git_flow.git import Git
from git_flow.remote.base import RemoteAPI
from git_flow.remote.bitbucket import BitbucketRemoteAPI
from git_flow.remote.github import GithubRemoteAPI
from git_flow.remote.gitea import GiteaRemoteAPI
from git_flow.io import *
from os.path import isfile
@@ -32,6 +34,14 @@ def ensure_initialized():
f"El valor de `flow.initialized` ({initialized}) es inválido."
)
version = int(flowconfig.get("flow.version", "1"))
if version != FLOWCONFIG_VERSION:
raise GitFlowError(
f"La versión del flowconfig ({version}) no es compatible con esta versión de git-flow ({FLOWCONFIG_VERSION}). "
f"Debe reinicializar el repositorio."
)
def ensure_right_branch():
branch = Git.get_current_branch()
@@ -104,14 +114,18 @@ def get_remote_api(token: str) -> RemoteAPI:
if "flow.remote" not in flowconfig:
raise GitFlowError("El repositorio no tiene configurado un remoto.")
remote_type = flowconfig.get("flow.remote-type", "").lower()
[host, repository] = RemoteAPI.parse(flowconfig["flow.remote"])
if host == "bitbucket.org":
if remote_type == "gitea":
return GiteaRemoteAPI(host, repository, token)
elif remote_type == "bitbucket":
return BitbucketRemoteAPI(repository, token)
elif host == "github.com":
elif remote_type == "github":
return GithubRemoteAPI(repository, token)
else:
raise GitFlowError("El host del repositorio remoto es inválido")
raise GitFlowError("El tipo del remoto es inválido")
def is_valid_ticket(ticket: str) -> bool:
"""Check if the specified string is a valid ticket number (ABC-123)"""