Merged in refactor/build-system (pull request #17)
refactor: build system Approved-by: Jonathan Teran
This commit is contained in:
@@ -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
|
## Lunes, 3 de Noviembre de 2025, 08:28
|
||||||
|
|
||||||
- Autor: [Jonathan Teran Carballo](mailto:jonathan.nerat@gmail.com)
|
- Autor: [Jonathan Teran Carballo](mailto:jonathan.nerat@gmail.com)
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ pipelines:
|
|||||||
name: "Tag dev"
|
name: "Tag dev"
|
||||||
script:
|
script:
|
||||||
- cd $BITBUCKET_CLONE_DIR
|
- cd $BITBUCKET_CLONE_DIR
|
||||||
- pip install -r requirements.txt
|
- pip install .
|
||||||
- ./git-flow tag $BEARER
|
- ./src/git_flow/main.py tag $BEARER
|
||||||
'main':
|
'main':
|
||||||
- step:
|
- step:
|
||||||
name: "Tag main"
|
name: "Tag main"
|
||||||
script:
|
script:
|
||||||
- cd $BITBUCKET_CLONE_DIR
|
- cd $BITBUCKET_CLONE_DIR
|
||||||
- pip install -r requirements.txt
|
- pip install .
|
||||||
- ./git-flow tag $BEARER
|
- ./src/git_flow/main.py tag $BEARER
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
|
|
||||||
"pythonVersion": "3.12"
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
certifi==2025.10.5
|
|
||||||
charset-normalizer==3.4.4
|
|
||||||
idna==3.11
|
|
||||||
requests==2.32.5
|
|
||||||
urllib3==2.5.0
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from lib.io import *
|
from .io import *
|
||||||
|
|
||||||
FLOWCONFIG_FILE = ".flowconfig"
|
|
||||||
CHANGELOG_FILE = "CHANGELOG.md"
|
|
||||||
UPDATED_CHANGELOG_MSG = "Updated " + CHANGELOG_FILE
|
|
||||||
|
|
||||||
|
|
||||||
class Status:
|
class Status:
|
||||||
@@ -17,15 +13,18 @@ class Status:
|
|||||||
self.index = line[1]
|
self.index = line[1]
|
||||||
self.file = line[3:].strip("\n")
|
self.file = line[3:].strip("\n")
|
||||||
|
|
||||||
|
|
||||||
class Git:
|
class Git:
|
||||||
FLOWCONFIG_FILE = ".flowconfig"
|
FLOWCONFIG_FILE = ".flowconfig"
|
||||||
|
CHANGELOG_FILE = "CHANGELOG.md"
|
||||||
|
UPDATED_CHANGELOG_MSG = "Updated " + CHANGELOG_FILE
|
||||||
|
|
||||||
command: list[str]
|
command: list[str]
|
||||||
check_returncode: bool = True
|
check_returncode: bool = True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def flow_config(*args, **kwargs):
|
def flow_config(*args, **kwargs):
|
||||||
return Git("config", *args, file=FLOWCONFIG_FILE, **kwargs)
|
return Git("config", *args, file=Git.FLOWCONFIG_FILE, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_current_branch():
|
def get_current_branch():
|
||||||
@@ -46,8 +45,8 @@ class Git:
|
|||||||
lambda r: r.removeprefix(prefix),
|
lambda r: r.removeprefix(prefix),
|
||||||
filter(
|
filter(
|
||||||
lambda l: l.startswith(prefix),
|
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:
|
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("-" + option)
|
||||||
self.command.append(value)
|
self.command.append(value)
|
||||||
else:
|
else:
|
||||||
self.command.append("--" + option + '=' + value)
|
self.command.append("--" + option + "=" + value)
|
||||||
|
|
||||||
self.command += args
|
self.command += args
|
||||||
|
|
||||||
@@ -6,9 +6,8 @@ import datetime
|
|||||||
import requests
|
import requests
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
import lib.git as git
|
from .git import Git
|
||||||
from lib.git import Git
|
from .io import *
|
||||||
from lib.io import *
|
|
||||||
|
|
||||||
|
|
||||||
REPOSITORY_TOKEN_PATH=".repository-token"
|
REPOSITORY_TOKEN_PATH=".repository-token"
|
||||||
@@ -258,7 +257,7 @@ def merge_command():
|
|||||||
print("Cambios a mergear:")
|
print("Cambios a mergear:")
|
||||||
|
|
||||||
for commit in commits:
|
for commit in commits:
|
||||||
if commit != git.UPDATED_CHANGELOG_MSG:
|
if commit != Git.UPDATED_CHANGELOG_MSG:
|
||||||
print("- " + commit)
|
print("- " + commit)
|
||||||
|
|
||||||
merge_conflicts = Git("merge", target, ff=False, commit=False).exec()
|
merge_conflicts = Git("merge", target, ff=False, commit=False).exec()
|
||||||
@@ -271,8 +270,8 @@ def merge_command():
|
|||||||
return
|
return
|
||||||
|
|
||||||
if update_changelog(branch, target):
|
if update_changelog(branch, target):
|
||||||
Git("add", git.CHANGELOG_FILE).exec()
|
Git("add", Git.CHANGELOG_FILE).exec()
|
||||||
Git("commit", message=git.UPDATED_CHANGELOG_MSG).exec()
|
Git("commit", message=Git.UPDATED_CHANGELOG_MSG).exec()
|
||||||
|
|
||||||
if remote:
|
if remote:
|
||||||
Git("push", remote, branch, set_upstream=True).exec()
|
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):
|
def update_changelog(branch: str, target: str):
|
||||||
last_commit = Git("show", "HEAD", no_patch=True, format="%s").firstline()
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
content = generate_changelog_entry(branch, target)
|
content = generate_changelog_entry(branch, target)
|
||||||
|
|
||||||
if os.path.isfile(git.CHANGELOG_FILE):
|
if os.path.isfile(Git.CHANGELOG_FILE):
|
||||||
with open(git.CHANGELOG_FILE, "r") as changelog:
|
with open(Git.CHANGELOG_FILE, "r") as changelog:
|
||||||
content = content + changelog.read()
|
content = content + changelog.read()
|
||||||
|
|
||||||
with open(git.CHANGELOG_FILE, "w") as changelog:
|
with open(Git.CHANGELOG_FILE, "w") as changelog:
|
||||||
changelog.write(content)
|
changelog.write(content)
|
||||||
|
|
||||||
|
|
||||||
@@ -572,7 +571,7 @@ def get_changelog_content_lines(target: str):
|
|||||||
for commit in commits:
|
for commit in commits:
|
||||||
message = Git("show", commit, no_patch=True, format="%s").firstline()
|
message = Git("show", commit, no_patch=True, format="%s").firstline()
|
||||||
|
|
||||||
if message == git.UPDATED_CHANGELOG_MSG:
|
if message == Git.UPDATED_CHANGELOG_MSG:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
index = message.index(":")
|
index = message.index(":")
|
||||||
@@ -663,6 +662,5 @@ def get_api_endpoint(service: str, repository: str, path: str):
|
|||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user