Merged in refactor/build-system (pull request #17)

refactor: build system

Approved-by: Jonathan Teran
This commit is contained in:
JonathanGitFlow
2025-11-04 00:54:40 +00:00
committed by jt
9 changed files with 68 additions and 35 deletions
+25
View File
@@ -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)
+4 -4
View File
@@ -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
+20
View File
@@ -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"
-4
View File
@@ -1,4 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
"pythonVersion": "3.12"
}
-5
View File
@@ -1,5 +0,0 @@
certifi==2025.10.5
charset-normalizer==3.4.4
idna==3.11
requests==2.32.5
urllib3==2.5.0
+8 -9
View File
@@ -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
View File
+10 -12
View File
@@ -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(":")
@@ -663,6 +662,5 @@ def get_api_endpoint(service: str, repository: str, path: str):
return ""
if __name__ == "__main__":
main()