# HG changeset patch # User RhodeCode Admin # Date 2023-11-24 08:56:56 # Node ID 4e9d64b6f457329a1e1ea739d90257bd227dd0a7 # Parent 0450f4222cd449c74e69a961e7a70636826908db fix(hooks): improve the code that manages hooks dir and files to be more prone to permissions issues diff --git a/vcsserver/hook_utils/__init__.py b/vcsserver/hook_utils/__init__.py --- a/vcsserver/hook_utils/__init__.py +++ b/vcsserver/hook_utils/__init__.py @@ -41,14 +41,20 @@ def install_git_hooks(repo_path, bare, e Creates a RhodeCode hook inside a git repository :param repo_path: path to repository + :param bare: defines if repository is considered a bare git repo :param executable: binary executable to put in the hooks - :param force_create: Create even if same name hook exists + :param force_create: Creates even if the same name hook exists """ executable = executable or sys.executable hooks_path = get_git_hooks_path(repo_path, bare) - if not os.path.isdir(hooks_path): + # we always call it to ensure dir exists and it has a proper mode + if not os.path.exists(hooks_path): + # If it doesn't exist, create a new directory with the specified mode os.makedirs(hooks_path, mode=0o777, exist_ok=True) + else: + # If it exists, change the directory's mode to the specified mode + os.chmod(hooks_path, mode=0o777) tmpl_post = pkg_resources.resource_string( 'vcsserver', '/'.join(