Changeset - c9f97be1927e
[Not reviewed]
default
0 1 0
Andrew Shadura - 9 years ago 2016-07-12 21:47:14
andrew@shadura.me
pygrack: refactor _get_fixedpath

This function strips the repository name and any slashes from the
URL path, leaving the protocol command, like info/refs or
git-{receive,upload}-pack.

Using .split() and .strip() for this purpose isn't entirely reliable
and is entirely unreadable, so it's better to write it out, even if
it's a bit verbose.

Also, error out in the unlikely case the path doesn't start with
a slash and the repository name; that shouldn't happen normally.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/middleware/pygrack.py
Show inline comments
 
@@ -86,7 +86,8 @@ class GitRepository(object):
 

	
 
        :param path:
 
        """
 
        return path.split(self.repo_name, 1)[-1].strip('/')
 
        assert path.startswith('/' + self.repo_name + '/')
 
        return path[len(self.repo_name) + 2:].strip('/')
 

	
 
    def inforefs(self, request, environ):
 
        """
0 comments (0 inline, 0 general)