diff options
Diffstat (limited to '0018-Config-file-option-to-skip-the-hook-script-creation.patch')
-rw-r--r-- | 0018-Config-file-option-to-skip-the-hook-script-creation.patch | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/0018-Config-file-option-to-skip-the-hook-script-creation.patch b/0018-Config-file-option-to-skip-the-hook-script-creation.patch deleted file mode 100644 index fa9aa01..0000000 --- a/0018-Config-file-option-to-skip-the-hook-script-creation.patch +++ /dev/null @@ -1,126 +0,0 @@ -From b48eb502d330ec7a543805d7f185ea270df75b90 Mon Sep 17 00:00:00 2001 -From: Ondrej Nosek <onosek@redhat.com> -Date: Wed, 12 Apr 2023 00:42:04 +0200 -Subject: [PATCH 5/6] Config file option to skip the hook script creation - -A new option named "skip_hooks" can be added to the config file -(into the main section). It accepts boolean values and when -the option is present and set, it prevents creating the pre-push -hook script during cloning a dist-git repository. - -Fixes: https://pagure.io/fedpkg/issue/515 -JIRA: RHELCMP-11491 - -Signed-off-by: Ondrej Nosek <onosek@redhat.com> ---- - pyrpkg/__init__.py | 14 ++++++++++---- - pyrpkg/cli.py | 13 +++++++++++-- - 2 files changed, 21 insertions(+), 6 deletions(-) - -diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py -index 187796e..7fddff7 100644 ---- a/pyrpkg/__init__.py -+++ b/pyrpkg/__init__.py -@@ -1571,7 +1571,7 @@ class Commands(object): - - def clone(self, repo, path=None, branch=None, bare_dir=None, - anon=False, target=None, depth=None, extra_args=None, -- config_path=None): -+ config_path=None, skip_hooks=None): - """Clone a repo, optionally check out a specific branch. - - :param str repo: the name of the repository to clone. -@@ -1589,6 +1589,7 @@ class Commands(object): - :param list extra_args: additional arguments that are passed to - the clone command. - :param str config_path: path to the global config file -+ :param bool skip_hooks: skip creation pre-push hook script - """ - - if not path: -@@ -1644,7 +1645,8 @@ class Commands(object): - - if not bare_dir: - self._add_git_excludes(os.path.join(path, git_dir)) -- self._add_git_pre_push_hook(os.path.join(path, git_dir), config_path) -+ if not skip_hooks: -+ self._add_git_pre_push_hook(os.path.join(path, git_dir), config_path) - - return - -@@ -1660,7 +1662,7 @@ class Commands(object): - return repo - - def clone_with_dirs(self, repo, anon=False, target=None, depth=None, -- extra_args=None, config_path=None): -+ extra_args=None, config_path=None, skip_hooks=None): - """Clone a repo old style with subdirs for each branch. - - :param str repo: name of the repository to clone. -@@ -1673,6 +1675,7 @@ class Commands(object): - :param list extra_args: additional arguments that are passed to - the clone command. - :param str config_path: path to the global config file -+ :param bool skip_hooks: skip creation pre-push hook script - """ - - self._push_url = None -@@ -1731,7 +1734,8 @@ class Commands(object): - - # Add excludes - self._add_git_excludes(branch_path) -- self._add_git_pre_push_hook(branch_path, config_path) -+ if not skip_hooks: -+ self._add_git_pre_push_hook(branch_path, config_path) - except (git.GitCommandError, OSError) as e: - raise rpkgError('Could not locally clone %s from %s: %s' - % (branch, repo_path, e)) -@@ -1820,6 +1824,8 @@ class Commands(object): - # This file was generated by {0} when cloning the repository. - # You can edit it to your liking or delete completely. It will not - # be recreated. -+ # Creating this file can be also prevented by adding an option -+ # "skip_hooks = True" into the {0}'s config file; [{0}] section. - - _remote="$1" - _url="$2" -diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py -index 3d8ce33..a1f3f44 100644 ---- a/pyrpkg/cli.py -+++ b/pyrpkg/cli.py -@@ -2177,13 +2177,21 @@ class cliClient(object): - self.log.warning("Repo name should't contain '.git' suffix. " - "Correcting the repo name: '%s'" % repo) - -+ skip_hooks = None -+ if self.config.has_option(self.name, "skip_hooks"): -+ try: -+ skip_hooks = self.config.getboolean(self.name, "skip_hooks") -+ except ValueError: -+ self.log.error("Error: config file option 'skip_hooks'") -+ raise - if self.args.branches: - self.cmd.clone_with_dirs(self.args.repo[0], - anon=self.args.anonymous, - target=self.args.clone_target, - depth=self.args.depth, - extra_args=self.extra_args, -- config_path=self.args.config) -+ config_path=self.args.config, -+ skip_hooks=skip_hooks) - else: - self.cmd.clone(self.args.repo[0], - branch=self.args.branch, -@@ -2191,7 +2199,8 @@ class cliClient(object): - target=self.args.clone_target, - depth=self.args.depth, - extra_args=self.extra_args, -- config_path=self.args.config) -+ config_path=self.args.config, -+ skip_hooks=skip_hooks) - - def commit(self): - if self.args.with_changelog and not self.args.message: --- -2.39.2 - |