From 46d7daa5bfecde9344dd48ed5c04a3681553340c Mon Sep 17 00:00:00 2001
From: Troy Dawson <tdawson@redhat.com>
Date: Tue, 23 Apr 2024 14:50:41 -0700
Subject: [PATCH] warn on possible fork
---
src/centpkg/__init__.py | 3 ++-
tests/test_distgit.py | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py
index d52b659..782f107 100644
--- a/src/centpkg/__init__.py
+++ b/src/centpkg/__init__.py
@@ -92,7 +92,8 @@ class DistGitDirectory(object):
DeprecationWarning)
else:
if not self.is_fork():
- raise ValueError("Branchname: {0} is not valid".format(branchtext))
+ warnings.warn('Unable to determine if this is a fork or not. Proceeding, but you should double check.',
+ UserWarning)
else:
self.distrobranch = True
self.signame = 'centos'
diff --git a/tests/test_distgit.py b/tests/test_distgit.py
index 5519a78..257aa13 100644
--- a/tests/test_distgit.py
+++ b/tests/test_distgit.py
@@ -13,11 +13,11 @@ class TestDistGitNothing(unittest.TestCase):
with self.assertRaises(TypeError):
d = DistGitDirectory()
-class TestDistGitInvalid(unittest.TestCase):
+class TestDistGitInvalid(unittest.TestCase, CatchWarningsMixin):
def test_invalid_branchstring_raises(self):
self.branchstring = 'nope-not-a-branch'
- with self.assertRaises(ValueError):
+ with self.assertWarns(UserWarning):
self.d = DistGitDirectory(self.branchstring)
class TestDistgitOnlySig(unittest.TestCase):
@@ -244,4 +244,4 @@ class TestIsFork(unittest.TestCase):
@unittest.mock.patch.object(centpkg_git.repo.Repo, '__init__', new=lambda s, p: None)
def test_upstream_url(self):
d = DistGitDirectory(self.branchstring, 'binutils')
- self.assertFalse(d.is_fork())
\ No newline at end of file
+ self.assertFalse(d.is_fork())
--
2.39.3