예제 #1
0
파일: git.py 프로젝트: sundysj/submin
def old_hook_repos(git_dir_root):
    signature = '### SUBMIN GIT AUTOCONFIG, DO NOT ALTER FOLLOWING LINE ###\n'
    git_dirs = []
    for root, dirs, files in os.walk(git_dir_root):
        for d in dirs:
            if d.endswith('.git'):
                git_dirs.append(d)
        break

    for git_dir in sorted(git_dirs):
        # check update hook
        reponame = git_dir[:-4]
        filename = os.path.join(git_dir_root, git_dir, 'hooks', 'update')
        if not shellscript.hasSignature(filename, signature):
            yield (reponame, 'update hook out-of-date')
            continue  # no need to check other hooks

        # check multiplexer script
        filename = os.path.join(git_dir_root, git_dir, 'hooks', 'post-receive')
        if not os.path.exists(filename):
            yield (reponame, 'post-receive does not exist')
            continue

        # ok, it exists, but does it contain the right stuff?
        if not shellscript.hasSignature(filename, signature):
            yield (reponame, 'post-receive does not call hook-mux')
            continue

        # check commit-email hook
        filename = os.path.join(git_dir_root, git_dir, 'hooks',
                                'post-receive.d', '001-commit-email.hook')
        # no post-receive hook = no commit emails enabled
        if os.path.exists(filename):
            if not hook_uptodate(filename, 'HOOK_VERSION = (\d+)',
                                 HOOK_VERSIONS['commit-email']):
                yield (reponame, 'commit email hook version incorrect')
                continue

        # check trac-sync hook
        filename = os.path.join(git_dir_root, git_dir, 'hooks',
                                'post-receive.d', '002-trac-sync.hook')
        # no post-receive hook = no trac-sync enabled
        if os.path.exists(filename):
            if not hook_uptodate(filename, 'HOOK_VERSION=(\d+)',
                                 HOOK_VERSIONS['trac-sync']):
                yield (reponame, 'trac sync hook version incorrect')
                continue

    return
예제 #2
0
def prepare(reponame):
    """Make sure basic things are in place for post-receive scripts to work.
	The post-receive hook calls hook-mux, which multiplexes everything on
	standard input to multiple scripts found in the post-recieve.d directory.

	This makes it possible to have multiple (post-receive) hooks.
	"""
    hook_dir = repository.directory('git', reponame) + 'hooks'

    # Make sure multiplexer script is in place. It should be a shell script
    # that calls the actual real script. The old situation is that the
    # post-receive script was actually a script to call only git-multimail.py.
    # The reason why we have a call to the script instead of a symlink, is
    # because we can not guarantee the executable bit of the target.
    if not shellscript.hasSignature(hook_dir + 'post-receive', signature):
        rewrite_hook(reponame,
                     'post-receive',
                     'hook-mux',
                     interpreter='/bin/bash',
                     args='post-receive')

    # make sure multiplexer dir exists
    # because www user can check if files in this directory exists, but
    # we can't chgrp() the dir, we set the mode explicitly to 0755. The
    # parent dir is only open to git user and www group, with mode 0750.
    mkdirs(hook_dir + 'post-receive.d', mode=0o755)
예제 #3
0
	def commitEmailsEnabled(self):
		"""Returns True if sending of commit messages is enabled."""
		hookdir = directory(self.name) + 'hooks'
		hook = hookdir + 'post-receive.d' + '001-commit-email.hook'
		old_hook = hookdir + 'post-receive'
		return os.path.exists(hook) or (
			os.path.exists(old_hook) and
			not shellscript.hasSignature(old_hook, hook_signature))
예제 #4
0
 def commitEmailsEnabled(self):
     """Returns True if sending of commit messages is enabled."""
     hookdir = directory(self.name) + 'hooks'
     hook = hookdir + 'post-receive.d' + '001-commit-email.hook'
     old_hook = hookdir + 'post-receive'
     return os.path.exists(hook) or (
         os.path.exists(old_hook)
         and not shellscript.hasSignature(old_hook, hook_signature))
