##// END OF EJS Templates
feat(disk-cache): rewrite diskcache backend to be k8s and NFS safe....
feat(disk-cache): rewrite diskcache backend to be k8s and NFS safe. We no longer use diskcache lib, but instead a homebrew solution that uses redis lock and simple filesystem storage

File last commit:

r1077:8dff4d0f python3
r1241:29c2a6b0 default
Show More
git_post_receive.py.tmpl
51 lines | 1.3 KiB | application/x-cheetah | CheetahLexer
#!_ENV_
import os
import sys
path_adjust = [_PATH_]
if path_adjust:
sys.path = path_adjust
try:
from vcsserver import hooks
except ImportError:
if os.environ.get('RC_DEBUG_GIT_HOOK'):
import traceback
print(traceback.format_exc())
hooks = None
# TIMESTAMP: _DATE_
RC_HOOK_VER = '_TMPL_'
def main():
if hooks is None:
# exit with success if we cannot import vcsserver.hooks !!
# this allows simply push to this repo even without rhodecode
sys.exit(0)
if os.environ.get('RC_SKIP_HOOKS') or os.environ.get('RC_SKIP_GIT_HOOKS'):
sys.exit(0)
repo_path = os.getcwd()
push_data = sys.stdin.readlines()
os.environ['RC_HOOK_VER'] = RC_HOOK_VER
# os.environ is modified here by a subprocess call that
# runs git and later git executes this hook.
# Environ gets some additional info from rhodecode system
# like IP or username from basic-auth
try:
result = hooks.git_post_receive(repo_path, push_data, os.environ)
sys.exit(result)
except Exception as error:
# TODO: johbo: Improve handling of this special case
if not getattr(error, '_vcs_kind', None) == 'repo_locked':
raise
print(f'ERROR: {error}')
sys.exit(1)
sys.exit(0)
if __name__ == '__main__':
main()