forked from pool/pagure
105 lines
4.1 KiB
Diff
105 lines
4.1 KiB
Diff
|
From 99cafd173c40d83e06110621ee5f2d3bef82d2c0 Mon Sep 17 00:00:00 2001
|
||
|
From: Pierre-Yves Chibon <pingou@pingoured.fr>
|
||
|
Date: Mon, 26 Nov 2018 12:02:10 +0100
|
||
|
Subject: [PATCH] Bypass old hooks rather than using non-existing symlinks
|
||
|
|
||
|
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>
|
||
|
---
|
||
|
pagure/hooks/__init__.py | 7 +++----
|
||
|
pagure/lib/__init__.py | 20 +++++++++++++++++---
|
||
|
pagure/lib/tasks.py | 4 +---
|
||
|
3 files changed, 21 insertions(+), 10 deletions(-)
|
||
|
|
||
|
diff --git a/pagure/hooks/__init__.py b/pagure/hooks/__init__.py
|
||
|
index 027f5822..d7409460 100644
|
||
|
--- a/pagure/hooks/__init__.py
|
||
|
+++ b/pagure/hooks/__init__.py
|
||
|
@@ -411,10 +411,9 @@ def run_project_hooks(
|
||
|
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.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.ORIGINAL_PAGURE_HOOK:
|
||
|
continue
|
||
|
|
||
|
# Execute
|
||
|
diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py
|
||
|
index 0284201b..aebd07d4 100644
|
||
|
--- a/pagure/lib/__init__.py
|
||
|
+++ b/pagure/lib/__init__.py
|
||
|
@@ -70,9 +70,23 @@ REDIS = None
|
||
|
PAGURE_CI = None
|
||
|
REPOTYPES = ("main", "docs", "tickets", "requests")
|
||
|
_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",
|
||
|
+]
|
||
|
|
||
|
|
||
|
class Unspecified(object):
|
||
|
diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py
|
||
|
index 74c03291..2e73121f 100644
|
||
|
--- a/pagure/lib/tasks.py
|
||
|
+++ b/pagure/lib/tasks.py
|
||
|
@@ -651,7 +651,6 @@ def move_to_repospanner(self, session, name, namespace, user, region):
|
||
|
raise Exception("Project is already on repoSpanner")
|
||
|
|
||
|
# Make sure that no non-runner hooks are enabled for this project
|
||
|
- compatible_targets = [pagure.lib.HOOK_DNE_TARGET]
|
||
|
incompatible_hooks = []
|
||
|
for repotype in pagure.lib.REPOTYPES:
|
||
|
path = project.repopath(repotype)
|
||
|
@@ -666,8 +665,7 @@ def move_to_repospanner(self, session, name, namespace, user, region):
|
||
|
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.ORIGINAL_PAGURE_HOOK:
|
||
|
incompatible_hooks.append((repotype, hook))
|
||
|
|
||
|
if incompatible_hooks:
|
||
|
--
|
||
|
2.17.2
|
||
|
|