#682 Config file option to skip the hook script creation
Merged a year ago by onosek. Opened a year ago by onosek.
onosek/rpkg skip_hooks  into  master

file modified
+10 -4
@@ -1571,7 +1571,7 @@ 

  

      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 @@ 

          :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 @@ 

  

          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 @@ 

          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 @@ 

          :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 @@ 

  

                  # 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 @@ 

              # 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"

file modified
+11 -2
@@ -2177,13 +2177,21 @@ 

              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 @@ 

                             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:

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

pretty please pagure-ci rebuild

a year ago

pretty please pagure-ci rebuild

a year ago

pretty please pagure-ci rebuild

a year ago

pretty please pagure-ci rebuild

a year ago

pretty please pagure-ci rebuild

a year ago

rebased onto 067b7f3b7b26d595ce479336eadee036e4a23f30

a year ago

pretty please pagure-ci rebuild

a year ago

Looks good to me.

How about adding information about this option to the comment in the hook script itself? I don't know if people would expect it there, but there would IMO be no harm in mentioning it.

Looks good to me.

How about adding information about this option to the comment in the hook script itself? I don't know if people would expect it there, but there would IMO be no harm in mentioning it.

Agree, it doesn't harm anything. Hopefully adding this option will not motivate users to use it on a large scale.

rebased onto 0aabe89e0ada8babdeefd51dab1c5cb4a19dcf86

a year ago

rebased onto f1a56eaa835287488feecd707b6d2c0c7bcf8fe3

a year ago

rebased onto 58c3d1533d366d5a82df4c2b9f4ff5de617a50ad

a year ago

rebased onto b48eb50

a year ago

Pull-Request has been merged by onosek

a year ago
Metadata