style: format with ruff
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import giturlparse
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
import giturlparse
|
||||||
|
|
||||||
from git_flow import SUPPORTED_REMOTE_URL_SCHEMAS, GitFlowError
|
from git_flow import SUPPORTED_REMOTE_URL_SCHEMAS, GitFlowError
|
||||||
from git_flow.git import Git
|
from git_flow.git import Git
|
||||||
|
|
||||||
@@ -22,17 +23,23 @@ class RemoteAPI(ABC):
|
|||||||
"""
|
"""
|
||||||
url = Git("remote", "get-url", remote).firstline()
|
url = Git("remote", "get-url", remote).firstline()
|
||||||
|
|
||||||
parsed_url = giturlparse.parse(url) # Validamos que la URL sea válida
|
parsed_url = giturlparse.parse(url) # Validamos que la URL sea válida
|
||||||
|
|
||||||
if not parsed_url.valid:
|
if not parsed_url.valid:
|
||||||
raise GitFlowError(f"La URL del remoto {remote} es inválida: {url}")
|
raise GitFlowError(f"La URL del remoto {remote} es inválida: {url}")
|
||||||
|
|
||||||
if not parsed_url.protocol in SUPPORTED_REMOTE_URL_SCHEMAS:
|
if not parsed_url.protocol in SUPPORTED_REMOTE_URL_SCHEMAS:
|
||||||
raise GitFlowError(f"La URL del remoto {remote} no tiene un esquema soportado: {url}")
|
raise GitFlowError(
|
||||||
|
f"La URL del remoto {remote} no tiene un esquema soportado: {url}"
|
||||||
|
)
|
||||||
|
|
||||||
# Cuando el host es seteado por pipeline puede ser "http://gitea/OWNER/REPO", en ese caso
|
# Cuando el host es seteado por pipeline puede ser "http://gitea/OWNER/REPO", en ese caso
|
||||||
# la libreria parsea OWNER="" y REPO="OWNER/REPO"
|
# la libreria parsea OWNER="" y REPO="OWNER/REPO"
|
||||||
repository = "/".join(filter(None, [parsed_url.owner, parsed_url.repo])).removeprefix("/").removesuffix(".git")
|
repository = (
|
||||||
|
"/".join(filter(None, [parsed_url.owner, parsed_url.repo]))
|
||||||
|
.removeprefix("/")
|
||||||
|
.removesuffix(".git")
|
||||||
|
)
|
||||||
|
|
||||||
return [parsed_url.protocol + "://", parsed_url.host, repository]
|
return [parsed_url.protocol + "://", parsed_url.host, repository]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user