Compare commits

...

3 Commits

Author SHA1 Message Date
Luis Gerardo Romero Garcia 8bd472fd6b Merge pull request 'refs #2789 Adds necessary ogboot commands to sudoers' (#46) from sudoers-ogboot into main
ogrepository/pipeline/head This commit looks good Details
Reviewed-on: #46
2025-09-22 13:12:34 +02:00
Natalia Serrano c9c8952741 Merge pull request 'refs #2830 create tags via a query to the forgejo API' (#45) from forgejo-tags into main
ogrepository/pipeline/head This commit looks good Details
ogrepository/pipeline/tag This commit looks good Details
Reviewed-on: #45
2025-09-18 13:53:09 +02:00
Natalia Serrano e0b9a036ca refs #2830 create tags via a query to the forgejo API 2025-09-18 13:52:34 +02:00
2 changed files with 30 additions and 26 deletions

View File

@ -1,11 +1,22 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.10.3] - 2025-09-18
### Changed
- Create tags via a query to the forgejo API
## [0.10.2] - 2025-09-01
## Fixed
### Fixed
- Corregida la logica en el endpoint create torrent sum
- Mejoras en los mensajes de logs
- Corregida la logica en el endpoint create torrent sum
- Mejoras en los mensajes de logs
- Mejoras en la validación de los archivos info e info.checked
## [0.10.1] - 2025-08-25
@ -21,13 +32,13 @@
- OgGit functionality (#2371, #2363, #2363, #2317)
### Removed
### Removed
- Removed unused BitTorrent-related packages and logic
## [0.9.0] - 2025-06-25
## Added
### Added
- Changed old tools for tools non dependant of Pyhton2 in repo
- mktorrent to handle creation of torrent files

View File

@ -2301,6 +2301,12 @@ def git_forgejo_create_repo(repo):
"private" : False
})
def git_forgejo_create_tag(repo,tag,msg,target):
return git_forgejo_post_command(f"/api/v1/repos/oggit/{repo}/tags", {
"message": msg,
"tag_name": tag,
"target": target
})
def git_forgejo_add_sshkey(pubkey, description = ""):
return git_forgejo_post_command("/api/v1/user/keys",
@ -2818,14 +2824,6 @@ def git_create_tag(repo):
- 409: A JSON object with an "error" key containing the message "Tag already exists"
"""
repo_path = os.path.join(REPOSITORIES_BASE_PATH, OGGIT_USER, repo + ".git")
if not os.path.isdir(repo_path):
journal.send(f"Can't create tag. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"error": "Repository not found"}), 404
git_repo = git.Repo(repo_path)
git_repo.git.config('--global', '--add', 'safe.directory', repo_path)
data = request.json
if data is None:
journal.send(f"Can't create tag. JSON post data missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
@ -2845,21 +2843,16 @@ def git_create_tag(repo):
if "message" in data:
commit_message = data["message"]
if tag in git_repo.tags:
journal.send(f"Can't create tag. Already found in repository {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"error": "Tag already exists"}), 409
try:
git_repo.create_tag(tag, ref = data["commit"], message = commit_message)
except git.exc.GitCommandError as ge:
if "not a valid tag name" in ge.stderr:
journal.send(f"Tag name {tag} is invalid", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"error" : "Invalid tag name"}), 400
else:
journal.send(f"Git error {ge}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"error" : "Error when performing git command"}), 500
res = git_forgejo_create_tag(repo,tag,commit_message,data["commit"])
except Exception as e:
journal.send (str(e), PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"error" : f"git_forgejo_create_tag failed: {e}"}), 500
if 200 != res[0]:
j = json.loads(res[1])
journal.send (j["message"], PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"error" : j["message"]}), 409
journal.send(f"Tag {tag} created in repo {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
return jsonify({"status": "created"}), 200