Show More
1 | NO CONTENT: file renamed from rhodecode/config/pre-receive.tmpl to rhodecode/config/pre_receive_tmpl.py |
|
NO CONTENT: file renamed from rhodecode/config/pre-receive.tmpl to rhodecode/config/pre_receive_tmpl.py |
@@ -33,6 +33,7 b' from mercurial.node import nullrev' | |||||
33 | from rhodecode import EXTENSIONS |
|
33 | from rhodecode import EXTENSIONS | |
34 | from rhodecode.lib import helpers as h |
|
34 | from rhodecode.lib import helpers as h | |
35 | from rhodecode.lib.utils import action_logger |
|
35 | from rhodecode.lib.utils import action_logger | |
|
36 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |||
36 |
|
37 | |||
37 |
|
38 | |||
38 | def _get_scm_size(alias, root_path): |
|
39 | def _get_scm_size(alias, root_path): | |
@@ -242,9 +243,14 b' def handle_git_post_receive(repo_path, r' | |||||
242 | baseui.setconfig('rhodecode_extras', k, v) |
|
243 | baseui.setconfig('rhodecode_extras', k, v) | |
243 | repo = repo.scm_instance |
|
244 | repo = repo.scm_instance | |
244 | repo.ui = baseui |
|
245 | repo.ui = baseui | |
245 |
old_rev, new_rev = revs |
|
246 | old_rev, new_rev, ref = revs | |
246 |
|
247 | if old_rev == EmptyChangeset().raw_id: | ||
247 | cmd = 'log ' + old_rev + '..' + new_rev + ' --reverse --pretty=format:"%H"' |
|
248 | cmd = "for-each-ref --format='%(refname)' 'refs/heads/*'" | |
|
249 | heads = repo.run_git_command(cmd)[0] | |||
|
250 | heads = heads.replace(ref, '') | |||
|
251 | cmd = 'log ' + new_rev + ' --reverse --pretty=format:"%H" --not ' + heads | |||
|
252 | else: | |||
|
253 | cmd = 'log ' + old_rev + '..' + new_rev + ' --reverse --pretty=format:"%H"' | |||
248 | git_revs = repo.run_git_command(cmd)[0].splitlines() |
|
254 | git_revs = repo.run_git_command(cmd)[0].splitlines() | |
249 |
|
255 | |||
250 | log_push_action(baseui, repo, _git_revs=git_revs) |
|
256 | log_push_action(baseui, repo, _git_revs=git_revs) |
@@ -22,10 +22,13 b'' | |||||
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
|
25 | from __future__ import with_statement | |||
25 | import os |
|
26 | import os | |
26 | import shutil |
|
27 | import shutil | |
27 | import logging |
|
28 | import logging | |
28 | import traceback |
|
29 | import traceback | |
|
30 | import pkg_resources | |||
|
31 | from os.path import dirname as dn, join as jn | |||
29 | from datetime import datetime |
|
32 | from datetime import datetime | |
30 |
|
33 | |||
31 | from rhodecode.lib.vcs.backends import get_backend |
|
34 | from rhodecode.lib.vcs.backends import get_backend | |
@@ -461,7 +464,23 b' class RepoModel(BaseModel):' | |||||
461 | if alias == 'hg': |
|
464 | if alias == 'hg': | |
462 | backend(repo_path, create=True, src_url=clone_uri) |
|
465 | backend(repo_path, create=True, src_url=clone_uri) | |
463 | elif alias == 'git': |
|
466 | elif alias == 'git': | |
464 | backend(repo_path, create=True, src_url=clone_uri, bare=True) |
|
467 | r = backend(repo_path, create=True, src_url=clone_uri, bare=True) | |
|
468 | # add rhodecode hook into this repo | |||
|
469 | ||||
|
470 | loc = jn(r.path, 'hooks') | |||
|
471 | if not r.bare: | |||
|
472 | loc = jn(r.path, '.git', 'hooks') | |||
|
473 | if not os.path.isdir(loc): | |||
|
474 | os.makedirs(loc) | |||
|
475 | ||||
|
476 | tmpl = pkg_resources.resource_string( | |||
|
477 | 'rhodecode', jn('config', 'pre_receive_tmpl.py') | |||
|
478 | ) | |||
|
479 | _hook_file = jn(loc, 'pre-receive') | |||
|
480 | with open(_hook_file, 'wb') as f: | |||
|
481 | f.write(tmpl) | |||
|
482 | os.chmod(_hook_file, 0555) | |||
|
483 | ||||
465 | else: |
|
484 | else: | |
466 | raise Exception('Undefined alias %s' % alias) |
|
485 | raise Exception('Undefined alias %s' % alias) | |
467 |
|
486 |
General Comments 0
You need to be logged in to leave comments.
Login now