##// END OF EJS Templates
git: fix git hook template mention of what hooks we actually execute....
marcink -
r2388:0df6dc22 default
parent child Browse files
Show More
@@ -1,46 +1,46 b''
1 #!_ENV_
1 #!_ENV_
2 import os
2 import os
3 import sys
3 import sys
4
4
5 try:
5 try:
6 from vcsserver import hooks
6 from vcsserver import hooks
7 except ImportError:
7 except ImportError:
8 if os.environ.get('RC_DEBUG_GIT_HOOK'):
8 if os.environ.get('RC_DEBUG_GIT_HOOK'):
9 import traceback
9 import traceback
10 print traceback.format_exc()
10 print traceback.format_exc()
11 hooks = None
11 hooks = None
12
12
13
13
14 RC_HOOK_VER = '_TMPL_'
14 RC_HOOK_VER = '_TMPL_'
15
15
16
16
17 def main():
17 def main():
18 if hooks is None:
18 if hooks is None:
19 # exit with success if we cannot import rhodecode.lib.hooks !!
19 # exit with success if we cannot import vcsserver.hooks !!
20 # this allows simply push to this repo even without rhodecode
20 # this allows simply push to this repo even without rhodecode
21 sys.exit(0)
21 sys.exit(0)
22
22
23 if os.environ.get('RC_SKIP_HOOKS'):
23 if os.environ.get('RC_SKIP_HOOKS'):
24 sys.exit(0)
24 sys.exit(0)
25
25
26 repo_path = os.getcwd()
26 repo_path = os.getcwd()
27 push_data = sys.stdin.readlines()
27 push_data = sys.stdin.readlines()
28 os.environ['RC_HOOK_VER'] = RC_HOOK_VER
28 os.environ['RC_HOOK_VER'] = RC_HOOK_VER
29 # os.environ is modified here by a subprocess call that
29 # os.environ is modified here by a subprocess call that
30 # runs git and later git executes this hook.
30 # runs git and later git executes this hook.
31 # Environ gets some additional info from rhodecode system
31 # Environ gets some additional info from rhodecode system
32 # like IP or username from basic-auth
32 # like IP or username from basic-auth
33 try:
33 try:
34 result = hooks.git_post_receive(repo_path, push_data, os.environ)
34 result = hooks.git_post_receive(repo_path, push_data, os.environ)
35 sys.exit(result)
35 sys.exit(result)
36 except Exception as error:
36 except Exception as error:
37 # TODO: johbo: Improve handling of this special case
37 # TODO: johbo: Improve handling of this special case
38 if not getattr(error, '_vcs_kind', None) == 'repo_locked':
38 if not getattr(error, '_vcs_kind', None) == 'repo_locked':
39 raise
39 raise
40 print 'ERROR:', error
40 print 'ERROR:', error
41 sys.exit(1)
41 sys.exit(1)
42 sys.exit(0)
42 sys.exit(0)
43
43
44
44
45 if __name__ == '__main__':
45 if __name__ == '__main__':
46 main()
46 main()
@@ -1,46 +1,46 b''
1 #!_ENV_
1 #!_ENV_
2 import os
2 import os
3 import sys
3 import sys
4
4
5 try:
5 try:
6 from vcsserver import hooks
6 from vcsserver import hooks
7 except ImportError:
7 except ImportError:
8 if os.environ.get('RC_DEBUG_GIT_HOOK'):
8 if os.environ.get('RC_DEBUG_GIT_HOOK'):
9 import traceback
9 import traceback
10 print traceback.format_exc()
10 print traceback.format_exc()
11 hooks = None
11 hooks = None
12
12
13
13
14 RC_HOOK_VER = '_TMPL_'
14 RC_HOOK_VER = '_TMPL_'
15
15
16
16
17 def main():
17 def main():
18 if hooks is None:
18 if hooks is None:
19 # exit with success if we cannot import rhodecode.lib.hooks !!
19 # exit with success if we cannot import vcsserver.hooks !!
20 # this allows simply push to this repo even without rhodecode
20 # this allows simply push to this repo even without rhodecode
21 sys.exit(0)
21 sys.exit(0)
22
22
23 if os.environ.get('RC_SKIP_HOOKS'):
23 if os.environ.get('RC_SKIP_HOOKS'):
24 sys.exit(0)
24 sys.exit(0)
25
25
26 repo_path = os.getcwd()
26 repo_path = os.getcwd()
27 push_data = sys.stdin.readlines()
27 push_data = sys.stdin.readlines()
28 os.environ['RC_HOOK_VER'] = RC_HOOK_VER
28 os.environ['RC_HOOK_VER'] = RC_HOOK_VER
29 # os.environ is modified here by a subprocess call that
29 # os.environ is modified here by a subprocess call that
30 # runs git and later git executes this hook.
30 # runs git and later git executes this hook.
31 # Environ gets some additional info from rhodecode system
31 # Environ gets some additional info from rhodecode system
32 # like IP or username from basic-auth
32 # like IP or username from basic-auth
33 try:
33 try:
34 result = hooks.git_pre_receive(repo_path, push_data, os.environ)
34 result = hooks.git_pre_receive(repo_path, push_data, os.environ)
35 sys.exit(result)
35 sys.exit(result)
36 except Exception as error:
36 except Exception as error:
37 # TODO: johbo: Improve handling of this special case
37 # TODO: johbo: Improve handling of this special case
38 if not getattr(error, '_vcs_kind', None) == 'repo_locked':
38 if not getattr(error, '_vcs_kind', None) == 'repo_locked':
39 raise
39 raise
40 print 'ERROR:', error
40 print 'ERROR:', error
41 sys.exit(1)
41 sys.exit(1)
42 sys.exit(0)
42 sys.exit(0)
43
43
44
44
45 if __name__ == '__main__':
45 if __name__ == '__main__':
46 main()
46 main()
General Comments 0
You need to be logged in to leave comments. Login now