Mercurial > kallithea
changeset 6008:bcb807305731
db: ensure git hooks work when the repositories base path is a symlink
When a Git hook starts, it thinks its repo_path is its cwd.
However, if the repositories base path is a symlink to a different
location, base path won't match the location of the repository
where the symlink will be resolved.
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Thu, 14 Jul 2016 14:47:38 +0200 |
parents | 1e373254388c |
children | e54ddaa52fee |
files | kallithea/model/db.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/db.py Thu Jul 14 14:56:20 2016 +0200 +++ b/kallithea/model/db.py Thu Jul 14 14:47:38 2016 +0200 @@ -1096,7 +1096,10 @@ @classmethod def get_by_full_path(cls, repo_full_path): - repo_name = repo_full_path.split(cls.base_path(), 1)[-1] + base_full_path = os.path.realpath(cls.base_path()) + repo_full_path = os.path.realpath(repo_full_path) + assert repo_full_path.startswith(base_full_path + os.path.sep) + repo_name = repo_full_path[len(base_full_path) + 1:] repo_name = cls.normalize_repo_name(repo_name) return cls.get_by_repo_name(repo_name.strip(URL_SEP))