diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 1569659..50c89b1 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -32,6 +32,13 @@ from pagure.lib.repo import PagureRepo # pylint: disable=R0913,E1101,R0914 +def get_pygit2_version(): + ''' Return pygit2 version as a tuple of integers. + This is needed for correct version comparison. + ''' + return tuple([int(i) for i in pygit2.__version__.split('.')]) + + def commit_to_patch(repo_obj, commits): ''' For a given commit (PyGit2 commit object) of a specified git repo, returns a string representation of the changes the commit did in a diff --git a/pagure/lib/repo.py b/pagure/lib/repo.py index c8a0661..2db6ba5 100644 --- a/pagure/lib/repo.py +++ b/pagure/lib/repo.py @@ -13,6 +13,7 @@ import pygit2 import pagure import pagure.exceptions +import pagure.lib.git class PagureRepo(pygit2.Repository): @@ -24,7 +25,8 @@ class PagureRepo(pygit2.Repository): @staticmethod def push(remote, refname): """ Push the given reference to the specified remote. """ - if pygit2.__version__.startswith('0.22'): + pygit2_version = pagure.lib.git.get_pygit2_version() + if pygit2_version >= (0, 22): remote.push([refname]) else: remote.push(refname)