diff --git a/pagure/api/project.py b/pagure/api/project.py new file mode 100644 index 0000000..0d079bb --- /dev/null +++ b/pagure/api/project.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +""" + (c) 2015 - Copyright Red Hat Inc + + Authors: + Pierre-Yves Chibon + +""" + +import flask + +import pygit2 + +import pagure +import pagure.exceptions +import pagure.lib +from pagure import APP, SESSION, is_repo_admin, authenticated +from pagure.api import ( + API, api_method, api_login_required, api_login_optional, APIERROR +) + + +@API.route('//git/tags') +@API.route('/fork///git/tags') +@api_method +def api_git_tags(repo, username=None): + """ + Project git tags + ---------------- + Returns the list of tags made on the git repo of the project. + + :: + + /api/0//git/tags + /api/0/fork///git/tags + + Accepts GET queries only. + + Sample response: + + :: + + { + "tags": [], + } + + """ + repo = pagure.lib.get_project(SESSION, repo, user=username) + output = {} + + if repo is None: + raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOPROJECT) + + repopath = pagure.get_repo_path(repo) + repo_obj = pygit2.Repository(repopath) + tags = [ tag for tag in repo_obj.listall_references()] + + jsonout = flask.jsonify({'tags': tags}) + return jsonout