refactor: remove unused constants, move io functions to module
This commit is contained in:
+13
-12
@@ -1,9 +1,7 @@
|
||||
import subprocess
|
||||
|
||||
from git_flow import GitFlowError
|
||||
from git_flow.io import *
|
||||
|
||||
|
||||
FLOWCONFIG_FILE = ".flowconfig"
|
||||
|
||||
CHANGELOG_FILE = "CHANGELOG.md"
|
||||
@@ -88,7 +86,9 @@ class Git:
|
||||
except subprocess.CalledProcessError:
|
||||
return None
|
||||
|
||||
def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool | list[str] | None) -> None:
|
||||
def __init__(
|
||||
self, subcommand: str, *args: str, **kwargs: str | int | bool | list[str] | None
|
||||
) -> None:
|
||||
self.command = ["git", subcommand]
|
||||
|
||||
for option, value in kwargs.items():
|
||||
@@ -133,7 +133,7 @@ class Git:
|
||||
def exec(self, **kwargs):
|
||||
self._run(**kwargs)
|
||||
|
||||
def _get(self, print: str|None = None, check: bool = True):
|
||||
def _get(self, print: str | None = None, check: bool = True):
|
||||
process = subprocess.run(self.command, capture_output=True, text=True)
|
||||
|
||||
if print is not None:
|
||||
@@ -144,9 +144,10 @@ class Git:
|
||||
|
||||
return process
|
||||
|
||||
|
||||
def _run(self, print: str|None = None, check: bool = True):
|
||||
process = subprocess.run(self.command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
def _run(self, print: str | None = None, check: bool = True):
|
||||
process = subprocess.run(
|
||||
self.command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||
)
|
||||
|
||||
if print is not None:
|
||||
self._print_process("", "", title=print)
|
||||
@@ -168,12 +169,12 @@ class Git:
|
||||
|
||||
command.append(arg)
|
||||
|
||||
title = title or "Ejecutando"
|
||||
print(COLOR_YELLOW + "| " + title + COLOR_RESET)
|
||||
print(COLOR_YELLOW + "| $ " + " ".join(command) + COLOR_RESET)
|
||||
text = f"[yellow]$ {" ".join(command)}[/yellow]"
|
||||
|
||||
for line in stdout.splitlines():
|
||||
print(COLOR_YELLOW + "| " + COLOR_RESET + "[out] " + line)
|
||||
text += "\n\\[out] " + line
|
||||
|
||||
for line in stderr.splitlines():
|
||||
print(COLOR_YELLOW + "| " + COLOR_RED + "[err] " + line + COLOR_RESET)
|
||||
text += "\n[red]\\[err][/red] " + line
|
||||
|
||||
panel(title or "Ejecutando", text)
|
||||
|
||||
Reference in New Issue
Block a user