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