예제 #5
0
파일: git.py 프로젝트: andy-deng/submin
def old_hook_repos(git_dir_root):
    signature = "### SUBMIN GIT AUTOCONFIG, DO NOT ALTER FOLLOWING LINE ###\n"
    git_dirs = []
    for root, dirs, files in os.walk(git_dir_root):
        for d in dirs:
            if d.endswith(".git"):
                git_dirs.append(d)
        break

    for git_dir in sorted(git_dirs):
        # check update hook
        reponame = git_dir[:-4]
        filename = os.path.join(git_dir_root, git_dir, "hooks", "update")
        if not shellscript.hasSignature(filename, signature):
            yield (reponame, "update hook out-of-date")
            continue  # no need to check other hooks

            # check multiplexer script
        filename = os.path.join(git_dir_root, git_dir, "hooks", "post-receive")
        if not os.path.exists(filename):
            yield (reponame, "post-receive does not exist")
            continue

            # ok, it exists, but does it contain the right stuff?
        if not shellscript.hasSignature(filename, signature):
            yield (reponame, "post-receive does not call hook-mux")
            continue

            # check commit-email hook
        filename = os.path.join(git_dir_root, git_dir, "hooks", "post-receive.d", "001-commit-email.hook")
        # no post-receive hook = no commit emails enabled
        if os.path.exists(filename):
            if not hook_uptodate(filename, "HOOK_VERSION = (\d+)", HOOK_VERSIONS["commit-email"]):
                yield (reponame, "commit email hook version incorrect")
                continue

                # check trac-sync hook
        filename = os.path.join(git_dir_root, git_dir, "hooks", "post-receive.d", "002-trac-sync.hook")
        # no post-receive hook = no trac-sync enabled
        if os.path.exists(filename):
            if not hook_uptodate(filename, "HOOK_VERSION=(\d+)", HOOK_VERSIONS["trac-sync"]):
                yield (reponame, "trac sync hook version incorrect")
                continue

    return
예제 #6
0
파일: common.py 프로젝트: andy-deng/submin
def enable_hook(reposdir, hookname, targetname,
			interpreter='/usr/bin/python', args='"$@"'):
	"""Assumes no hook is already there, or if there is, that is a shell script.
	If you want to overwrite the hook with a clean submin-hook, call rewrite_hook instead."""
	target_script = options.static_path("hooks") + "git" + targetname
	new_hook = '%s %s %s\n' % (interpreter, target_script, args)
	hook = reposdir + 'hooks' + hookname

	if shellscript.hasSignature(hook, signature):
		return

	shellscript.rewriteWithSignature(hook, signature, new_hook, True, mode=0o755)
예제 #7
0
def enable_hook(reposdir,
                hookname,
                targetname,
                interpreter='/usr/bin/python',
                args='"$@"'):
    """Assumes no hook is already there, or if there is, that is a shell script.
	If you want to overwrite the hook with a clean submin-hook, call rewrite_hook instead."""
    target_script = options.static_path("hooks") + "git" + targetname
    new_hook = '%s %s %s\n' % (interpreter, target_script, args)
    hook = reposdir + 'hooks' + hookname

    if shellscript.hasSignature(hook, signature):
        return

    shellscript.rewriteWithSignature(hook,
                                     signature,
                                     new_hook,
                                     True,
                                     mode=0o755)
예제 #8
0
def prepare(reponame):
	"""Make sure basic things are in place for post-receive scripts to work.
	The post-receive hook calls hook-mux, which multiplexes everything on
	standard input to multiple scripts found in the post-recieve.d directory.

	This makes it possible to have multiple (post-receive) hooks.
	"""
	hook_dir = repository.directory('git', reponame) + 'hooks'

	# Make sure multiplexer script is in place. It should be a shell script
	# that calls the actual real script. The old situation is that the
	# post-receive script was actually a script to call only git-multimail.py.
	# The reason why we have a call to the script instead of a symlink, is
	# because we can not guarantee the executable bit of the target.
	if not shellscript.hasSignature(hook_dir + 'post-receive', signature):
		rewrite_hook(reponame, 'post-receive', 'hook-mux',
			interpreter='/bin/bash', args='post-receive')

	# make sure multiplexer dir exists
	# because www user can check if files in this directory exists, but
	# we can't chgrp() the dir, we set the mode explicitly to 0755. The
	# parent dir is only open to git user and www group, with mode 0750.
	mkdirs(hook_dir + 'post-receive.d', mode=0o755)
예제 #9
0
	def tracCommitHookEnabled(self):
		reposdir = options.env_path('svn_dir')
		hook = reposdir + self.name + 'hooks' + 'post-commit'
		return shellscript.hasSignature(str(hook), self.trac_signature)
예제 #10
0
	def tracCommitHookEnabled(self):
		reposdir = options.env_path('svn_dir')
		hook = reposdir + self.name + 'hooks' + 'post-commit'
		return shellscript.hasSignature(str(hook), self.trac_signature)