Compare commits

...
19 Commits
Author SHA1 Message Date
bitbucket-pipelines 341e6239b2 chore: bump version and update CHANGELOG.md [skip ci] 2025-11-28 18:48:40 +00:00
JonathanGitFlowandjt 4fb00e786f Merged in bugfix/command-init-merge-errors (pull request #38)
bugfix: command init merge errors

Approved-by: Jonathan Teran
2025-11-28 18:48:15 +00:00
Jonathan Teran Carballo 2ad747111f bugfix: arreglo split de ramas de flow.branches 2025-11-28 15:44:05 -03:00
Jonathan Teran Carballo 5c3a3171fd bugfix: arreglo iteracion de items de flowconfig en set_config 2025-11-28 15:43:46 -03:00
Jonathan Teran Carballo 50979e2c3d docs: agrego venv a lista de carpetas ignoradas 2025-11-28 15:42:54 -03:00
bitbucket-pipelines a670b90899 chore: bump version and update CHANGELOG.md [skip ci] 2025-11-27 02:35:54 +00:00
JonathanGitFlowandjt 532a93e95e Merged in refactor/move-constants (pull request #37)
refactor: move constants

Approved-by: Jonathan Teran
2025-11-27 02:35:28 +00:00
jt 29757ccfb5 refactor: muevo constantes a modulo git_flow para centralizar uso 2025-11-26 23:35:00 -03:00
jt 7f857fdd68 bugfix: ignorar carpetas generadas en build de lsp 2025-11-26 23:34:39 -03:00
bitbucket-pipelines 432885e107 chore: bump version and update CHANGELOG.md [skip ci] 2025-11-27 01:53:24 +00:00
JonathanGitFlowandjt a7ea4a6149 Merged in feature/branch-list-format (pull request #36)
feature: branch list format

Approved-by: Jonathan Teran
2025-11-27 01:53:01 +00:00
jt 717708469a feature: modifico formato de listado de ramas 2025-11-26 22:51:58 -03:00
bitbucket-pipelines 542c629489 chore: bump version and update CHANGELOG.md [skip ci] 2025-11-23 21:51:20 +00:00
JonathanGitFlowandjt 3c271be415 Merged in feature/add-branch-command (pull request #35)
feature: add branch command

Approved-by: Jonathan Teran
2025-11-23 21:50:57 +00:00
jt c74f1a3093 feature: agrego comando branch para listar ramas 2025-11-23 18:50:00 -03:00
jt eafb3f1b31 feature: agrego soporte para parametros repetidos en llamadas a Git 2025-11-23 18:49:42 -03:00
JonathanGitFlowandjt 82b9a70400 Merged in docs/agregar-seccion-instalacion (pull request #34)
docs: agregar seccion instalacion

Approved-by: Jonathan Teran
2025-11-23 07:05:38 +00:00
jt 6f90a37ba2 style: arreglo sublistas en seccion configuracion 2025-11-23 04:04:48 -03:00
jt 5a641938c0 docs: agrego seccion con pasos de instalacion 2025-11-23 04:02:35 -03:00
12 changed files with 199 additions and 36 deletions
+8 -3
View File
@@ -1,6 +1,11 @@
# Bitbucket token
.repository-token .repository-token
**/__pycache__/ # Virtual environment
build/ venv/
**/*.egg-info/
# Build folders and artifacts
dist/ dist/
build/
**/__pycache__/
**/*.egg-info/
+40
View File
@@ -1,3 +1,43 @@
## v1.5.2 - 2025-11-28
### Commits
- **bugfix**: arreglo split de ramas de flow.branches [[jteran](mailto:jteran@renatre.org.ar)] (2ad7471)
- **bugfix**: arreglo iteracion de items de flowconfig en set_config [[jteran](mailto:jteran@renatre.org.ar)] (5c3a317)
- **docs**: agrego venv a lista de carpetas ignoradas [[jteran](mailto:jteran@renatre.org.ar)] (50979e2)
---
## v1.5.1 - 2025-11-27
### Commits
- **refactor**: muevo constantes a modulo git_flow para centralizar uso [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (29757cc)
- **bugfix**: ignorar carpetas generadas en build de lsp [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (7f857fd)
---
## v1.5.0 - 2025-11-27
### Commits
- **feature**: modifico formato de listado de ramas [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (7177084)
---
## v1.4.0 - 2025-11-23
### Commits
- **feature**: agrego comando branch para listar ramas [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (c74f1a3)
- **feature**: agrego soporte para parametros repetidos en llamadas a Git [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (eafb3f1)
---
## v1.3.0 - 2025-11-23 ## v1.3.0 - 2025-11-23
### Commits ### Commits
+26 -5
View File
@@ -7,6 +7,30 @@ Herramienta para establecer un workflow siguiendo [Conventional Commits
Esta diseñada para facilitar la creación de commits y branches en un formato estandar, que permite Esta diseñada para facilitar la creación de commits y branches en un formato estandar, que permite
derivar versiones automaticamente de los merges sobre ramas principales. derivar versiones automaticamente de los merges sobre ramas principales.
## Instalación
Para instalar Git Flow, se sugiere utilizar [pipx](https://github.com/pypa/pipx) (seguir la
documentación para instalarlo). Una vez instalado `pipx`, simplemente clonamos el repositorio en una
carpeta local, y lo instalamos:
```sh
cd ~/Downloads
git clone git@bitbucket.org:sushi2717/git-flow.git
cd git-flow
pipx install .
```
Luego podemos verificar que se haya instalado correctamente ejecutando: `git-flow -h`
Para actualizarlo, hacemos un pull de los cambios recientes del repositorio, y hacemos el upgrade
mediante `pipx`:
```sh
cd ~/Downloads/git-flow
git pull
pipx upgrade git-flow
```
## Configuración ## Configuración
Para poder usar la herramienta en un repositorio, necesitamos inicializarlo: Para poder usar la herramienta en un repositorio, necesitamos inicializarlo:
@@ -29,11 +53,8 @@ El comando solicitará 2 opciones:
El mismo se puede crear desde: *"Atlassian Account Settings" > "Security" > "Create and Manage API El mismo se puede crear desde: *"Atlassian Account Settings" > "Security" > "Create and Manage API
Tokens" > "Create API Tokens with scopes"*. El token necesita el scope `write:pullrequest:bitbucket` Tokens" > "Create API Tokens with scopes"*. El token necesita el scope `write:pullrequest:bitbucket`
- `write:repository:bitbucket` Luego se debe guardar el token dentro del repositorio a configurar, en el archivo
`.repository-token`. De no especificarse, los merges y tags se harán de forma local.
Luego se debe guardar el token dentro del repositorio a configurar, en el archivo `.repository-token`.
De no especificarse, los merges y tags se harán de forma local.
## Utilización ## Utilización
+6
View File
@@ -0,0 +1,6 @@
{
"exclude": [
"build",
"**/*.egg-info"
]
}
+13 -1
View File
@@ -18,7 +18,7 @@ COMMIT_TYPES = [
"docs", "docs",
"style", "style",
"test", "test",
"wip" "wip",
] ]
# Commits con estos valores incrementan el componente correspondiente # Commits con estos valores incrementan el componente correspondiente
@@ -46,3 +46,15 @@ SUPPORTED_REMOTE_APIS = [
] ]
REPOSITORY_TOKEN_FILENAME = ".repository-token" REPOSITORY_TOKEN_FILENAME = ".repository-token"
COLOR_BLACK = "\033[30m"
COLOR_RED = "\033[31m"
COLOR_GREEN = "\033[32m"
COLOR_YELLOW = "\033[33m"
COLOR_BLUE = "\033[34m"
COLOR_5 = "\033[35m"
COLOR_6 = "\033[36m"
COLOR_7 = "\033[37m"
COLOR_BLACK_BOLD = "\033[1;30m"
COLOR_WHITE_BOLD = "\033[1;37m"
COLOR_RESET = "\033[0m"
+6 -12
View File
@@ -4,6 +4,11 @@ from os.path import isfile
from git_flow import ( from git_flow import (
BRANCH_TYPES, BRANCH_TYPES,
COLOR_BLUE,
COLOR_GREEN,
COLOR_RED,
COLOR_RESET,
COLOR_YELLOW,
REPOSITORY_TOKEN_FILENAME, REPOSITORY_TOKEN_FILENAME,
GitFlowError, GitFlowError,
) )
@@ -12,17 +17,6 @@ from git_flow.remote.base import RemoteAPI
from git_flow.remote.bitbucket import BitbucketRemoteAPI from git_flow.remote.bitbucket import BitbucketRemoteAPI
from git_flow.remote.github import GithubRemoteAPI from git_flow.remote.github import GithubRemoteAPI
COLOR_BLACK = "\033[30m"
COLOR_RED = "\033[31m"
COLOR_GREEN = "\033[32m"
COLOR_YELLOW = "\033[33m"
COLOR_BLUE = "\033[34m"
COLOR_5 = "\033[35m"
COLOR_6 = "\033[36m"
COLOR_7 = "\033[37m"
COLOR_BLACK_BOLD = "\033[1;30m"
COLOR_RESET = "\033[0m"
TYPE_SUCCESS = 0 TYPE_SUCCESS = 0
TYPE_WARNING = 1 TYPE_WARNING = 1
TYPE_ERROR = 2 TYPE_ERROR = 2
@@ -176,7 +170,7 @@ class Command(ABC):
def get_branch_env_and_type(self, branch: str) -> tuple[str, str]: def get_branch_env_and_type(self, branch: str) -> tuple[str, str]:
components = branch.split("/") components = branch.split("/")
target_branches = self.flowconfig["flow.branches"].split(" ") target_branches = self.flowconfig["flow.branches"].split(",")
if len(components) == 2: if len(components) == 2:
if components[0] not in BRANCH_TYPES: if components[0] not in BRANCH_TYPES:
+89
View File
@@ -0,0 +1,89 @@
from argparse import ArgumentParser, Namespace
from git_flow import COLOR_WHITE_BOLD, COLOR_GREEN, COLOR_RED, COLOR_RESET, GitFlowError
from git_flow.command.base import Command
from git_flow.git import Git
BRANCH_FORMAT = "%(refname:short)"
class BranchCommand(Command):
def name(self) -> str:
return "branch"
def description(self) -> str:
return """Lista ramas del repositorio, agrupandolas por entorno objetivo"""
def setup_parser(self, parser: ArgumentParser) -> ArgumentParser:
parser.add_argument(
"environment",
nargs="?",
help="Entorno de las ramas a listar. Puede ser vacio para listar ramas de todos los entornos, un entorno válido, o 'trash' para listar las ramas eliminadas.",
)
return parser
def run(self, args: Namespace = Namespace()):
self.ensure_initialized()
self.current_branch = Git.get_current_branch()
self.environments = self.flowconfig["flow.branches"].split(",")
if args.environment is None:
self.show_envs()
self.show_all_branches()
elif args.environment in self.environments:
self.show_envs()
self.show_env_branches(args.environment)
elif args.environment == "trash":
self.show_trash_branches()
else:
raise GitFlowError(f"'{args.environment}' no es un entorno válido.")
def show_trash_branches(self):
branches = self.get_trash_branches()
if not branches:
print("No hay ramas a mostrar.")
return
for branch in branches:
prefix = (COLOR_RED + "*") if branch == self.current_branch else " "
print(prefix + " " + branch + COLOR_RESET)
def get_trash_branches(self):
return Git("for-each-ref", "refs/heads/trash/", format=BRANCH_FORMAT).lines()
def show_all_branches(self):
for environment in self.environments:
self.show_env_branches(environment, len(self.environments) > 1)
trash = len(self.get_trash_branches())
if trash:
print()
print(COLOR_WHITE_BOLD + "Papelera: " + COLOR_RESET + str(trash) + " rama" + ("" if trash == 1 else "s"))
def show_envs(self):
print(COLOR_WHITE_BOLD + "Entornos" + COLOR_RESET)
for environment in self.environments:
prefix = (COLOR_GREEN + "*") if environment == self.current_branch else " "
print(prefix + " " + environment + COLOR_RESET)
print()
def show_env_branches(self, environment: str, show_env: bool = False):
is_first_env = environment == self.environments[0]
pattern = "refs/heads/" if is_first_env else "refs/heads/release/" + environment + "/"
pattern += "*/*"
exclude = ["refs/heads/trash/", "refs/heads/release/"] if is_first_env else []
branches = Git("for-each-ref", pattern, exclude=exclude, format=BRANCH_FORMAT).lines()
print(COLOR_WHITE_BOLD + (environment if show_env else "Ramas") + COLOR_RESET)
if not branches:
print("No hay ramas a mostrar.")
return
for branch in branches:
prefix = (COLOR_GREEN + "*") if branch == self.current_branch else " "
print(prefix + " " + branch + COLOR_RESET)
-1
View File
@@ -1,5 +1,4 @@
from argparse import Namespace from argparse import Namespace
import os
from git_flow import GitFlowError from git_flow import GitFlowError
from git_flow.command.base import Command from git_flow.command.base import Command
from git_flow.git import FLOWCONFIG_FILE, Git from git_flow.git import FLOWCONFIG_FILE, Git
+1 -1
View File
@@ -56,7 +56,7 @@ class TagCommand(Command):
def get_token_and_ci(self, args: Namespace): def get_token_and_ci(self, args: Namespace):
try: try:
return (self.ensure_repository_token(), False) return (self.ensure_repository_token(), False)
except GitFlowError as e: except GitFlowError:
return (args.token, True) return (args.token, True)
def setup_parser(self, parser: ArgumentParser) -> ArgumentParser: def setup_parser(self, parser: ArgumentParser) -> ArgumentParser:
+5 -2
View File
@@ -38,7 +38,7 @@ class Git:
@staticmethod @staticmethod
def set_config(config: dict[str, str], file: str | None = None): def set_config(config: dict[str, str], file: str | None = None):
for key, value in config: for key, value in config.items():
Git("config", key, value, file=file).exec() Git("config", key, value, file=file).exec()
@staticmethod @staticmethod
@@ -89,7 +89,7 @@ class Git:
def is_repository() -> bool: def is_repository() -> bool:
return Git("rev-parse", is_inside_work_tree=True).code() == 0 return Git("rev-parse", is_inside_work_tree=True).code() == 0
def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool | None) -> None: def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool | list[str] | None) -> None:
self.command = ["git", subcommand] self.command = ["git", subcommand]
for option, value in kwargs.items(): for option, value in kwargs.items():
@@ -103,6 +103,9 @@ class Git:
self.command.append(prefix + option) self.command.append(prefix + option)
elif value is None: elif value is None:
continue continue
elif isinstance(value, list):
for v in value:
self.command.append("--" + option + "=" + v)
else: else:
value = value if isinstance(value, str) else str(value) value = value if isinstance(value, str) else str(value)
+1 -9
View File
@@ -1,14 +1,6 @@
import sys import sys
from git_flow import COLOR_BLACK_BOLD, COLOR_BLUE, COLOR_GREEN, COLOR_RED, COLOR_RESET, COLOR_YELLOW
COLOR_BLACK = '\033[30m'
COLOR_RED = '\033[31m'
COLOR_GREEN = '\033[32m'
COLOR_YELLOW = '\033[33m'
COLOR_BLUE = '\033[34m'
COLOR_BLACK_BOLD = '\033[1;30m'
COLOR_RESET = '\033[0m'
def confirm(prompt, default: bool = True): def confirm(prompt, default: bool = True):
user_input = input(prompt + (" [Y/n]: " if default else " [y/N]: ")) user_input = input(prompt + (" [Y/n]: " if default else " [y/N]: "))
+2
View File
@@ -5,6 +5,7 @@ from argparse import Namespace, ArgumentParser
from git_flow import GitFlowError from git_flow import GitFlowError
from git_flow.command.base import Command from git_flow.command.base import Command
from git_flow.command.branch import BranchCommand
from git_flow.command.commit import CommitCommand from git_flow.command.commit import CommitCommand
from git_flow.command.init import InitCommand from git_flow.command.init import InitCommand
from git_flow.command.merge import MergeCommand from git_flow.command.merge import MergeCommand
@@ -70,6 +71,7 @@ def main():
MergeCommand(), MergeCommand(),
TagCommand(), TagCommand(),
ReleaseCommand(), ReleaseCommand(),
BranchCommand()
) )
try: try:
command.run() command.run()