From 9e1c71037374c61b352f910d5e73b0c431c2f968 Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Mon, 3 Nov 2025 21:46:49 -0300 Subject: [PATCH 1/3] refactor: cambio estructura de proyecto siguiendo guidelines de python --- pyproject.toml | 20 ++++++++++++++++++++ pyrightconfig.json | 4 ---- requirements.txt | 5 ----- {lib => src/git_flow}/__init__.py | 0 {lib => src/git_flow}/git.py | 19 +++++++++---------- {lib => src/git_flow}/io.py | 0 git-flow => src/git_flow/main.py | 25 ++++++++++--------------- 7 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 pyproject.toml delete mode 100644 pyrightconfig.json delete mode 100644 requirements.txt rename {lib => src/git_flow}/__init__.py (100%) rename {lib => src/git_flow}/git.py (90%) rename {lib => src/git_flow}/io.py (100%) rename git-flow => src/git_flow/main.py (97%) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e40495d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[build-system] +requires = ["hatchling >= 1.26"] +build-backend = "hatchling.build" + +[project] +name = "git-flow" +description = "Git workflow automation to follow best practices" +version = "v1.0.0" +requires-python = ">= 3.12" +dependencies = [ + "requests" +] +authors = [ + {name = "Alan Facundo Biglieri", email = "abiglieri@renatre.org.ar"}, + {name = "Jonathan Teran Carballo", email = "jteran@renatre.org.ar"}, +] +readme = "README.md" + +[project.scripts] +git-flow = "git_flow.main:main" diff --git a/pyrightconfig.json b/pyrightconfig.json deleted file mode 100644 index e228e52..0000000 --- a/pyrightconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", - "pythonVersion": "3.12" -} diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 80e01dd..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -certifi==2025.10.5 -charset-normalizer==3.4.4 -idna==3.11 -requests==2.32.5 -urllib3==2.5.0 diff --git a/lib/__init__.py b/src/git_flow/__init__.py similarity index 100% rename from lib/__init__.py rename to src/git_flow/__init__.py diff --git a/lib/git.py b/src/git_flow/git.py similarity index 90% rename from lib/git.py rename to src/git_flow/git.py index e96bc68..bd8f23d 100644 --- a/lib/git.py +++ b/src/git_flow/git.py @@ -1,10 +1,6 @@ import subprocess -from lib.io import * - -FLOWCONFIG_FILE = ".flowconfig" -CHANGELOG_FILE = "CHANGELOG.md" -UPDATED_CHANGELOG_MSG = "Updated " + CHANGELOG_FILE +from .io import * class Status: @@ -17,15 +13,18 @@ class Status: self.index = line[1] self.file = line[3:].strip("\n") + class Git: FLOWCONFIG_FILE = ".flowconfig" + CHANGELOG_FILE = "CHANGELOG.md" + UPDATED_CHANGELOG_MSG = "Updated " + CHANGELOG_FILE command: list[str] check_returncode: bool = True @staticmethod def flow_config(*args, **kwargs): - return Git("config", *args, file=FLOWCONFIG_FILE, **kwargs) + return Git("config", *args, file=Git.FLOWCONFIG_FILE, **kwargs) @staticmethod def get_current_branch(): @@ -46,8 +45,8 @@ class Git: lambda r: r.removeprefix(prefix), filter( lambda l: l.startswith(prefix), - Git("for-each-ref", format="%(refname)").lines() - ) + Git("for-each-ref", format="%(refname)").lines(), + ), ) def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool) -> None: @@ -69,7 +68,7 @@ class Git: self.command.append("-" + option) self.command.append(value) else: - self.command.append("--" + option + '=' + value) + self.command.append("--" + option + "=" + value) self.command += args @@ -116,7 +115,7 @@ class Git: for arg in self.command: if arg.startswith("--") and "=" in arg: pos = arg.index("=") - arg = arg[:pos+1] + '"' + arg[pos+1:] + '"' + arg = arg[: pos + 1] + '"' + arg[pos + 1 :] + '"' elif " " in arg: arg = '"' + arg + '"' diff --git a/lib/io.py b/src/git_flow/io.py similarity index 100% rename from lib/io.py rename to src/git_flow/io.py diff --git a/git-flow b/src/git_flow/main.py similarity index 97% rename from git-flow rename to src/git_flow/main.py index ec72f79..6d31afa 100755 --- a/git-flow +++ b/src/git_flow/main.py @@ -6,9 +6,8 @@ import datetime import requests import locale -import lib.git as git -from lib.git import Git -from lib.io import * +from .git import Git +from .io import * REPOSITORY_TOKEN_PATH=".repository-token" @@ -258,7 +257,7 @@ def merge_command(): print("Cambios a mergear:") for commit in commits: - if commit != git.UPDATED_CHANGELOG_MSG: + if commit != Git.UPDATED_CHANGELOG_MSG: print("- " + commit) merge_conflicts = Git("merge", target, ff=False, commit=False).exec() @@ -271,8 +270,8 @@ def merge_command(): return if update_changelog(branch, target): - Git("add", git.CHANGELOG_FILE).exec() - Git("commit", message=git.UPDATED_CHANGELOG_MSG).exec() + Git("add", Git.CHANGELOG_FILE).exec() + Git("commit", message=Git.UPDATED_CHANGELOG_MSG).exec() if remote: Git("push", remote, branch, set_upstream=True).exec() @@ -530,16 +529,16 @@ def get_unique_branch_name(branch_type): def update_changelog(branch: str, target: str): last_commit = Git("show", "HEAD", no_patch=True, format="%s").firstline() - if last_commit == git.UPDATED_CHANGELOG_MSG: + if last_commit == Git.UPDATED_CHANGELOG_MSG: return False else: content = generate_changelog_entry(branch, target) - if os.path.isfile(git.CHANGELOG_FILE): - with open(git.CHANGELOG_FILE, "r") as changelog: + if os.path.isfile(Git.CHANGELOG_FILE): + with open(Git.CHANGELOG_FILE, "r") as changelog: content = content + changelog.read() - with open(git.CHANGELOG_FILE, "w") as changelog: + with open(Git.CHANGELOG_FILE, "w") as changelog: changelog.write(content) @@ -572,7 +571,7 @@ def get_changelog_content_lines(target: str): for commit in commits: message = Git("show", commit, no_patch=True, format="%s").firstline() - if message == git.UPDATED_CHANGELOG_MSG: + if message == Git.UPDATED_CHANGELOG_MSG: continue index = message.index(":") @@ -662,7 +661,3 @@ def get_api_endpoint(service: str, repository: str, path: str): return "https://api.bitbucket.org/2.0/repositories/" + repository + path return "" - - -if __name__ == "__main__": - main() From 96c787b38ce14d69ca6d754371bab12d15f2d5c0 Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Mon, 3 Nov 2025 21:54:03 -0300 Subject: [PATCH 2/3] bugfix: arreglo ejecucion de tag mediante pipeline --- bitbucket-pipelines.yml | 8 ++++---- src/git_flow/main.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 4e00f4d..0106802 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -7,12 +7,12 @@ pipelines: name: "Tag dev" script: - cd $BITBUCKET_CLONE_DIR - - pip install -r requirements.txt - - ./git-flow tag $BEARER + - pip install . + - ./src/git_flow/main.py tag $BEARER 'main': - step: name: "Tag main" script: - cd $BITBUCKET_CLONE_DIR - - pip install -r requirements.txt - - ./git-flow tag $BEARER + - pip install . + - ./src/git_flow/main.py tag $BEARER diff --git a/src/git_flow/main.py b/src/git_flow/main.py index 6d31afa..5283a27 100755 --- a/src/git_flow/main.py +++ b/src/git_flow/main.py @@ -661,3 +661,6 @@ def get_api_endpoint(service: str, repository: str, path: str): return "https://api.bitbucket.org/2.0/repositories/" + repository + path return "" + +if __name__ == "__main__": + main() From b3f057f6226dd6796b6eb9a810f25d0d8f8ce5b5 Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Mon, 3 Nov 2025 21:54:12 -0300 Subject: [PATCH 3/3] Updated CHANGELOG.md --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c406bf..e9f0ad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ +## Lunes, 3 de Noviembre de 2025, 21:54 + +- Autor: [Jonathan Teran Carballo](mailto:jonathan.nerat@gmail.com) +- Rama: `refactor/build-system` + +### Commits + +- **bugfix**: arreglo ejecucion de tag mediante pipeline (96c787b) + - bitbucket-pipelines.yml (M) + - src/git_flow/main.py (M) +- **refactor**: cambio estructura de proyecto siguiendo guidelines de python (9e1c710) + - git-flow (D) + - lib/__init__.py (D) + - lib/git.py (D) + - lib/io.py (D) + - pyproject.toml (A) + - pyrightconfig.json (D) + - requirements.txt (D) + - src/git_flow/__init__.py (A) + - src/git_flow/git.py (A) + - src/git_flow/io.py (A) + - src/git_flow/main.py (A) + +--- + ## Lunes, 3 de Noviembre de 2025, 08:28 - Autor: [Jonathan Teran Carballo](mailto:jonathan.nerat@gmail.com)