From 4553da364d7d8a974ab0c08834ee0a54320da2cb Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Tue, 18 Apr 2023 16:06:43 +0200 Subject: [PATCH 6/6] Pre-push hook won't check private branches The pre-push hook script was failing the when user tried to push a private branch. It required using the --release argument with the pre-push-check command and passing additional arguments into the hook script. That was found unreliable and private branches won't be checked. Fixes: #683 JIRA: RHELCMP-11528 Signed-off-by: Ondrej Nosek --- pyrpkg/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 7fddff7..3f934d3 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -4489,9 +4489,15 @@ class Commands(object): specfile_path = os.path.relpath(specfile_path_absolute, start=self.path) cmd = ['spectool', '-l', os.path.join(clone_dir, specfile_path)] # extract just '--define' arguments from rpmdefines - for opt, val in zip(self.rpmdefines[0::2], self.rpmdefines[1::2]): - if opt == '--define': - cmd.extend((opt, val)) + try: + for opt, val in zip(self.rpmdefines[0::2], self.rpmdefines[1::2]): + if opt == '--define': + cmd.extend((opt, val)) + except rpkgError: + # this exception was caused probably by using a private branch + self.log.warning('The pre-push script can\'t check private branches. ' + 'Push operation continues.') + return ret, stdout, _ = self._run_command(cmd, cwd=clone_dir, return_text=True, return_stdout=True) if ret != 0: -- 2.39.2