#4058 Bypass old hooks rather than using non-existing symlinks
Merged 5 years ago by pingou. Opened 5 years ago by pingou.

file modified
+11 -5
@@ -427,7 +427,10 @@ 

      stdin = stdin.encode("utf-8")

  

      if debug:

-         print("Running legacy hooks with args: %s, stdin: %s" % (args, stdin))

+         print(

+             "Running legacy hooks (if any) with args: %s, stdin: %s"

+             % (args, stdin)

+         )

  

      for hook in os.listdir(hookdir):

          # This is for legacy hooks, which create symlinks in the form of
@@ -435,10 +438,13 @@ 

          if hook.startswith(hooktype + "."):

              hookfile = os.path.join(hookdir, hook)

  

-             # Determine if this is an actual hook, or if it's a remnant

-             # from a hook that was installed before it was moved to the

-             # runner system.

-             if os.path.realpath(hookfile) == pagure.lib.query.HOOK_DNE_TARGET:

+             # By-pass all the old hooks that pagure may have created before

+             # moving to the runner architecture

+             if hook in pagure.lib.query.ORIGINAL_PAGURE_HOOK:

+                 continue

+ 

+             if hook.endswith(".sample"):

+                 # Ignore the samples that Git inserts

                  continue

  

              # Execute

file modified
+17 -3
@@ -69,9 +69,23 @@ 

  REDIS = None

  PAGURE_CI = None

  _log = logging.getLogger(__name__)

- # The target for hooks migrated to the Runner system, to be able to detect

- # whether a hook was migrated without having to open and read the file

- HOOK_DNE_TARGET = "/does/not/exist"

+ # List of all the possible hooks pagure could generate before it was moved

+ # to the runner architecture we now use.

+ # This list is kept so we can ignore all of these hooks.

+ ORIGINAL_PAGURE_HOOK = [

+     "post-receive.default",

+     "post-receive.fedmsg",

+     "post-receive.irc",

+     "post-receive.mail",

+     "post-receive.mirror",

+     "post-receive.pagure",

+     "post-receive.pagure-requests",

+     "post-receive.pagure-ticket",

+     "post-receive.rtd",

+     "pre-receive.pagure_no_new_branches",

+     "pre-receive.pagureforcecommit",

+     "pre-receive.pagureunsignedcommit",

+ ]

  

  

  def get_repotypes():

file modified
+1 -3
@@ -605,7 +605,6 @@ 

              raise Exception("Project is already on repoSpanner")

  

          #  Make sure that no non-runner hooks are enabled for this project

-         compatible_targets = [pagure.lib.query.HOOK_DNE_TARGET]

          incompatible_hooks = []

          for repotype in pagure.lib.query.get_repotypes():

              path = project.repopath(repotype)
@@ -620,8 +619,7 @@ 

                  if hook.endswith(".sample"):

                      # Ignore the samples that Git inserts

                      continue

-                 hookfile = os.path.join(hookpath, hook)

-                 if os.path.realpath(hookfile) not in compatible_targets:

+                 if hook not in pagure.lib.query.ORIGINAL_PAGURE_HOOK:

                      incompatible_hooks.append((repotype, hook))

  

          if incompatible_hooks:

When we moved to the runner architecture, we changed the way hooks are
called. During this move, we changed all of our existing hooks into
non-existing symlinks pointing to '/does/not/exists' and we were checking
if the files on disk were matching this target or not.
This created a few issue when releasing pagure:
- python setup.py sdist resolve symlinks as part of the archive creation
process
Reported in https://pagure.io/pagure/issue/3782
- Building pagure failed on some system because these symlinks does not
exist
Reported in https://pagure.io/pagure/issue/3706

So in this commit we are dropping the use of symlink and just making
pagure ignore all the hook it could have created.

Fixes https://pagure.io/pagure/issue/3782
Fixes https://pagure.io/pagure/issue/3706

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

1 new commit added

  • When calling the hooks, ignore the samples that git inserts
5 years ago

rebased onto 79cb3c9a3a1276bd3175db0d46de3b3c51305d9e

5 years ago

rebased onto 498ef54b08d25ad379d9bc15320496b971f3cf6c

5 years ago

rebased onto 498ef54b08d25ad379d9bc15320496b971f3cf6c

5 years ago

rebased onto 7db5e04361731f65fd6f48e1c4157d4f2326eef1

5 years ago

rebased onto 668ab8818a0045ad1ff49350664e9f9687714bf1

5 years ago

rebased onto 3bded87373a3eef6b4a500d3759185bc78a0b0ad

5 years ago

rebased onto 4937c4e

5 years ago

Pull-Request has been merged by pingou

5 years ago