Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a17d9c308a | ||
|
|
7121d40ed8 | ||
|
|
41b7a9e602 | ||
|
|
f35dbc126a | ||
|
|
410c5f9356 | ||
|
|
7a24ccb24c | ||
|
|
dc35b635a1 | ||
|
|
5171100c76 | ||
|
|
68cec91506 | ||
|
|
02c081f68f | ||
|
|
a83d693584 | ||
|
|
b51544ddab | ||
|
|
d5a88d6c8d | ||
|
|
e144048429 | ||
|
|
d7f2e569da | ||
|
|
45fe22aea7 | ||
|
|
c194b555c3 | ||
|
|
60c29b6aa5 | ||
|
|
488e9172cb | ||
|
|
c23a890f8e | ||
|
|
dd79b478e2 | ||
|
|
0a143909f5 | ||
|
|
6a44b20556 | ||
|
|
cc816b4244 | ||
|
|
8ff91e9c45 | ||
|
|
865c39e4f2 | ||
|
|
f14c77e144 | ||
|
|
01631cfddd | ||
|
|
ad76e13673 | ||
|
|
d054881f3e | ||
|
|
ab3023acb7 | ||
|
|
aa63815cc6 | ||
|
|
9ef3100871 | ||
|
|
201e2b54a6 | ||
|
|
a5e50b8b16 | ||
|
|
df09810806 | ||
|
|
e44cd98696 | ||
|
|
57c6ff7a4b | ||
|
|
4a39fe95d4 | ||
|
|
24a40c99bc | ||
|
|
bd03cf218b | ||
|
|
e9e7d2ad6e | ||
|
|
82c78c727a | ||
|
|
6d65462dbf | ||
|
|
6df7206eec | ||
|
|
e793feaa1e | ||
|
|
d03cf964e1 | ||
|
|
9d17cf0320 | ||
|
|
8c95835207 | ||
|
|
7c69936360 | ||
|
|
4cf6321b80 | ||
|
|
ae61fa4fa4 | ||
|
|
22ba8f5e5f |
@@ -5,13 +5,13 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Publish-to-PyPI:
|
Bump-Build-Publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 10
|
||||||
|
|
||||||
- name: Configure git
|
- name: Configure git
|
||||||
run: |
|
run: |
|
||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
git config --global user.email "actions@git.jonathanteran.dev"
|
git config --global user.email "actions@git.jonathanteran.dev"
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
- name: "Set up Python"
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version-file: ".python-version"
|
python-version-file: ".python-version"
|
||||||
@@ -27,11 +27,23 @@ jobs:
|
|||||||
- name: Install uv
|
- name: Install uv
|
||||||
uses: astral-sh/setup-uv@v8.3.2
|
uses: astral-sh/setup-uv@v8.3.2
|
||||||
|
|
||||||
- name: Bump version
|
- name: Install git-flow and bump version
|
||||||
|
id: version
|
||||||
run: |
|
run: |
|
||||||
uv run git-flow tag --token="${{ secrets.GITEA_TOKEN }}"
|
pip install git-flow-envs=="${{ vars.GITFLOWENVS_VERSION }}"
|
||||||
|
git-flow tag --token="${{ secrets.GITEA_TOKEN }}"
|
||||||
|
RESULT="$?"
|
||||||
|
|
||||||
|
if [ "$RESULT" -eq 0 ]; then
|
||||||
|
echo "New tag available."
|
||||||
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "No new tag available, skipping next step."
|
||||||
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build and publish
|
- name: Build and publish
|
||||||
|
if: steps.version.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
uv build
|
uv build
|
||||||
uv publish --token="${{ secrets.PYPI_TOKEN }}"
|
uv publish --token="${{ secrets.PYPI_TOKEN }}"
|
||||||
@@ -1,3 +1,31 @@
|
|||||||
|
## v1.23.0 - 2026-09-21
|
||||||
|
|
||||||
|
- **feature**: add fetch depth [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (68cec91)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.22.3 - 2026-09-21
|
||||||
|
|
||||||
|
- **bugfix**: tag locally for workflow to run [[jteran](mailto:jteran@renatre.org.ar)] (24a40c9)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.22.2 - 2026-09-21
|
||||||
|
|
||||||
|
- **bugfix**: fix workflow pipeline [[jteran](mailto:jteran@renatre.org.ar)] (82c78c7)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.22.1 - 2026-09-21
|
||||||
|
|
||||||
|
- **refactor**: update remote tag fetching behaviour so it uses api instead of shallow clone [[jteran](mailto:jteran@renatre.org.ar)] (22ba8f5)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
## v1.22.0 - 2026-09-21
|
## v1.22.0 - 2026-09-21
|
||||||
|
|
||||||
- **feature**: tag from ci fetches commits from remote api [[jteran](mailto:jteran@renatre.org.ar)] (26ab81b)
|
- **feature**: tag from ci fetches commits from remote api [[jteran](mailto:jteran@renatre.org.ar)] (26ab81b)
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
|
from os.path import isfile
|
||||||
|
|
||||||
|
import questionary
|
||||||
|
import rich
|
||||||
|
import rich.panel
|
||||||
|
|
||||||
from git_flow import (
|
from git_flow import (
|
||||||
BRANCH_TYPES,
|
BRANCH_TYPES,
|
||||||
REPOSITORY_TOKEN_FILENAME,
|
COMMIT_TYPES,
|
||||||
FLOWCONFIG_FILENAME,
|
FLOWCONFIG_FILENAME,
|
||||||
FLOWCONFIG_VERSION,
|
FLOWCONFIG_VERSION,
|
||||||
COMMIT_TYPES,
|
REPOSITORY_TOKEN_FILENAME,
|
||||||
GitFlowError,
|
GitFlowError,
|
||||||
)
|
)
|
||||||
from git_flow.git import Git
|
from git_flow.git import Git
|
||||||
|
from git_flow.io import *
|
||||||
from git_flow.remote.base import RemoteAPI
|
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.gitea import GiteaRemoteAPI
|
from git_flow.remote.gitea import GiteaRemoteAPI
|
||||||
|
from git_flow.remote.github import GithubRemoteAPI
|
||||||
from git_flow.remote.gitlab import GitlabRemoteAPI
|
from git_flow.remote.gitlab import GitlabRemoteAPI
|
||||||
from git_flow.io import *
|
|
||||||
from os.path import isfile
|
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
import rich
|
|
||||||
import rich.panel
|
|
||||||
import questionary
|
|
||||||
|
|
||||||
flowconfig = Git.get_config(FLOWCONFIG_FILENAME) if isfile(FLOWCONFIG_FILENAME) else {}
|
flowconfig = Git.get_config(FLOWCONFIG_FILENAME) if isfile(FLOWCONFIG_FILENAME) else {}
|
||||||
environments = (
|
environments = (
|
||||||
@@ -102,7 +102,7 @@ def ensure_clean_worktree(has_remote: bool):
|
|||||||
if not status:
|
if not status:
|
||||||
return
|
return
|
||||||
|
|
||||||
not_empty = any(map(lambda s: s.index != " " or s.worktree != " ", status))
|
not_empty = any(s.index != " " or s.worktree != " " for s in status)
|
||||||
|
|
||||||
if not_empty:
|
if not_empty:
|
||||||
if not has_remote:
|
if not has_remote:
|
||||||
@@ -162,23 +162,23 @@ def get_commit_message(commit_types: list[str] = COMMIT_TYPES) -> str:
|
|||||||
return commit_type + ": " + commit_message
|
return commit_type + ": " + commit_message
|
||||||
|
|
||||||
|
|
||||||
def io_error(message: str, title: Optional[str] = None):
|
def io_error(message: str, title: str | None = None):
|
||||||
_io_status(message, "✖ Error: ", "red", title)
|
_io_status(message, "✖ Error: ", "red", title)
|
||||||
|
|
||||||
|
|
||||||
def io_warning(message: str, title: Optional[str] = None):
|
def io_warning(message: str, title: str | None = None):
|
||||||
_io_status(message, "⚠ Warning: ", "yellow", title)
|
_io_status(message, "⚠ Warning: ", "yellow", title)
|
||||||
|
|
||||||
|
|
||||||
def io_info(message: str, title: Optional[str] = None):
|
def io_info(message: str, title: str | None = None):
|
||||||
_io_status(message, "ℹ Info: ", "blue", title)
|
_io_status(message, "ℹ Info: ", "blue", title)
|
||||||
|
|
||||||
|
|
||||||
def io_success(message: str, title: Optional[str] = None):
|
def io_success(message: str, title: str | None = None):
|
||||||
_io_status(message, "✔ Success: ", "green", title)
|
_io_status(message, "✔ Success: ", "green", title)
|
||||||
|
|
||||||
|
|
||||||
def _io_status(message: str, prefix: str, style: str, title: Optional[str] = None):
|
def _io_status(message: str, prefix: str, style: str, title: str | None = None):
|
||||||
if title:
|
if title:
|
||||||
rich.print(
|
rich.print(
|
||||||
rich.panel.Panel(
|
rich.panel.Panel(
|
||||||
|
|||||||
+43
-44
@@ -1,8 +1,5 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
import typer
|
import typer
|
||||||
|
|
||||||
import git_flow.command.base as base
|
|
||||||
from git_flow import (
|
from git_flow import (
|
||||||
COMMIT_TYPE_INCREMENT,
|
COMMIT_TYPE_INCREMENT,
|
||||||
SEMVER_MAJOR,
|
SEMVER_MAJOR,
|
||||||
@@ -12,17 +9,18 @@ from git_flow import (
|
|||||||
GitFlowError,
|
GitFlowError,
|
||||||
)
|
)
|
||||||
from git_flow.changelog import Changelog
|
from git_flow.changelog import Changelog
|
||||||
|
from git_flow.command import base
|
||||||
from git_flow.git import Git
|
from git_flow.git import Git
|
||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def tag(token: Optional[str] = None):
|
def tag(target: str | None = None, token: str | None = None, update_changelog: bool = False):
|
||||||
"""Crea un nuevo tag para el último merge."""
|
"""Crea un nuevo tag para el último merge."""
|
||||||
base.ensure_initialized()
|
base.ensure_initialized()
|
||||||
|
|
||||||
target = Git.get_current_branch()
|
target = target or Git.get_current_branch()
|
||||||
|
|
||||||
if target not in base.environments:
|
if target not in base.environments:
|
||||||
raise GitFlowError("Solo se pueden taggear commits en ramas principales.")
|
raise GitFlowError("Solo se pueden taggear commits en ramas principales.")
|
||||||
@@ -32,75 +30,78 @@ def tag(token: Optional[str] = None):
|
|||||||
if ci and not token:
|
if ci and not token:
|
||||||
raise GitFlowError("No hay token disponible")
|
raise GitFlowError("No hay token disponible")
|
||||||
|
|
||||||
merge_commit = get_last_merge_commit()
|
merge_commit = Git(
|
||||||
|
"log", first_parent=True, merges=True, max_count=1, format="%H"
|
||||||
|
).firstline()
|
||||||
|
|
||||||
|
if not merge_commit:
|
||||||
|
raise GitFlowError("No hay merges a taggear.")
|
||||||
|
|
||||||
|
# Con varios entornos cada uno versiona por separado (v1.0.0-prod), con uno solo no hace falta
|
||||||
|
suffix = f"-{target}" if len(base.environments) > 1 else ""
|
||||||
|
|
||||||
if ci:
|
if ci:
|
||||||
# Pipeline: no asumimos historial completo, los commits del PR se piden a la API
|
# Commits se obtienen por API del ultimo PR / MR mergeado
|
||||||
commits = base.get_remote_api(token).get_merge_commits(merge_commit)
|
commits = base.get_remote_api(token).get_merge_commits(merge_commit)
|
||||||
commits = [c for c in commits if not c.is_merge]
|
commits = [c for c in commits if not c.is_merge]
|
||||||
|
# Último tag se obtiene por API filtrando por sufijo
|
||||||
|
current_tag = base.get_remote_api(token).get_latest_tag(suffix)
|
||||||
else:
|
else:
|
||||||
branch = Git("show", merge_commit + "^2", patch=False, format="%h").firstline()
|
# Commits se obtienen del último merge, listando hasta el primer forkpoint
|
||||||
|
branch = Git("show", merge_commit + "^2", patch=False, format="%H").firstline()
|
||||||
fork_point = Git.get_first_fork_point(branch, target)
|
fork_point = Git.get_first_fork_point(branch, target)
|
||||||
commits = Git.get_commits(fork_point, branch)
|
commits = Git.get_commits(fork_point, branch)
|
||||||
|
# Último tag se obtiene localmente
|
||||||
|
current_tag = Git.get_current_tag(suffix)
|
||||||
|
|
||||||
next_tag = get_next_tag_from_commits([c.subject for c in commits], target)
|
next_tag = get_next_tag_from_commits(
|
||||||
|
[c.subject for c in commits], suffix, current_tag
|
||||||
|
)
|
||||||
|
|
||||||
if not next_tag:
|
if not next_tag:
|
||||||
base.io_info(
|
base.io_warning(
|
||||||
"Los cambios realizados no implican un salto de versión, se mantiene la anterior."
|
"Los cambios realizados no implican un salto de versión, se mantiene la anterior."
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
changelog = Changelog()
|
raise typer.Exit(code=1)
|
||||||
|
|
||||||
changelog.update(next_tag, commits)
|
if update_changelog:
|
||||||
Git("add", Changelog.FILENAME).exec(print="Agregando nuevo CHANGELOG.md")
|
changelog = Changelog()
|
||||||
Git("commit", message=Changelog.COMMIT_MESSAGE).exec(print="Creando commit")
|
changelog.update(next_tag, commits)
|
||||||
tag_commit = Git("show", "HEAD", patch=False, format="%h").firstline()
|
Git("add", Changelog.FILENAME).exec(print="Agregando nuevo CHANGELOG.md")
|
||||||
|
Git("commit", message=Changelog.COMMIT_MESSAGE).exec(print="Creando commit")
|
||||||
|
|
||||||
|
if ci:
|
||||||
|
Git("push").exec()
|
||||||
|
|
||||||
|
tag_commit = Git("show", "HEAD", patch=False, format="%H").firstline()
|
||||||
|
|
||||||
if ci:
|
if ci:
|
||||||
Git("push").exec(print="Subiendo commit al remoto para taggearlo")
|
|
||||||
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
|
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
|
||||||
|
|
||||||
Git("tag", next_tag, tag_commit).exec(print="Creando tag localmente")
|
Git("tag", next_tag, tag_commit).exec(print="Creando tag localmente")
|
||||||
|
|
||||||
|
|
||||||
def get_token_and_ci(token: Optional[str]):
|
def get_token_and_ci(token: str | None):
|
||||||
if token:
|
if token:
|
||||||
return (token, True)
|
return (token, True)
|
||||||
else:
|
else:
|
||||||
return (base.ensure_repository_token(), False)
|
return (base.ensure_repository_token(), False)
|
||||||
|
|
||||||
|
|
||||||
def get_last_merge_commit():
|
def get_next_tag_from_commits(
|
||||||
commit = Git(
|
commits: list[str], suffix: str, current_tag: str | None
|
||||||
"log", first_parent=True, merges=True, max_count=1, format="%H"
|
) -> str | None:
|
||||||
).firstline()
|
|
||||||
|
|
||||||
if not commit:
|
|
||||||
raise GitFlowError("No hay merges a taggear.")
|
|
||||||
|
|
||||||
return commit
|
|
||||||
|
|
||||||
|
|
||||||
def check_not_tagged(commit: str):
|
|
||||||
tag = Git("describe", commit, tags=True, exact_match=True).firstline(check=False)
|
|
||||||
|
|
||||||
if tag:
|
|
||||||
raise GitFlowError("El commit a taggear ya tiene tag: " + tag)
|
|
||||||
|
|
||||||
|
|
||||||
def get_next_tag_from_commits(commits: list[str], branch: str) -> str | None:
|
|
||||||
increment = SEMVER_SKIP
|
increment = SEMVER_SKIP
|
||||||
for commit in commits:
|
for commit in commits:
|
||||||
commit_type = commit.partition(":")[0]
|
commit_type = commit.partition(":")[0]
|
||||||
increment = max(increment, COMMIT_TYPE_INCREMENT.get(commit_type, SEMVER_SKIP))
|
increment = max(increment, COMMIT_TYPE_INCREMENT.get(commit_type, SEMVER_SKIP))
|
||||||
|
|
||||||
tag = Git.get_current_tag() or f"v0.0.0-{branch}"
|
if increment == SEMVER_SKIP:
|
||||||
|
return None
|
||||||
|
|
||||||
until_dash = tag.index("-") if "-" in tag else None
|
version = (current_tag or "v0.0.0" + suffix).removeprefix("v").removesuffix(suffix)
|
||||||
suffix = tag[until_dash:] if until_dash is not None else ""
|
[major, minor, patch] = map(int, version.split("."))
|
||||||
[major, minor, patch] = map(int, tag[1:until_dash].split("."))
|
|
||||||
|
|
||||||
if increment == SEMVER_MAJOR:
|
if increment == SEMVER_MAJOR:
|
||||||
major += 1
|
major += 1
|
||||||
@@ -111,7 +112,5 @@ def get_next_tag_from_commits(commits: list[str], branch: str) -> str | None:
|
|||||||
patch = 0
|
patch = 0
|
||||||
elif increment == SEMVER_PATCH:
|
elif increment == SEMVER_PATCH:
|
||||||
patch += 1
|
patch += 1
|
||||||
elif increment == SEMVER_SKIP:
|
|
||||||
suffix = "-r" + Git("rev-list", "HEAD", count=True).firstline()
|
|
||||||
|
|
||||||
return None if increment == SEMVER_SKIP else f"v{major}.{minor}.{patch}{suffix}"
|
return f"v{major}.{minor}.{patch}{suffix}"
|
||||||
|
|||||||
+9
-2
@@ -63,8 +63,15 @@ class Git:
|
|||||||
return list(map(Git.Status, Git("status", porcelain=True).lines(False)))
|
return list(map(Git.Status, Git("status", porcelain=True).lines(False)))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_current_tag():
|
def get_current_tag(suffix: str = ""):
|
||||||
return Git("describe", abbrev="0", tags=True).firstline(check=False, print="Obteniendo tag actual")
|
"""Último tag SemVer alcanzable desde HEAD, con el sufijo exacto indicado."""
|
||||||
|
return Git(
|
||||||
|
"describe",
|
||||||
|
abbrev="0",
|
||||||
|
tags=True,
|
||||||
|
match="v[0-9]*.[0-9]*.[0-9]*" + suffix,
|
||||||
|
exclude=None if suffix else "*-*",
|
||||||
|
).firstline(check=False, print="Obteniendo tag actual")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_first_fork_point(branch: str, env: str):
|
def get_first_fork_point(branch: str, env: str):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
import giturlparse
|
import giturlparse
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@@ -72,6 +74,12 @@ class RemoteAPI(ABC):
|
|||||||
viejo), sin depender del historial local."""
|
viejo), sin depender del historial local."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def list_tags(self, suffix: str = "") -> list[str]:
|
||||||
|
"""Nombres de los tags del repositorio, sin orden garantizado. `suffix` es solo una pista
|
||||||
|
para que la API filtre; el filtrado definitivo se hace en `get_latest_tag`."""
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_endpoint(self, resource: str) -> str:
|
def get_endpoint(self, resource: str) -> str:
|
||||||
pass
|
pass
|
||||||
@@ -91,13 +99,33 @@ class RemoteAPI(ABC):
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_all_pages(self, url: str, page_size: int = 50) -> list:
|
def get_latest_tag(self, suffix: str = "") -> str | None:
|
||||||
|
"""Tag SemVer más alto (vX.Y.Z + suffix exacto), o None si no hay ninguno."""
|
||||||
|
pattern = re.compile(rf"^v(\d+)\.(\d+)\.(\d+){re.escape(suffix)}$")
|
||||||
|
versions = {}
|
||||||
|
|
||||||
|
for name in self.list_tags(suffix):
|
||||||
|
match = pattern.match(name)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
versions[tuple(map(int, match.groups()))] = name
|
||||||
|
|
||||||
|
return versions[max(versions)] if versions else None
|
||||||
|
|
||||||
|
def get_all_pages(
|
||||||
|
self,
|
||||||
|
url: str,
|
||||||
|
page_size: int = 50,
|
||||||
|
params: dict | None = None,
|
||||||
|
size_param: str = "per_page",
|
||||||
|
) -> list:
|
||||||
"""Recorre un endpoint paginado por número de página (page / per_page)."""
|
"""Recorre un endpoint paginado por número de página (page / per_page)."""
|
||||||
items: list = []
|
items: list = []
|
||||||
page = 1
|
page = 1
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
batch = self.get_json(url, {"page": page, "per_page": page_size}).json()
|
query = {**(params or {}), "page": page, size_param: page_size}
|
||||||
|
batch = self.get_json(url, query).json()
|
||||||
items += batch
|
items += batch
|
||||||
|
|
||||||
if len(batch) < page_size:
|
if len(batch) < page_size:
|
||||||
|
|||||||
@@ -77,5 +77,21 @@ class BitbucketRemoteAPI(RemoteAPI):
|
|||||||
|
|
||||||
return commits
|
return commits
|
||||||
|
|
||||||
|
def list_tags(self, suffix: str = "") -> list[str]:
|
||||||
|
names: list[str] = []
|
||||||
|
url: str | None = self.get_endpoint("refs/tags")
|
||||||
|
params: dict[str, int|str] | None = {"pagelen": 100}
|
||||||
|
|
||||||
|
if suffix:
|
||||||
|
params["q"] = f'name ~ "{suffix}"'
|
||||||
|
|
||||||
|
while url:
|
||||||
|
page = self.get_json(url, params).json()
|
||||||
|
names += [t["name"] for t in page["values"]]
|
||||||
|
url = page.get("next")
|
||||||
|
params = None # "next" ya incluye la query
|
||||||
|
|
||||||
|
return names
|
||||||
|
|
||||||
def get_endpoint(self, resource: str) -> str:
|
def get_endpoint(self, resource: str) -> str:
|
||||||
return f"{BitbucketRemoteAPI.API_ENDPOINT}/{self.repository}/{resource}"
|
return f"{BitbucketRemoteAPI.API_ENDPOINT}/{self.repository}/{resource}"
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ class GiteaRemoteAPI(RemoteAPI):
|
|||||||
for c in reversed(items)
|
for c in reversed(items)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def list_tags(self, suffix: str = "") -> list[str]:
|
||||||
|
tags = self.get_all_pages(self.get_endpoint("/tags"), 50, size_param="limit")
|
||||||
|
|
||||||
|
return [t["name"] for t in tags]
|
||||||
|
|
||||||
def get_endpoint(self, resource: str) -> str:
|
def get_endpoint(self, resource: str) -> str:
|
||||||
return f"{self.base_url}/api/v1/repos/{self.repository}{resource}"
|
return f"{self.base_url}/api/v1/repos/{self.repository}{resource}"
|
||||||
|
|
||||||
|
|||||||
@@ -63,5 +63,8 @@ class GithubRemoteAPI(RemoteAPI):
|
|||||||
for c in reversed(items)
|
for c in reversed(items)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def list_tags(self, suffix: str = "") -> list[str]:
|
||||||
|
return [t["name"] for t in self.get_all_pages(self.get_endpoint("/tags"), 100)]
|
||||||
|
|
||||||
def get_endpoint(self, resource: str) -> str:
|
def get_endpoint(self, resource: str) -> str:
|
||||||
return f"{GithubRemoteAPI.API_ENDPOINT}/{self.repository}{resource}"
|
return f"{GithubRemoteAPI.API_ENDPOINT}/{self.repository}{resource}"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class GitlabRemoteAPI(RemoteAPI):
|
|||||||
if response.ok:
|
if response.ok:
|
||||||
return "Tag creado exitosamente: " + tag
|
return "Tag creado exitosamente: " + tag
|
||||||
else:
|
else:
|
||||||
raise GitFlowError("Ocurrió un error al crear el tag para repositorio " + quote(self.repository, safe="") + ": " + response.text)
|
raise GitFlowError("Ocurrió un error al crear el tag: " + response.text)
|
||||||
|
|
||||||
def get_merge_commits(self, merge_commit: str) -> list[Commit]:
|
def get_merge_commits(self, merge_commit: str) -> list[Commit]:
|
||||||
mrs = self.get_json(
|
mrs = self.get_json(
|
||||||
@@ -70,6 +70,13 @@ class GitlabRemoteAPI(RemoteAPI):
|
|||||||
for c in items
|
for c in items
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def list_tags(self, suffix: str = "") -> list[str]:
|
||||||
|
# "search" soporta "$" para anclar al final del nombre
|
||||||
|
params = {"search": suffix + "$"} if suffix else None
|
||||||
|
tags = self.get_all_pages(self.get_endpoint("/repository/tags"), 100, params)
|
||||||
|
|
||||||
|
return [t["name"] for t in tags]
|
||||||
|
|
||||||
def get_endpoint(self, resource: str) -> str:
|
def get_endpoint(self, resource: str) -> str:
|
||||||
project_id = quote(self.repository, safe="")
|
project_id = quote(self.repository, safe="")
|
||||||
return f"{self.base_url}/api/v4/projects/{project_id}{resource}"
|
return f"{self.base_url}/api/v4/projects/{project_id}{resource}"
|
||||||
|
|||||||
Reference in New Issue
Block a user