@@ -66,47 +66,53 @@ def _dlhook(*args, **kwargs):
:param group_id:
:param deleted_by:
:param deleted_on:
"""
return 0
DELETE_REPO_HOOK = _dlhook
#==============================================================================
# POST PUSH HOOK
# this function will be executed after each push it's runned after the build-in
# hook that rhodecode uses for logging pushes
# this function will be executed after each push it's executed after the
# build-in hook that RhodeCode uses for logging pushes
def _pushhook(*args, **kwargs):
Post push hook
kwargs available:
:param server_url: url of instance that triggered this hook
:param config: path to .ini config used
:param scm: type of VS 'git' or 'hg'
:param username: name of user who pushed
:param ip: ip of who pushed
:param action: pull
:param action: push
:param repository: repository name
:param pushed_revs: generator of pushed revisions
:param pushed_revs: list of pushed revisions
PUSH_HOOK = _pushhook
# POST PULL HOOK
# build-in hook that RhodeCode uses for logging pulls
def _pullhook(*args, **kwargs):
Post pull hook
kwargs available::
:param username: name of user who pulled
:param ip: ip of who pulled
PULL_HOOK = _pullhook
@@ -70,25 +70,25 @@ dulserver.DEFAULT_HANDLERS = {
#git-push
'git-receive-pack': dulserver.ReceivePackHandler,
}
# not used for now until dulwich get's fixed
#from dulwich.repo import Repo
#from dulwich.web import make_wsgi_chain
from paste.httpheaders import REMOTE_USER, AUTH_TYPE
from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \
HTTPBadRequest, HTTPNotAcceptable
from rhodecode.lib.utils2 import safe_str, fix_PATH
from rhodecode.lib.utils2 import safe_str, fix_PATH, get_server_url
from rhodecode.lib.base import BaseVCSController
from rhodecode.lib.auth import get_container_username
from rhodecode.lib.utils import is_valid_repo, make_ui
from rhodecode.lib.compat import json
from rhodecode.model.db import User, RhodeCodeUi
log = logging.getLogger(__name__)
GIT_PROTO_PAT = re.compile(r'^/(.+)/(info/refs|git-upload-pack|git-receive-pack)')
@@ -180,31 +180,33 @@ class SimpleGit(BaseVCSController):
except:
log.error(traceback.format_exc())
return HTTPInternalServerError()(environ, start_response)
#check permissions for this repository
perm = self._check_permission(action, user, repo_name)
if perm is not True:
return HTTPForbidden()(environ, start_response)
# extras are injected into UI object and later available
# in hooks executed by rhodecode
from rhodecode import CONFIG
server_url = get_server_url(environ)
extras = {
'ip': ipaddr,
'username': username,
'action': action,
'repository': repo_name,
'scm': 'git',
'config': CONFIG['__file__'],
'server_url': server_url,
'make_lock': None,
'locked_by': [None, None]
#===================================================================
# GIT REQUEST HANDLING
repo_path = os.path.join(safe_str(self.basepath), safe_str(repo_name))
log.debug('Repository path is %s' % repo_path)
# CHECK LOCKING only if it's not ANONYMOUS USER
if username != User.DEFAULT_USER:
@@ -26,25 +26,25 @@
import os
import logging
import traceback
from mercurial.error import RepoError
from mercurial.hgweb import hgweb_mod
from rhodecode.lib.utils import make_ui, is_valid_repo, ui_sections
from rhodecode.model.db import User
from rhodecode.lib.exceptions import HTTPLockedRC
def is_mercurial(environ):
@@ -143,31 +143,33 @@ class SimpleHg(BaseVCSController):
# extras are injected into mercurial UI object and later available
# in hg hooks executed by rhodecode
'scm': 'hg',
#======================================================================
# MERCURIAL REQUEST HANDLING
log.debug('Checking locking on repository')
@@ -17,24 +17,26 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import time
import datetime
import webob
from pylons.i18n.translation import _, ungettext
from rhodecode.lib.vcs.utils.lazy import LazyProperty
def __get_lem():
Get language extension map based on what's inside pygments lexers
from pygments import lexers
from string import lower
from collections import defaultdict
@@ -507,12 +509,17 @@ def fix_PATH(os_=None):
cur_path = os.path.split(sys.executable)[0]
if not os.environ['PATH'].startswith(cur_path):
os.environ['PATH'] = '%s:%s' % (cur_path, os.environ['PATH'])
def obfuscate_url_pw(engine):
from sqlalchemy.engine import url
url = url.make_url(engine)
if url.password:
url.password = 'XXXXX'
return str(url)
def get_server_url(environ):
req = webob.Request(environ)
return req.host_url + req.script_name
Status change: