feature: agrego soporte para apis gitea
This commit is contained in:
@@ -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)"""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import typer
|
||||
|
||||
from git_flow import FLOWCONFIG_FILENAME, GitFlowError
|
||||
from git_flow import FLOWCONFIG_FILENAME, FLOWCONFIG_VERSION, GitFlowError
|
||||
from git_flow.git import Git
|
||||
from git_flow.command.base import *
|
||||
|
||||
@@ -15,15 +15,17 @@ def init():
|
||||
_ensure_not_already_initialized()
|
||||
|
||||
branches = _setup_flow_branches()
|
||||
remote = _setup_flow_remote()
|
||||
(remote, remote_type) = _setup_flow_remote()
|
||||
|
||||
flowconfig = {
|
||||
"flow.version": str(FLOWCONFIG_VERSION),
|
||||
"flow.initialized": "true",
|
||||
"flow.branches": ",".join(branches),
|
||||
}
|
||||
|
||||
if remote:
|
||||
if remote and remote_type:
|
||||
flowconfig["flow.remote"] = remote
|
||||
flowconfig["flow.remote-type"] = remote_type
|
||||
|
||||
Git.set_config(flowconfig, FLOWCONFIG_FILENAME)
|
||||
Git("add", FLOWCONFIG_FILENAME).exec()
|
||||
@@ -74,6 +76,7 @@ def _setup_flow_remote():
|
||||
)
|
||||
|
||||
remote = None
|
||||
remote_type = None
|
||||
|
||||
if confirm("¿Configurar repositorio remoto?"):
|
||||
remotes = Git("remote").lines(print="Listando remotos disponibles")
|
||||
@@ -93,7 +96,9 @@ def _setup_flow_remote():
|
||||
info("Tiene más de un remoto, seleccione el que va a utilizar.")
|
||||
remote = choice("Remoto", remotes)
|
||||
|
||||
return remote
|
||||
remote_type = choice("Tipo de remoto:", ["bitbucket", "github", "gitea"])
|
||||
|
||||
return (remote, remote_type)
|
||||
|
||||
|
||||
def _ensure_all_flow_branches_exist(branches: list[str], remote: str | None):
|
||||
|
||||
Reference in New Issue
Block a user