# HG changeset patch # User Andrew Shadura # Date 2016-07-14 14:47:38 # Node ID bcb8073057313cf4151ede244b7f0b6cc0092432 # Parent 1e373254388cf67a084d39234f9b7a4548174649 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. diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -1096,7 +1096,10 @@ class Repository(Base, BaseModel): @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))