Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
379e0f3257 | ||
|
|
4a57dfd121 | ||
|
|
01e938ebd9 | ||
|
|
97b4a56ff7 | ||
|
|
24be50111d | ||
|
|
897e9aa53b | ||
|
|
e4800d1054 | ||
|
|
0d95a978bf | ||
|
|
0af5102fae | ||
|
|
2a21922a63 | ||
|
|
12b2bc9a39 | ||
|
|
b24b22a178 | ||
|
|
c5f1be346c | ||
|
|
6c32b3e751 | ||
|
|
5600e5ec83 | ||
|
|
57142afa40 | ||
|
|
4375af35d9 | ||
|
|
44b8efd953 | ||
|
|
f4b47000a6 | ||
|
|
b12d2a1930 | ||
|
|
7b4fb34ef3 | ||
|
|
6a758cdb94 | ||
|
|
b148a9f71d | ||
|
|
2e65cb7a3e | ||
|
|
9c8df34a09 | ||
|
|
89f8bc58ba | ||
|
|
4e089dc4d6 | ||
|
|
c8e1a7cc88 | ||
|
|
65be7a01f0 | ||
|
|
7ce6addf07 | ||
|
|
824b5f06de | ||
|
|
9937f4b6bc | ||
|
|
053b8b102b | ||
|
|
a2475195b2 | ||
|
|
603519bf39 | ||
|
|
0c8e7bb37a | ||
|
|
6643271747 | ||
|
|
68e11c66d1 | ||
|
|
f1f6e6724c | ||
|
|
83df7e9553 | ||
|
|
f5e683a1da | ||
|
|
fb9b8b57f6 | ||
|
|
c47afffa14 | ||
|
|
341e6239b2 | ||
|
|
4fb00e786f | ||
|
|
2ad747111f | ||
|
|
5c3a3171fd | ||
|
|
50979e2c3d | ||
|
|
a670b90899 | ||
|
|
532a93e95e | ||
|
|
29757ccfb5 | ||
|
|
7f857fdd68 | ||
|
|
432885e107 | ||
|
|
a7ea4a6149 | ||
|
|
717708469a | ||
|
|
542c629489 | ||
|
|
3c271be415 | ||
|
|
c74f1a3093 | ||
|
|
eafb3f1b31 | ||
|
|
82b9a70400 | ||
|
|
6f90a37ba2 | ||
|
|
5a641938c0 |
+8
-3
@@ -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/
|
||||||
|
|||||||
+140
@@ -1,3 +1,143 @@
|
|||||||
|
## v1.8.0 - 2025-12-15
|
||||||
|
|
||||||
|
- **feature**: agrego opcion para incluir ticket en nombre de rama [[jteran](mailto:jteran@renatre.org.ar)] (01e938e)
|
||||||
|
- **feature**: mostrar warning si la rama actual no es un entorno configurado [[jteran](mailto:jteran@renatre.org.ar)] (97b4a56)
|
||||||
|
- **feature**: hacer pull en rama actual antes de crear nueva rama [[jteran](mailto:jteran@renatre.org.ar)] (24be501)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.5 - 2025-12-14
|
||||||
|
|
||||||
|
- **bugfix**: verificar si la rama grupo trackea una rama remota antes de hacer pull [[jteran](mailto:jteran@renatre.org.ar)] (0d95a97)
|
||||||
|
- **bugfix**: capturo interrupion por teclado para no mostrar stack trace [[jteran](mailto:jteran@renatre.org.ar)] (0af5102)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.4 - 2025-12-14
|
||||||
|
|
||||||
|
- **bugfix**: generación de PR de ramas release [[jteran](mailto:jteran@renatre.org.ar)] (b24b22a)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.3 - 2025-12-14
|
||||||
|
|
||||||
|
- **bugfix**: listado de ramas para elegir grupo release no devolvia resultados [[jteran](mailto:jteran@renatre.org.ar)] (5600e5e)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.2 - 2025-12-11
|
||||||
|
|
||||||
|
- **bugfix**: al hacer un release, cambio a la rama grupo si esta disponible [[jteran](mailto:jteran@renatre.org.ar)] (44b8efd)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.1 - 2025-12-11
|
||||||
|
|
||||||
|
- **bugfix**: cambio la forma en la que se obtiene el first fork point entre 2 ramas [[jteran](mailto:jteran@renatre.org.ar)] (7b4fb34)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.0 - 2025-12-11
|
||||||
|
|
||||||
|
- **feature**: muestro el listado de commits a pasar al siguiente entorno en release [[jteran](mailto:jteran@renatre.org.ar)] (2e65cb7)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.6.4 - 2025-12-10
|
||||||
|
|
||||||
|
- **bugfix**: cambio la lista de commits a mostrar en el merge [[jteran](mailto:jteran@renatre.org.ar)] (4e089dc)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.6.3 - 2025-12-04
|
||||||
|
|
||||||
|
- **bugfix**: revertir guion entre version y entorno, agregar guion a sufijo [[jteran](mailto:jteran@renatre.org.ar)] (7ce6add)
|
||||||
|
- **bugfix**: agrego guion entre version y nombre de entorno [[jteran](mailto:jteran@renatre.org.ar)] (053b8b1)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.6.3- - 2025-12-04
|
||||||
|
|
||||||
|
- **bugfix**: agrego guion entre version y nombre de entorno [[jteran](mailto:jteran@renatre.org.ar)] (053b8b1)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.6.2 - 2025-12-04
|
||||||
|
|
||||||
|
- **bugfix**: crear changelog cuando no existe [[jteran](mailto:jteran@renatre.org.ar)] (0c8e7bb)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.6.1 - 2025-11-29
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
- **bugfix**: arreglo mensaje de confirmacion de squash, muevo prompt de commit message antes del squash [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (f1f6e67)
|
||||||
|
- **bugfix**: cambio default en confirmacion para agrupar release [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (83df7e9)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.6.0 - 2025-11-29
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
- **feature**: agrego opcion para agrupar ramas release [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (c47afff)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"exclude": [
|
||||||
|
"build",
|
||||||
|
"**/*.egg-info"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ class Changelog:
|
|||||||
|
|
||||||
return f"""## {title} - {now.strftime("%F")}
|
return f"""## {title} - {now.strftime("%F")}
|
||||||
|
|
||||||
### Commits
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def generate_content(self, base: str, branch: str):
|
def generate_content(self, base: str, branch: str):
|
||||||
@@ -56,5 +54,6 @@ class Changelog:
|
|||||||
if isfile(self.FILENAME):
|
if isfile(self.FILENAME):
|
||||||
with open(self.FILENAME, "r") as f:
|
with open(self.FILENAME, "r") as f:
|
||||||
content += f.read()
|
content += f.read()
|
||||||
|
|
||||||
with open(self.FILENAME, "w") as f:
|
with open(self.FILENAME, "w") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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,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
|
||||||
|
|||||||
@@ -17,16 +17,15 @@ class MergeCommand(Command):
|
|||||||
|
|
||||||
branch = self.ensure_right_branch()
|
branch = self.ensure_right_branch()
|
||||||
(target, _) = self.get_branch_env_and_type(branch)
|
(target, _) = self.get_branch_env_and_type(branch)
|
||||||
base = Git.get_first_fork_point(branch, target)
|
|
||||||
|
|
||||||
if "flow.remote" in self.flowconfig:
|
if "flow.remote" in self.flowconfig:
|
||||||
remote = self.flowconfig["flow.remote"]
|
remote = self.flowconfig["flow.remote"]
|
||||||
token = self.ensure_repository_token()
|
token = self.ensure_repository_token()
|
||||||
self.run_remote(remote, token, base, branch, target)
|
self.run_remote(remote, token, branch, target)
|
||||||
else:
|
else:
|
||||||
self.run_local(base, branch, target)
|
self.run_local(branch, target)
|
||||||
|
|
||||||
def run_remote(self, remote: str, token: str, base: str, branch: str, target: str):
|
def run_remote(self, remote: str, token: str, branch: str, target: str):
|
||||||
self.ensure_clean_worktree(True)
|
self.ensure_clean_worktree(True)
|
||||||
|
|
||||||
Git("switch", target).exec(print="Cambiando a rama destino")
|
Git("switch", target).exec(print="Cambiando a rama destino")
|
||||||
@@ -34,26 +33,26 @@ class MergeCommand(Command):
|
|||||||
Git("switch", "-").exec(print="Volviendo a rama a mergear")
|
Git("switch", "-").exec(print="Volviendo a rama a mergear")
|
||||||
|
|
||||||
self.check_merge_conflicts(target)
|
self.check_merge_conflicts(target)
|
||||||
self.show_commits_to_merge(base)
|
self.show_commits_to_merge(target)
|
||||||
|
|
||||||
if self.confirm(f"¿Crear PR de '{branch}' a '{target}'?"):
|
if self.confirm(f"¿Crear PR de '{branch}' a '{target}'?"):
|
||||||
Git("push", remote, branch, set_upstream=True).exec(
|
Git("push", remote, branch, set_upstream=True).exec(
|
||||||
print="Subiendo rama al remoto para crear PR"
|
print="Subiendo rama al remoto para crear PR"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.create_pull_request(token, base, branch, target)
|
self.create_pull_request(token, branch, target)
|
||||||
|
|
||||||
def run_local(self, base: str, branch: str, target: str):
|
def run_local(self, branch: str, target: str):
|
||||||
self.ensure_clean_worktree(False)
|
self.ensure_clean_worktree(False)
|
||||||
self.check_merge_conflicts(target)
|
self.check_merge_conflicts(target)
|
||||||
self.show_commits_to_merge(base)
|
self.show_commits_to_merge(target)
|
||||||
|
|
||||||
if self.confirm(f"¿Mergear rama '{branch}' a '{target}'?"):
|
if self.confirm(f"¿Mergear rama '{branch}' a '{target}'?"):
|
||||||
Git("switch", target).exec(print="Cambiando a rama destino")
|
Git("switch", target).exec(print="Cambiando a rama destino")
|
||||||
Git("merge", branch, ff=False).exec(print="Mergeando")
|
Git("merge", branch, ff=False).exec(print="Mergeando")
|
||||||
|
|
||||||
def show_commits_to_merge(self, base):
|
def show_commits_to_merge(self, target):
|
||||||
commits = Git("log", base + "..", format="%s").lines()
|
commits = Git("log", target + "..", format="%s").lines()
|
||||||
|
|
||||||
if not commits:
|
if not commits:
|
||||||
raise GitFlowError("No hay cambios a mergear.")
|
raise GitFlowError("No hay cambios a mergear.")
|
||||||
@@ -79,14 +78,18 @@ class MergeCommand(Command):
|
|||||||
else:
|
else:
|
||||||
self.success("No se detectaron merge conflicts.")
|
self.success("No se detectaron merge conflicts.")
|
||||||
|
|
||||||
def create_pull_request(self, token: str, base: str, branch: str, target: str):
|
def create_pull_request(self, token: str, branch: str, target: str):
|
||||||
changelog = Changelog()
|
changelog = Changelog()
|
||||||
|
title = branch.replace("/", ": ").replace("-", " ")
|
||||||
|
|
||||||
|
if title.startswith("release: "):
|
||||||
|
title = title[title.index(' ', title.index(' ') + 1) + 1:]
|
||||||
|
|
||||||
message = self.get_remote_api(token).create_pull_request(
|
message = self.get_remote_api(token).create_pull_request(
|
||||||
branch,
|
branch,
|
||||||
target,
|
target,
|
||||||
branch.replace("/", ": ").replace("-", " "),
|
branch.replace("/", ": ").replace("-", " "),
|
||||||
changelog.generate_content(base, branch),
|
changelog.generate_content(target, branch),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.success(message)
|
self.success(message)
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ class NewCommand(Command):
|
|||||||
|
|
||||||
def run(self, args: Namespace = Namespace()):
|
def run(self, args: Namespace = Namespace()):
|
||||||
self.ensure_initialized()
|
self.ensure_initialized()
|
||||||
self.ensure_right_branch()
|
branch = self.ensure_right_branch()
|
||||||
|
envs = self.flowconfig["flow.branches"].split(",")
|
||||||
|
|
||||||
|
if branch not in envs:
|
||||||
|
self.warning("La rama actual no corresponde a un entorno configurado.")
|
||||||
|
|
||||||
self.info("Se creará una nueva rama de trabajo sobre la rama actual.")
|
self.info("Se creará una nueva rama de trabajo sobre la rama actual.")
|
||||||
self.info("Debe seleccionar el tipo de cambio a realizar.")
|
self.info("Debe seleccionar el tipo de cambio a realizar.")
|
||||||
@@ -21,6 +25,9 @@ class NewCommand(Command):
|
|||||||
branch_type = self.choice("Tipos de cambio", BRANCH_TYPES)
|
branch_type = self.choice("Tipos de cambio", BRANCH_TYPES)
|
||||||
new_branch = self._get_unique_branch_name(branch_type)
|
new_branch = self._get_unique_branch_name(branch_type)
|
||||||
|
|
||||||
|
if "flow.remote" in self.flowconfig and Git.get_tracking_branch(branch):
|
||||||
|
Git("pull").exec(print="Actualizando rama actual")
|
||||||
|
|
||||||
if self.confirm(f"¿Crear rama '{new_branch}' sobre la rama actual?"):
|
if self.confirm(f"¿Crear rama '{new_branch}' sobre la rama actual?"):
|
||||||
Git("switch", new_branch, create=True).exec(print="Creando nueva rama")
|
Git("switch", new_branch, create=True).exec(print="Creando nueva rama")
|
||||||
|
|
||||||
@@ -37,6 +44,9 @@ class NewCommand(Command):
|
|||||||
persistent=True,
|
persistent=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ticket = self.prompt("[Opcional] Ingrese el ID del ticket (por ejemplo: ABC-123 o #123):")
|
||||||
|
ticket = ticket[1:] if ticket.startswith("#") else ticket
|
||||||
|
keywords = ticket + ' ' + keywords
|
||||||
keywords = filter(lambda k: len(k) > 0, keywords.split(" "))
|
keywords = filter(lambda k: len(k) > 0, keywords.split(" "))
|
||||||
branch = branch_type + "/" + "-".join(keywords)
|
branch = branch_type + "/" + "-".join(keywords)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from argparse import Namespace
|
from argparse import ArgumentParser, Namespace
|
||||||
from git_flow import COMMIT_TYPES, GitFlowError
|
from git_flow import COMMIT_TYPES, GitFlowError
|
||||||
from git_flow.command.base import Command
|
from git_flow.command.base import Command
|
||||||
from git_flow.git import Git
|
from git_flow.git import Git
|
||||||
@@ -11,6 +11,15 @@ class ReleaseCommand(Command):
|
|||||||
def description(self) -> str:
|
def description(self) -> str:
|
||||||
return """Realiza el merge de la rama, o crea el PR para hacerlo si tiene un remoto configurado"""
|
return """Realiza el merge de la rama, o crea el PR para hacerlo si tiene un remoto configurado"""
|
||||||
|
|
||||||
|
def setup_parser(self, parser: ArgumentParser) -> ArgumentParser:
|
||||||
|
parser.add_argument(
|
||||||
|
"--group",
|
||||||
|
nargs="?",
|
||||||
|
help="Agrupar release",
|
||||||
|
)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
def run(self, args: Namespace = Namespace()):
|
def run(self, args: Namespace = Namespace()):
|
||||||
self.ensure_initialized()
|
self.ensure_initialized()
|
||||||
|
|
||||||
@@ -34,34 +43,52 @@ class ReleaseCommand(Command):
|
|||||||
else f"release/{next_env}/{branch}"
|
else f"release/{next_env}/{branch}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if has_remote:
|
base = Git.get_first_fork_point(branch, env)
|
||||||
Git("pull").exec(print="Sincronizando cambios de la rama")
|
commits = Git("log", base + ".." , format="%s").lines()
|
||||||
Git("switch", next_env).exec(print="Cambiando al siguiente entorno")
|
|
||||||
Git("pull").exec(print="Sincronizando cambios del entorno")
|
if not commits:
|
||||||
|
raise GitFlowError("No hay cambios a mergear.")
|
||||||
|
|
||||||
|
print("Cambios a pasar al proximo entorno:")
|
||||||
|
|
||||||
|
for commit in commits:
|
||||||
|
print("- " + commit)
|
||||||
|
|
||||||
|
group = args.group
|
||||||
|
|
||||||
|
if not group:
|
||||||
|
if self.confirm("¿Desea agrupar este release con otra rama?", False):
|
||||||
|
group = self.choice("Grupo release: ", Git.get_branches("release/" + next_env + "/"))
|
||||||
|
else:
|
||||||
|
group = next_env
|
||||||
|
|
||||||
|
if has_remote and Git.get_tracking_branch(group):
|
||||||
|
Git("switch", group).exec(print="Cambiando a la rama objetivo")
|
||||||
|
Git("pull").exec(print="Sincronizando cambios la rama objetivo")
|
||||||
Git("switch", "-").exec(print="Volviendo a la rama original")
|
Git("switch", "-").exec(print="Volviendo a la rama original")
|
||||||
|
|
||||||
base = Git.get_first_fork_point(branch, env)
|
if len(commits) > 1 and self.confirm(
|
||||||
commits = int(Git("rev-list", base + "..", count=True).firstline())
|
f"¿Desea reemplazar los {len(commits)} commits de la rama por uno solo?",
|
||||||
|
False
|
||||||
if commits > 1 and self.confirm(
|
|
||||||
"Desea reemplazar los {commits} commits de la rama por uno solo?"
|
|
||||||
):
|
):
|
||||||
Git("switch", next_branch, base, create=True).exec(
|
self.info("Debe ingresar el mensaje del commit a crear.")
|
||||||
print="Creando rama release en base"
|
|
||||||
)
|
|
||||||
Git("merge", branch, squash=True).exec(
|
|
||||||
print="Squasheando commits en uno solo"
|
|
||||||
)
|
|
||||||
|
|
||||||
commit_type = self.choice("Tipo de commit", COMMIT_TYPES[:-1])
|
commit_type = self.choice("Tipo de commit", COMMIT_TYPES[:-1])
|
||||||
commit_message = self.prompt(
|
commit_message = self.prompt(
|
||||||
"Mensaje (máximo recomendado: 100 caracteres)", persistent=True
|
"Mensaje (máximo recomendado: 100 caracteres)", persistent=True
|
||||||
)
|
)
|
||||||
message = commit_type + ": " + commit_message
|
message = commit_type + ": " + commit_message
|
||||||
|
|
||||||
|
Git("switch", next_branch, base, create=True).exec(
|
||||||
|
print="Creando rama release en base"
|
||||||
|
)
|
||||||
|
Git("merge", branch, squash=True).exec(
|
||||||
|
print="Squasheando commits en uno solo"
|
||||||
|
)
|
||||||
Git("commit", m=message).exec(print="Creando commit único")
|
Git("commit", m=message).exec(print="Creando commit único")
|
||||||
else:
|
else:
|
||||||
Git("switch", next_branch, create=True).exec(print="Creando rama release")
|
Git("switch", next_branch, create=True).exec(print="Creando rama release")
|
||||||
|
|
||||||
Git("rebase", base, next_branch, onto=next_env).exec(
|
Git("rebase", base, next_branch, onto=group).exec(
|
||||||
print="Moviendo cambios hacia el siguiente ambiente"
|
print="Moviendo cambios hacia el siguiente ambiente"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -91,7 +91,7 @@ class TagCommand(Command):
|
|||||||
tag = Git.get_current_tag() or f"v0.0.0-{branch}"
|
tag = Git.get_current_tag() or f"v0.0.0-{branch}"
|
||||||
|
|
||||||
until_dash = tag.index("-") if "-" in tag else None
|
until_dash = tag.index("-") if "-" in tag else None
|
||||||
suffix = tag[until_dash + 1 :] if until_dash is not None else ""
|
suffix = tag[until_dash:] if until_dash is not None else ""
|
||||||
[major, minor, patch] = map(int, tag[1:until_dash].split("."))
|
[major, minor, patch] = map(int, tag[1:until_dash].split("."))
|
||||||
|
|
||||||
if increment == SEMVER_MAJOR:
|
if increment == SEMVER_MAJOR:
|
||||||
|
|||||||
+21
-19
@@ -1,5 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from git_flow import GitFlowError
|
||||||
from git_flow.io import *
|
from git_flow.io import *
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +39,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
|
||||||
@@ -50,8 +51,8 @@ class Git:
|
|||||||
return Git("rev-parse", "HEAD", abbrev_ref=True).firstline()
|
return Git("rev-parse", "HEAD", abbrev_ref=True).firstline()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_branches():
|
def get_branches(prefix: str = ""):
|
||||||
return Git._get_references("heads")
|
return Git._get_references("heads/" + prefix)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def status():
|
def status():
|
||||||
@@ -63,33 +64,31 @@ class Git:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_first_fork_point(branch: str, env: str):
|
def get_first_fork_point(branch: str, env: str):
|
||||||
boundary_commits = list(
|
# Lista de commits alcanzables por el entorno (por ejemplo, dev),
|
||||||
filter(
|
env_commits = Git("rev-list", env + "..." + branch, first_parent=True).lines()
|
||||||
lambda c: c.startswith("-"), # boundary commits
|
|
||||||
Git(
|
|
||||||
"rev-list", env + "..." + branch, topo_order=True, boundary=True
|
|
||||||
).lines(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not boundary_commits:
|
if not env_commits:
|
||||||
raise RuntimeError("No se encontro un commit base para realizar el rebase.")
|
raise RuntimeError("No se encontro un commit base para realizar el rebase.")
|
||||||
|
|
||||||
return boundary_commits[-1].removeprefix("-")
|
return Git("show", env_commits[-1] + "^", patch=False, format="%h").firstline()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_references(kind: str):
|
def _get_references(kind: str):
|
||||||
prefix = "refs/" + kind + "/"
|
prefix = "refs/" + kind
|
||||||
return list(map(
|
return Git("for-each-ref", prefix + "**", format="%(refname:short)").lines()
|
||||||
lambda r: r.removeprefix(prefix),
|
|
||||||
Git("for-each-ref", prefix + "*", format="%(refname)").lines(),
|
|
||||||
))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
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:
|
@staticmethod
|
||||||
|
def get_tracking_branch(branch: str) -> str | None:
|
||||||
|
try:
|
||||||
|
return Git("rev-parse", branch + "@{upstream}", abbrev_ref=True).firstline()
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return 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 +102,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
@@ -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]: "))
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -77,6 +79,9 @@ def main():
|
|||||||
command.error(str(e))
|
command.error(str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
command.error("Ocurrió un error inesperado: " + str(e))
|
command.error("Ocurrió un error inesperado: " + str(e))
|
||||||
|
except KeyboardInterrupt as e:
|
||||||
|
print()
|
||||||
|
command.error("Ejecución abortada")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user