Show More
@@ -454,6 +454,9 b' def action_parser(user_log, feed=False):' | |||
|
454 | 454 | revision=rev.raw_id), |
|
455 | 455 | title=tooltip(message(rev)), class_='tooltip') |
|
456 | 456 | ) |
|
457 | ||
|
458 | revs = [] | |
|
459 | if len(filter(lambda v: v != '', revs_ids)) > 0: | |
|
457 | 460 | # get only max revs_top_limit of changeset for performance/ui reasons |
|
458 | 461 | revs = [ |
|
459 | 462 | x for x in repo.get_changesets(revs_ids[0], |
@@ -92,6 +92,7 b' def log_pull_action(ui, repo, **kwargs):' | |||
|
92 | 92 | extras = dict(repo.ui.configitems('rhodecode_extras')) |
|
93 | 93 | username = extras['username'] |
|
94 | 94 | repository = extras['repository'] |
|
95 | scm = extras['scm'] | |
|
95 | 96 | action = 'pull' |
|
96 | 97 | |
|
97 | 98 | action_logger(username, action, repository, extras['ip'], commit=True) |
@@ -117,6 +118,9 b' def log_push_action(ui, repo, **kwargs):' | |||
|
117 | 118 | username = extras['username'] |
|
118 | 119 | repository = extras['repository'] |
|
119 | 120 | action = extras['action'] + ':%s' |
|
121 | scm = extras['scm'] | |
|
122 | ||
|
123 | if scm == 'hg': | |
|
120 | 124 | node = kwargs['node'] |
|
121 | 125 | |
|
122 | 126 | def get_revs(repo, rev_opt): |
@@ -132,6 +136,8 b' def log_push_action(ui, repo, **kwargs):' | |||
|
132 | 136 | stop, start = get_revs(repo, [node + ':']) |
|
133 | 137 | |
|
134 | 138 | revs = (str(repo[r]) for r in xrange(start, stop + 1)) |
|
139 | elif scm == 'git': | |
|
140 | revs = [] | |
|
135 | 141 | |
|
136 | 142 | action = action % ','.join(revs) |
|
137 | 143 |
@@ -74,7 +74,7 b' from paste.httpheaders import REMOTE_USE' | |||
|
74 | 74 | from rhodecode.lib.utils2 import safe_str |
|
75 | 75 | from rhodecode.lib.base import BaseVCSController |
|
76 | 76 | from rhodecode.lib.auth import get_container_username |
|
77 | from rhodecode.lib.utils import is_valid_repo | |
|
77 | from rhodecode.lib.utils import is_valid_repo, make_ui | |
|
78 | 78 | from rhodecode.model.db import User |
|
79 | 79 | |
|
80 | 80 | from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError |
@@ -103,6 +103,7 b' class SimpleGit(BaseVCSController):' | |||
|
103 | 103 | |
|
104 | 104 | ipaddr = self._get_ip_addr(environ) |
|
105 | 105 | username = None |
|
106 | self._git_first_op = False | |
|
106 | 107 | # skip passing error to error controller |
|
107 | 108 | environ['pylons.status_code_redirect'] = True |
|
108 | 109 | |
@@ -178,6 +179,13 b' class SimpleGit(BaseVCSController):' | |||
|
178 | 179 | perm = self._check_permission(action, user, repo_name) |
|
179 | 180 | if perm is not True: |
|
180 | 181 | return HTTPForbidden()(environ, start_response) |
|
182 | extras = { | |
|
183 | 'ip': ipaddr, | |
|
184 | 'username': username, | |
|
185 | 'action': action, | |
|
186 | 'repository': repo_name, | |
|
187 | 'scm': 'git', | |
|
188 | } | |
|
181 | 189 | |
|
182 | 190 | #=================================================================== |
|
183 | 191 | # GIT REQUEST HANDLING |
@@ -185,10 +193,16 b' class SimpleGit(BaseVCSController):' | |||
|
185 | 193 | repo_path = os.path.join(safe_str(self.basepath), safe_str(repo_name)) |
|
186 | 194 | log.debug('Repository path is %s' % repo_path) |
|
187 | 195 | |
|
196 | baseui = make_ui('db') | |
|
197 | for k, v in extras.items(): | |
|
198 | baseui.setconfig('rhodecode_extras', k, v) | |
|
199 | ||
|
188 | 200 | try: |
|
189 | 201 | #invalidate cache on push |
|
190 | 202 | if action == 'push': |
|
191 | 203 | self._invalidate_cache(repo_name) |
|
204 | self._handle_githooks(action, baseui, environ) | |
|
205 | ||
|
192 | 206 | log.info('%s action on GIT repo "%s"' % (action, repo_name)) |
|
193 | 207 | app = self.__make_app(repo_name, repo_path) |
|
194 | 208 | return app(environ, start_response) |
@@ -249,3 +263,25 b' class SimpleGit(BaseVCSController):' | |||
|
249 | 263 | # operation is pull/push |
|
250 | 264 | op = getattr(self, '_git_stored_op', 'pull') |
|
251 | 265 | return op |
|
266 | ||
|
267 | def _handle_githooks(self, action, baseui, environ): | |
|
268 | ||
|
269 | from rhodecode.lib.hooks import log_pull_action, log_push_action | |
|
270 | service = environ['QUERY_STRING'].split('=') | |
|
271 | if len(service) < 2: | |
|
272 | return | |
|
273 | ||
|
274 | class cont(object): | |
|
275 | pass | |
|
276 | ||
|
277 | repo = cont() | |
|
278 | setattr(repo, 'ui', baseui) | |
|
279 | ||
|
280 | push_hook = 'pretxnchangegroup.push_logger' | |
|
281 | pull_hook = 'preoutgoing.pull_logger' | |
|
282 | _hooks = dict(baseui.configitems('hooks')) or {} | |
|
283 | if action == 'push' and _hooks.get(push_hook): | |
|
284 | log_push_action(ui=baseui, repo=repo) | |
|
285 | elif action == 'pull' and _hooks.get(pull_hook): | |
|
286 | log_pull_action(ui=baseui, repo=repo) | |
|
287 |
@@ -153,7 +153,8 b' class SimpleHg(BaseVCSController):' | |||
|
153 | 153 | 'ip': ipaddr, |
|
154 | 154 | 'username': username, |
|
155 | 155 | 'action': action, |
|
156 | 'repository': repo_name | |
|
156 | 'repository': repo_name, | |
|
157 | 'scm': 'hg', | |
|
157 | 158 | } |
|
158 | 159 | |
|
159 | 160 | #====================================================================== |
General Comments 0
You need to be logged in to leave comments.
Login now