Mercurial > kallithea
annotate rhodecode/config/post_receive_tmpl.py @ 3877:5070c840dc23 beta
Use lower level API from mercurial when doing a pull
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 20 May 2013 02:24:16 +0200 |
parents | c0ec29b20eb6 |
children | a5888ca796b5 |
rev | line source |
---|---|
2402
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 import os |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 import sys |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 try: |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 import rhodecode |
2617
c0ec29b20eb6
Fixed githooks for fetching multiple tags and branches.
Marcin Kuzminski <marcin@python-works.com>
parents:
2411
diff
changeset
|
7 RC_HOOK_VER = '_TMPL_' |
c0ec29b20eb6
Fixed githooks for fetching multiple tags and branches.
Marcin Kuzminski <marcin@python-works.com>
parents:
2411
diff
changeset
|
8 os.environ['RC_HOOK_VER'] = RC_HOOK_VER |
2402
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 from rhodecode.lib.hooks import handle_git_post_receive |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 except ImportError: |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 rhodecode = None |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 def main(): |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 if rhodecode is None: |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # exit with success if we cannot import rhodecode !! |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # this allows simply push to this repo even without |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # rhodecode |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 sys.exit(0) |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 |
2409
761e00380370
whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2404
diff
changeset
|
21 repo_path = os.path.abspath('.') |
2617
c0ec29b20eb6
Fixed githooks for fetching multiple tags and branches.
Marcin Kuzminski <marcin@python-works.com>
parents:
2411
diff
changeset
|
22 push_data = sys.stdin.readlines() |
2402
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # os.environ is modified here by a subprocess call that |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # runs git and later git executes this hook. |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 # Environ get's some additional info from rhodecode system |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 # like IP or username from basic-auth |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 handle_git_post_receive(repo_path, push_data, os.environ) |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 sys.exit(0) |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
2eeb2ed72e55
Added handling of git hooks, extract pushed revisions and store them inside
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 if __name__ == '__main__': |
2409
761e00380370
whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2404
diff
changeset
|
31 main() |