SHA256
1
0
forked from pool/pagure
pagure/pagure-pygit2.patch

40 lines
1.7 KiB
Diff

commit 8a1a7ba9f789ba446bab63783f7b963246861cb8
Author: Dominik Wombacher <dominik@wombacher.cc>
Date: Tue Apr 16 18:17:03 2024 +0000
tests: Fix issue 'No module named pygit2.remote'
diff '--color=auto' -ur a/pagure/lib/git.py b/pagure/lib/git.py
--- a/pagure/lib/git.py 2024-05-24 16:43:47.000000000 +0200
+++ b/pagure/lib/git.py 2024-08-17 13:39:06.096428774 +0200
@@ -33,8 +33,10 @@
from sqlalchemy.exc import SQLAlchemyError
-# from sqlalchemy.orm.session import Session
-from pygit2.remote import RemoteCollection
+try:
+ from pygit2.remote import RemoteCollection
+except ImportError:
+ from pygit2.remotes import RemoteCollection
import pagure.utils
import pagure.exceptions
diff '--color=auto' -ur a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py
--- a/tests/test_pagure_lib_git.py 2024-05-24 16:43:47.000000000 +0200
+++ b/tests/test_pagure_lib_git.py 2024-08-17 13:35:21.848131790 +0200
@@ -3645,8 +3645,12 @@
# make sure the function works fine even if there's a leftover
# ref from previous failed run of the function
- with patch("pygit2.remote.RemoteCollection.delete"):
- pagure.lib.git.update_pull_ref(fake_pr, fork)
+ try:
+ with patch("pygit2.remote.RemoteCollection.delete"):
+ pagure.lib.git.update_pull_ref(fake_pr, fork)
+ except ImportError:
+ with patch("pygit2.remotes.RemoteCollection.delete"):
+ pagure.lib.git.update_pull_ref(fake_pr, fork)
self.assertIsNotNone(fork.remotes["pingou_1234567"])
tests.add_content_git_repo(projects[1], append="foobarbaz")
newesthex = fork.references["refs/heads/master"].peel().hex