git/check-perms: Adapt the script to the Gitolite3 VREF stuff
This commit is contained in:
parent
ec1d144ab0
commit
a28756babd
1 changed files with 14 additions and 47 deletions
|
@ -308,65 +308,32 @@ def check_git_perms(path, fix=False):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_update_hooks(gitdir, fix=False):
|
def check_gitolite_update_hook(gitdir, fix=False):
|
||||||
"""Check our update hooks
|
"""Check our update hooks
|
||||||
|
|
||||||
This ensures that the Git repository at `gitdir` is set up with the proper
|
This ensures that the Git repository at `gitdir` is set up with the proper
|
||||||
update hooks.
|
update hook for Gitolite.
|
||||||
|
|
||||||
If it isn't, and if `fix` is True, this actually fixes the problem.
|
If it isn't, and if `fix` is True, this actually fixes the problem.
|
||||||
"""
|
"""
|
||||||
chained_hooks_dir = os.path.join(gitdir, 'hooks', 'update-chained.d')
|
gitolite_hook = '/etc/gitolite/hooks/common/update'
|
||||||
chained_hooks = {'update-gitolite': '/etc/gitolite/hooks/common/update',
|
update_hook = os.path.join(gitdir, 'hooks', 'update')
|
||||||
'update-block-push-origin': '/usr/share/git-core/update-block-push-origin',
|
|
||||||
}
|
|
||||||
|
|
||||||
if not os.path.isdir(chained_hooks_dir):
|
if not os.path.exists(update_hook):
|
||||||
if fix:
|
if fix:
|
||||||
os.makedirs(chained_hooks_dir)
|
os.symlink(gitolite_hook, update_hook)
|
||||||
|
return
|
||||||
|
|
||||||
else:
|
raise ValueError('No update hook set up')
|
||||||
raise ValueError('chained hooks not set up')
|
|
||||||
|
|
||||||
for name, goodpath in chained_hooks.items():
|
if os.path.realpath(update_hook) != gitolite_hook:
|
||||||
hook = os.path.join(chained_hooks_dir, name)
|
|
||||||
|
|
||||||
if not os.path.exists(hook):
|
|
||||||
if fix:
|
|
||||||
os.symlink(goodpath, hook)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise ValueError('%s chained update hook not set up' % name)
|
|
||||||
|
|
||||||
realpath = os.path.realpath(hook)
|
|
||||||
if realpath != goodpath:
|
|
||||||
if fix:
|
|
||||||
os.unlink(hook)
|
|
||||||
os.symlink(goodpath, hook)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise ValueError('invalid %s chained update hook' % name)
|
|
||||||
|
|
||||||
|
|
||||||
goodpath = '/usr/share/git-core/update-chained'
|
|
||||||
hook = os.path.join(gitdir, 'hooks', 'update')
|
|
||||||
|
|
||||||
if not os.path.exists(hook):
|
|
||||||
if fix:
|
if fix:
|
||||||
os.symlink(goodpath, hook)
|
os.unlink(update_hook)
|
||||||
|
os.symlink(gitolite_hook, update_hook)
|
||||||
|
return
|
||||||
|
|
||||||
else:
|
raise ValueError('Update hook does not point to the Gitolie one')
|
||||||
raise ValueError('no update hook set up')
|
|
||||||
|
|
||||||
realpath = os.path.realpath(hook)
|
|
||||||
|
|
||||||
if realpath != goodpath:
|
|
||||||
if fix:
|
|
||||||
os.unlink(hook)
|
|
||||||
os.symlink(goodpath, hook)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise ValueError('invalid update hook (%s)' % hook)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = '%prog [options] [gitroot]'
|
usage = '%prog [options] [gitroot]'
|
||||||
|
@ -470,7 +437,7 @@ def main():
|
||||||
|
|
||||||
if 'update-hook' in checks:
|
if 'update-hook' in checks:
|
||||||
try:
|
try:
|
||||||
check_update_hooks(gitdir, fix=opts.fix)
|
check_gitolite_update_hook(gitdir, fix=opts.fix)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error('%s: %s' % (gitdir, e))
|
error('%s: %s' % (gitdir, e))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue