Fix error logging, wrong constant
parent
4e645bd619
commit
9bbd9de285
|
@ -2250,7 +2250,7 @@ def git_list_repositories():
|
|||
journal.send("Running endpoint 'Obtener Información de todos los repositorios Git'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
if not os.path.isdir(REPOSITORIES_BASE_PATH):
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error": "Repository storage not found, git functionality may not be installed."}), 500
|
||||
|
||||
repos = []
|
||||
|
@ -2356,7 +2356,7 @@ def git_compact_repository(repo):
|
|||
journal.send("Running endpoint 'Compactar repositorio Git'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
if not os.path.isdir(REPOSITORIES_BASE_PATH):
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error": "Repository storage not found, git functionality may not be installed."}), 500
|
||||
|
||||
|
||||
|
@ -2385,7 +2385,7 @@ def git_get_branches(repo):
|
|||
"""
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't list repositories. 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)
|
||||
|
@ -2417,7 +2417,7 @@ def git_create_branch(repo, branch):
|
|||
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
journal.send(f"Can't create branch. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create branch. 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)
|
||||
|
@ -2425,20 +2425,20 @@ def git_create_branch(repo, branch):
|
|||
|
||||
data = request.json
|
||||
if data is None:
|
||||
journal.send(f"Can't create branch. JSON post data missing", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create branch. JSON post data missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error" : "Parameters missing"}), 400
|
||||
|
||||
if not "commit" in data:
|
||||
journal.send(f"Can't create branch. Commit parameter missing", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create branch. Commit parameter missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error" : "commit parameter missing"}), 400
|
||||
|
||||
if branch in git_repo.branches:
|
||||
journal.send(f"Can't create branch. Already found in repository {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create branch. Already found in repository {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error": "Branch already exists"}), 409
|
||||
|
||||
git_repo.create_tag(branch, ref = data["commit"])
|
||||
|
||||
journal.send(f"Branch {branch} created in repo {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Branch {branch} created in repo {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"status": "created"}), 201
|
||||
|
||||
@app.route("/ogrepository/v1/git/repositories/<string:repo>/branches/<string:branch>", methods=['DELETE'])
|
||||
|
@ -2456,7 +2456,7 @@ def git_delete_branch(repo, branch):
|
|||
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
journal.send(f"Can't delete branch. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't delete branch. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return {"error": "Repository not found"}, 404
|
||||
|
||||
git_repo = git.Repo(repo_path)
|
||||
|
@ -2464,11 +2464,11 @@ def git_delete_branch(repo, branch):
|
|||
|
||||
|
||||
if not branch in git_repo.branches:
|
||||
journal.send(f"Can't delete branch. Not found in repository {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't delete branch. Not found in repository {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error": "Branch not found"}), 404
|
||||
|
||||
git_repo.delete_head(branch)
|
||||
journal.send(f"Branch {branch} deleted in repo {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Branch {branch} deleted in repo {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
return jsonify({"status": "deleted"}), 200
|
||||
|
||||
|
@ -2488,7 +2488,7 @@ def git_list_tags(repo):
|
|||
"""
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't list repositories. 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)
|
||||
|
@ -2521,7 +2521,7 @@ def git_create_tag(repo, tag):
|
|||
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, 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_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
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)
|
||||
|
@ -2529,20 +2529,20 @@ def git_create_tag(repo, tag):
|
|||
|
||||
data = request.json
|
||||
if data is None:
|
||||
journal.send(f"Can't create tag. JSON post data missing", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create tag. JSON post data missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error" : "Parameters missing"}), 400
|
||||
|
||||
if not "commit" in data:
|
||||
journal.send(f"Can't create tag. Commit parameter missing", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create tag. Commit parameter missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error" : "commit parameter missing"}), 400
|
||||
|
||||
if tag in git_repo.tags:
|
||||
journal.send(f"Can't create tag. Already found in repository {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
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
|
||||
|
||||
git_repo.create_tag(tag, ref = data["commit"])
|
||||
|
||||
journal.send(f"Tag {tag} created in repo {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Tag {tag} created in repo {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"status": "created"}), 200
|
||||
|
||||
@app.route("/ogrepository/v1/git/repositories/<string:repo>/tags/<string:tag>", methods=['DELETE'])
|
||||
|
@ -2560,7 +2560,7 @@ def git_delete_tag(repo, tag):
|
|||
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
journal.send(f"Can't delete tag. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't delete tag. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return {"error": "Repository not found"}, 404
|
||||
|
||||
git_repo = git.Repo(repo_path)
|
||||
|
@ -2568,11 +2568,11 @@ def git_delete_tag(repo, tag):
|
|||
|
||||
|
||||
if not tag in git_repo.tags:
|
||||
journal.send(f"Can't delete tag. Not found in repository {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't delete tag. Not found in repository {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error": "Tag not found"}), 404
|
||||
|
||||
git_repo.delete_head(tag)
|
||||
journal.send(f"Tag {tag} deleted in repo {repo}", PRIORITY=journal.LOG_ERROR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Tag {tag} deleted in repo {repo}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
return jsonify({"status": "deleted"}), 200
|
||||
|
||||
|
|
Loading…
Reference in New Issue