feature: tag from ci fetches commits from remote api

This commit is contained in:
Jonathan Teran Carballo
2026-09-20 21:05:21 -03:00
parent 889109bf77
commit 26ab81b175
8 changed files with 195 additions and 31 deletions
+30
View File
@@ -1,5 +1,6 @@
import requests
from git_flow import GitFlowError
from git_flow.git import Commit
from git_flow.remote.base import RemoteAPI
@@ -44,6 +45,35 @@ class GiteaRemoteAPI(RemoteAPI):
else:
raise GitFlowError("Ocurrió un error al crear el tag: " + response.text)
def get_merge_commits(self, merge_commit: str) -> list[Commit]:
pr = self.get_json(self.get_endpoint(f"/commits/{merge_commit}/pull")).json()
url = self.get_endpoint(f"/pulls/{pr['number']}/commits")
items: list = []
page = 1
# Gitea pagina con page / limit
while True:
batch = self.get_json(
url, {"page": page, "limit": 50, "files": "false", "verification": "false"}
).json()
items += batch
if len(batch) < 50:
break
page += 1
# La API los devuelve del más viejo al más nuevo
return [
Commit(
c["sha"][:7],
c["commit"]["message"].splitlines()[0],
c["commit"]["author"]["email"],
len(c["parents"]) > 1,
)
for c in reversed(items)
]
def get_endpoint(self, resource: str) -> str:
return f"{self.base_url}/api/v1/repos/{self.repository}{resource}"