From 04f59da0c411613f84a93a7f4a0feeaec7a8ace2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 29 2015 09:23:14 +0000 Subject: Move the method to retrieve the list of tags for a repo into pagure.lib.git This way we can re-use the method for the UI --- diff --git a/pagure/api/project.py b/pagure/api/project.py index a9132d8..5a3ea11 100644 --- a/pagure/api/project.py +++ b/pagure/api/project.py @@ -10,8 +10,6 @@ import flask -import pygit2 - import pagure import pagure.exceptions import pagure.lib @@ -52,13 +50,7 @@ def api_git_tags(repo, username=None): 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.split('refs/tags/')[1] - for tag in repo_obj.listall_references() - if 'refs/tags/' in tag - ] + tags = pagure.lib.git.get_git_tags(repo) jsonout = flask.jsonify({'tags': tags}) return jsonout diff --git a/pagure/lib/git.py b/pagure/lib/git.py index c3b55ab..4ae7cbb 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -907,3 +907,17 @@ def diff_pull_request( 'Fork is empty, there are no commits to request pulling') return (diff_commits, diff) + + +def get_git_tags(project): + """ Returns the list of tags created in the git repositorie of the + specified project. + """ + repopath = pagure.get_repo_path(project) + repo_obj = pygit2.Repository(repopath) + tags = [ + tag.split('refs/tags/')[1] + for tag in repo_obj.listall_references() + if 'refs/tags/' in tag + ] + return tags