From 30f189736137a50da4b740acf775ff6675a15a70 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Wed, 8 Mar 2023 16:39:16 +0100 Subject: [PATCH] Do not generate pre-push hook script in some cases Some rpkg users don't use fedpkg or similar tool for cloning and therefore there is no tool to execute the pre-push-check function. Do not generate the hook script in this case. Fixes: #665 JIRA: RHELCMP-11392 Signed-off-by: Ondrej Nosek --- pyrpkg/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index acdad22..776cb21 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -1795,6 +1795,13 @@ class Commands(object): for possible user mistakes. """ tool_name = os.path.basename(sys.argv[0]) # rhpkg|fedpkg|... + if not tool_name: + # empty argv - this functionality is not executed from x-pkg tool + # and therefore there isn't a program that can run pre-push-check. + # Example: the COPR team executes 'clone' by their own script. + self.log.debug('Pre-push hook script was NOT added - missing ' + 'the packaging tool like fedpkg, rhpkg, ...') + return hook_content = textwrap.dedent(""" #!/bin/bash -- 2.39.2