Changeset - 9bc1ee41df8c
[Not reviewed]
default
0 3 0
domruf - 8 years ago 2018-01-25 21:49:33
dominikruf@gmail.com
Grafted from: b6e09bf7852f
hooks: rename 'push_data' and 'revs' to git_stdin_lines

...to better reflect what it is.
3 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
kallithea/config/post_receive_tmpl.py
Show inline comments
 
@@ -8,23 +8,23 @@ import sys
 
# instead of the exception output
 
if sys.platform == "win32":
 
    import msvcrt
 
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
 

	
 
KALLITHEA_HOOK_VER = '_TMPL_'
 
os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
 
from kallithea.lib.hooks import handle_git_post_receive as _handler
 

	
 

	
 
def main():
 
    repo_path = os.path.abspath('.')
 
    push_data = sys.stdin.readlines()
 
    git_stdin_lines = sys.stdin.readlines()
 
    # os.environ is modified here by a subprocess call that
 
    # runs git and later git executes this hook.
 
    # Environ gets some additional info from kallithea system
 
    # like IP or username from basic-auth
 
    _handler(repo_path, push_data, os.environ)
 
    _handler(repo_path, git_stdin_lines, os.environ)
 
    sys.exit(0)
 

	
 

	
 
if __name__ == '__main__':
 
    main()
kallithea/config/pre_receive_tmpl.py
Show inline comments
 
@@ -8,23 +8,23 @@ import sys
 
# instead of the exception output
 
if sys.platform == "win32":
 
    import msvcrt
 
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
 

	
 
KALLITHEA_HOOK_VER = '_TMPL_'
 
os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
 
from kallithea.lib.hooks import handle_git_pre_receive as _handler
 

	
 

	
 
def main():
 
    repo_path = os.path.abspath('.')
 
    push_data = sys.stdin.readlines()
 
    git_stdin_lines = sys.stdin.readlines()
 
    # os.environ is modified here by a subprocess call that
 
    # runs git and later git executes this hook.
 
    # Environ gets some additional info from kallithea system
 
    # like IP or username from basic-auth
 
    _handler(repo_path, push_data, os.environ)
 
    _handler(repo_path, git_stdin_lines, os.environ)
 
    sys.exit(0)
 

	
 

	
 
if __name__ == '__main__':
 
    main()
kallithea/lib/hooks.py
Show inline comments
 
@@ -355,33 +355,33 @@ def log_delete_user(user_dict, deleted_b
 
     'emails',
 
     'inherit_default_permissions'
 

	
 
    """
 
    from kallithea import EXTENSIONS
 
    callback = getattr(EXTENSIONS, 'DELETE_USER_HOOK', None)
 
    if callable(callback):
 
        return callback(deleted_by=deleted_by, **user_dict)
 

	
 
    return 0
 

	
 

	
 
def handle_git_pre_receive(repo_path, revs, env):
 
    return handle_git_receive(repo_path, revs, env, hook_type='pre')
 
def handle_git_pre_receive(repo_path, git_stdin_lines, env):
 
    return handle_git_receive(repo_path, git_stdin_lines, env, hook_type='pre')
 

	
 

	
 
def handle_git_post_receive(repo_path, revs, env):
 
    return handle_git_receive(repo_path, revs, env, hook_type='post')
 
def handle_git_post_receive(repo_path, git_stdin_lines, env):
 
    return handle_git_receive(repo_path, git_stdin_lines, env, hook_type='post')
 

	
 

	
 
def handle_git_receive(repo_path, revs, env, hook_type):
 
def handle_git_receive(repo_path, git_stdin_lines, env, hook_type):
 
    """
 
    A really hacky method that is run by git post-receive hook and logs
 
    a push action together with pushed revisions. It's executed by subprocess
 
    thus needs all info to be able to create an on the fly app environment,
 
    connect to database and run the logging code. Hacky as sh*t but works.
 

	
 
    :param repo_path:
 
    :param revs:
 
    :param env:
 
    """
 
    from paste.deploy import appconfig
 
    from sqlalchemy import engine_from_config
 
@@ -416,25 +416,25 @@ def handle_git_receive(repo_path, revs, 
 
    if hook_type == 'pre':
 
        repo = repo.scm_instance
 
    else:
 
        # post push shouldn't use the cached instance never
 
        repo = repo.scm_instance_no_cache()
 

	
 
    if hook_type == 'pre':
 
        pre_push(baseui, repo)
 

	
 
    # if push hook is enabled via web interface
 
    elif hook_type == 'post' and _hooks.get(Ui.HOOK_PUSH):
 
        rev_data = []
 
        for l in revs:
 
        for l in git_stdin_lines:
 
            old_rev, new_rev, ref = l.strip().split(' ')
 
            _ref_data = ref.split('/')
 
            if _ref_data[1] in ['tags', 'heads']:
 
                rev_data.append({'old_rev': old_rev,
 
                                 'new_rev': new_rev,
 
                                 'ref': ref,
 
                                 'type': _ref_data[1],
 
                                 'name': '/'.join(_ref_data[2:])})
 

	
 
        git_revs = []
 

	
 
        for push_ref in rev_data:
0 comments (0 inline, 0 general)