From 08cdff0852a4e07ce29d4eb2340e1044fdbb5ba0 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 05 2020 09:27:18 +0000 Subject: Fix mirroring in projects hosted elsewhere To fix this we needed to support internal push to the main repo, so not just "tickets" and "requests". We also needed to ensure that the push was marked as internal. Finally we needed to convert to unicode the output of the subprocess command which in python3 returns bytes. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/__init__.py b/pagure/hooks/__init__.py index 5774b59..0e12ad5 100644 --- a/pagure/hooks/__init__.py +++ b/pagure/hooks/__init__.py @@ -320,11 +320,7 @@ def run_project_hooks( # First we run dynamic ACLs authbackend = get_git_auth_helper() - if ( - is_internal - and username == "pagure" - and repotype in ("tickets", "requests") - ): + if is_internal and username == "pagure": if debug: print("This is an internal push, dynamic ACL is pre-approved") elif not authbackend.is_dynamic: diff --git a/pagure/lib/git.py b/pagure/lib/git.py index d80d331..3cc30af 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -3036,13 +3036,14 @@ def mirror_pull_project(session, project, debug=False): env = os.environ.copy() env["GL_USER"] = "pagure" env["GL_BYPASS_ACCESS_CHECKS"] = "1" + env["internal"] = "yes" if pagure_config.get("GITOLITE_HOME"): env["HOME"] = pagure_config["GITOLITE_HOME"] env.update(environ) env.update(extra) out = subprocess.check_output( command, cwd=repopath, stderr=subprocess.STDOUT, env=env - ) + ).decode("utf-8") log = "Output from %s:" % command logs.append(log) logs.append(out) diff --git a/tests/test_pagure_lib_git_mirror_project.py b/tests/test_pagure_lib_git_mirror_project.py index 03aebef..4773a6a 100644 --- a/tests/test_pagure_lib_git_mirror_project.py +++ b/tests/test_pagure_lib_git_mirror_project.py @@ -60,7 +60,7 @@ class PagureLibGitMirrorProjecttests(tests.Modeltests): tmp = MagicMock() tmp.communicate.return_value = ("", "") popen_mock.return_value = tmp - ck_out_mock.return_value = "all good" + ck_out_mock.return_value = b"all good" output = pagure.lib.git.mirror_pull_project(self.session, self.project)