Changeset - 5b40eb88a46d
[Not reviewed]
default
0 2 0
Søren Løvborg - 9 years ago 2017-01-04 23:05:11
sorenl@unity3d.com
vcs: remove non-sensical conditional block

__get_action can only return "pull" or "push"; any other value is an
error on our end. And indeed, if not, the old code would crash further
down in the function (under "CHECK LOCKING") because the "user" local
variable was not assigned.

This also corrects the comment that incorrectly suggests the perm check
is only relevant for anonymous access.

The relevant code is duplicated between Hg and Git... and thus also
this change.

(Diff becomes clearer if whitespace changes are ignored.)
2 files changed with 2 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -65,13 +65,12 @@ class SimpleGit(BaseVCSController):
 

	
 
    def _handle_request(self, environ, start_response):
 
        if not is_git(environ):
 
            return self.application(environ, start_response)
 

	
 
        ip_addr = self._get_ip_addr(environ)
 
        username = None
 
        self._git_first_op = False
 
        # skip passing error to error controller
 
        environ['pylons.status_code_redirect'] = True
 

	
 
        #======================================================================
 
        # EXTRACT REPOSITORY NAME FROM ENV
 
@@ -91,15 +90,14 @@ class SimpleGit(BaseVCSController):
 
        #======================================================================
 
        # GET ACTION PULL or PUSH
 
        #======================================================================
 
        action = self.__get_action(environ)
 

	
 
        #======================================================================
 
        # CHECK ANONYMOUS PERMISSION
 
        # CHECK PERMISSIONS
 
        #======================================================================
 
        if action in ['pull', 'push']:
 
            anonymous_user = User.get_default_user(cache=True)
 
            username = anonymous_user.username
 
            if anonymous_user.active:
 
                # ONLY check permissions if the user is activated
 
                anonymous_perm = self._check_permission(action, anonymous_user,
 
                                                        repo_name, ip_addr)
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -69,13 +69,12 @@ class SimpleHg(BaseVCSController):
 

	
 
    def _handle_request(self, environ, start_response):
 
        if not is_mercurial(environ):
 
            return self.application(environ, start_response)
 

	
 
        ip_addr = self._get_ip_addr(environ)
 
        username = None
 
        # skip passing error to error controller
 
        environ['pylons.status_code_redirect'] = True
 

	
 
        #======================================================================
 
        # EXTRACT REPOSITORY NAME FROM ENV
 
        #======================================================================
 
@@ -99,15 +98,14 @@ class SimpleHg(BaseVCSController):
 
        try:
 
            action = self.__get_action(environ)
 
        except HTTPBadRequest as e:
 
            return e(environ, start_response)
 

	
 
        #======================================================================
 
        # CHECK ANONYMOUS PERMISSION
 
        # CHECK PERMISSIONS
 
        #======================================================================
 
        if action in ['pull', 'push']:
 
            anonymous_user = User.get_default_user(cache=True)
 
            username = anonymous_user.username
 
            if anonymous_user.active:
 
                # ONLY check permissions if the user is activated
 
                anonymous_perm = self._check_permission(action, anonymous_user,
 
                                                        repo_name, ip_addr)
0 comments (0 inline, 0 general)