From 6aab3c39927ce8cd1df255c237e67c5c06a4623b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 17 2015 08:39:36 +0000 Subject: Introduce the PagureRepo class, sub-class of pygit2.Repository The aim is to concentrate in this class all the logic to handle the different breakage of pygit2's API, either overriding methods or using static methods --- diff --git a/pagure/lib/repo.py b/pagure/lib/repo.py new file mode 100644 index 0000000..12dbd66 --- /dev/null +++ b/pagure/lib/repo.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +""" + (c) 2015 - Copyright Red Hat Inc + + Authors: + Pierre-Yves Chibon + +""" + + +import pygit2 + + +class PagureRepo(pygit2.Repository): + """ An utility class allowing to go around pygit2's inability to be + stable. + + """ + + @staticmethod + def push(remote, refname): + """ Push the given reference to the specified remote. """ + if pygit2.__version__.startswith('0.22'): + remote.push([refname]) + else: + remote.push(refname)