diff --git a/api/repo_api.py b/api/repo_api.py index e08f8f0..bba3c80 100644 --- a/api/repo_api.py +++ b/api/repo_api.py @@ -2520,8 +2520,8 @@ def git_get_branches(repo): "branches": branches } -@app.route("/ogrepository/v1/git/repositories//branches/", methods=['POST']) -def git_create_branch(repo, branch): +@app.route("/ogrepository/v1/git/repositories//branches", methods=['POST']) +def git_create_branch(repo): """Create a given branch in a given repository Args: @@ -2551,6 +2551,12 @@ def git_create_branch(repo, branch): 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 not "name" in data: + journal.send(f"Can't create branch. Name parameter missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG") + return jsonify({"error" : "name parameter missing"}), 400 + + branch = data["name"] + if branch in git_repo.branches: 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 @@ -2637,8 +2643,8 @@ def git_list_tags(repo): } -@app.route("/ogrepository/v1/git/repositories//tags/", methods=['POST']) -def git_create_tag(repo, tag): +@app.route("/ogrepository/v1/git/repositories//tags", methods=['POST']) +def git_create_tag(repo): """Create a given tag in a given repository Args: @@ -2668,7 +2674,13 @@ def git_create_tag(repo, tag): 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 not "name" in data: + journal.send(f"Can't create tag. Name parameter missing", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG") + return jsonify({"error" : "name parameter missing"}), 400 + commit_message = "" + tag = data["name"] + if "message" in data: commit_message = data["message"] diff --git a/api/swagger.yaml b/api/swagger.yaml index f79b0e6..a619772 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -2100,7 +2100,6 @@ paths: exception: type: string example: "(Exception description)" - /ogrepository/v1/git/repositories/{repository}/tags/{tag}: post: summary: "Crear tag" description: | @@ -2113,20 +2112,20 @@ paths: required: true type: string description: "Nombre de repositorio" - - name: tag - in: path - required: true - type: string - description: "Tag del repositorio" - name: JSON in: body required: true description: | + * **name** - Nombre del tag * **commit** - Commit al que apunta el tag nuevo. Puede ser un nombre de otra rama/tag. * **message** - Mensaje descriptivo para el tag. Opcional, si no se especifica se asume una cadena vacĂ­a. schema: type: object properties: + name: + type: string + example: v1.0 + required: True commit: type: string example: HEAD @@ -2261,8 +2260,6 @@ paths: error: type: string example: "Branch already exists" - - /ogrepository/v1/git/repositories/{repository}/branches/{branch}: post: summary: "Crear branch" description: | @@ -2275,11 +2272,6 @@ paths: required: true type: string description: "Nombre de repositorio" - - name: branch - in: path - required: true - type: string - description: "Branch del repositorio" - name: JSON in: body required: true @@ -2288,9 +2280,14 @@ paths: schema: type: object properties: + name: + type: string + example: devel + required: True commit: type: string example: HEAD + required: True responses: "201": description: "Rama creada"