Show More
@@ -28,7 +28,7 b' import kallithea.lib.hooks' | |||||
28 | def main(): |
|
28 | def main(): | |
29 | repo_path = os.path.abspath('.') |
|
29 | repo_path = os.path.abspath('.') | |
30 | git_stdin_lines = sys.stdin.readlines() |
|
30 | git_stdin_lines = sys.stdin.readlines() | |
31 |
sys.exit(kallithea.lib.hooks.handle_git_post_receive(repo_path, git_stdin_lines |
|
31 | sys.exit(kallithea.lib.hooks.handle_git_post_receive(repo_path, git_stdin_lines)) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | if __name__ == '__main__': |
|
34 | if __name__ == '__main__': |
@@ -28,7 +28,7 b' import kallithea.lib.hooks' | |||||
28 | def main(): |
|
28 | def main(): | |
29 | repo_path = os.path.abspath('.') |
|
29 | repo_path = os.path.abspath('.') | |
30 | git_stdin_lines = sys.stdin.readlines() |
|
30 | git_stdin_lines = sys.stdin.readlines() | |
31 |
sys.exit(kallithea.lib.hooks.handle_git_pre_receive(repo_path, git_stdin_lines |
|
31 | sys.exit(kallithea.lib.hooks.handle_git_pre_receive(repo_path, git_stdin_lines)) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | if __name__ == '__main__': |
|
34 | if __name__ == '__main__': |
@@ -357,7 +357,7 b' def log_delete_user(user_dict, deleted_b' | |||||
357 | return 0 |
|
357 | return 0 | |
358 |
|
358 | |||
359 |
|
359 | |||
360 |
def _hook_environment(repo_path |
|
360 | def _hook_environment(repo_path): | |
361 | """ |
|
361 | """ | |
362 | Create a light-weight environment for stand-alone scripts and return an UI and the |
|
362 | Create a light-weight environment for stand-alone scripts and return an UI and the | |
363 | db repository. |
|
363 | db repository. | |
@@ -371,7 +371,7 b' def _hook_environment(repo_path, env):' | |||||
371 | from kallithea.config.environment import load_environment |
|
371 | from kallithea.config.environment import load_environment | |
372 | from kallithea.model.base import init_model |
|
372 | from kallithea.model.base import init_model | |
373 |
|
373 | |||
374 |
extras = _extract_extras( |
|
374 | extras = _extract_extras() | |
375 | path, ini_name = os.path.split(extras['config']) |
|
375 | path, ini_name = os.path.split(extras['config']) | |
376 | conf = appconfig('config:%s' % ini_name, relative_to=path) |
|
376 | conf = appconfig('config:%s' % ini_name, relative_to=path) | |
377 | conf = load_environment(conf.global_conf, conf.local_conf) |
|
377 | conf = load_environment(conf.global_conf, conf.local_conf) | |
@@ -395,16 +395,16 b' def _hook_environment(repo_path, env):' | |||||
395 | return baseui, repo |
|
395 | return baseui, repo | |
396 |
|
396 | |||
397 |
|
397 | |||
398 |
def handle_git_pre_receive(repo_path, git_stdin_lines |
|
398 | def handle_git_pre_receive(repo_path, git_stdin_lines): | |
399 | """Called from Git pre-receive hook""" |
|
399 | """Called from Git pre-receive hook""" | |
400 |
baseui, repo = _hook_environment(repo_path |
|
400 | baseui, repo = _hook_environment(repo_path) | |
401 | scm_repo = repo.scm_instance |
|
401 | scm_repo = repo.scm_instance | |
402 | push_lock_handling(baseui, scm_repo) |
|
402 | push_lock_handling(baseui, scm_repo) | |
403 |
|
403 | |||
404 |
|
404 | |||
405 |
def handle_git_post_receive(repo_path, git_stdin_lines |
|
405 | def handle_git_post_receive(repo_path, git_stdin_lines): | |
406 | """Called from Git post-receive hook""" |
|
406 | """Called from Git post-receive hook""" | |
407 |
baseui, repo = _hook_environment(repo_path |
|
407 | baseui, repo = _hook_environment(repo_path) | |
408 |
|
408 | |||
409 | # the post push hook should never use the cached instance |
|
409 | # the post push hook should never use the cached instance | |
410 | scm_repo = repo.scm_instance_no_cache() |
|
410 | scm_repo = repo.scm_instance_no_cache() |
@@ -538,16 +538,13 b' def get_server_url(environ):' | |||||
538 | return req.host_url + req.script_name |
|
538 | return req.host_url + req.script_name | |
539 |
|
539 | |||
540 |
|
540 | |||
541 |
def _extract_extras( |
|
541 | def _extract_extras(): | |
542 | """ |
|
542 | """ | |
543 | Extracts the Kallithea extras data from os.environ, and wraps it into named |
|
543 | Extracts the Kallithea extras data from os.environ, and wraps it into named | |
544 | AttributeDict object |
|
544 | AttributeDict object | |
545 | """ |
|
545 | """ | |
546 | if not env: |
|
|||
547 | env = os.environ |
|
|||
548 |
|
||||
549 | try: |
|
546 | try: | |
550 | extras = json.loads(env['KALLITHEA_EXTRAS']) |
|
547 | extras = json.loads(os.environ['KALLITHEA_EXTRAS']) | |
551 | except KeyError: |
|
548 | except KeyError: | |
552 | raise Exception("Environment variable KALLITHEA_EXTRAS not found") |
|
549 | raise Exception("Environment variable KALLITHEA_EXTRAS not found") | |
553 |
|
550 |
General Comments 0
You need to be logged in to leave comments.
Login now