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(