diff options
| author | Jesse Hall <jessehall@google.com> | 2013-11-27 11:17:13 -0800 |
|---|---|---|
| committer | Jesse Hall <jessehall@google.com> | 2013-12-03 09:02:16 -0800 |
| commit | 672cc499b9dce9c18ecd9dfc81fd18094535dc49 (patch) | |
| tree | fabd598df21d7062baec16bf66a1fca505a968f7 | |
| parent | 4534120628a8e3a7f82063757bbcb02107dd14d8 (diff) | |
| download | git-repo-672cc499b9dce9c18ecd9dfc81fd18094535dc49.tar.gz | |
Canonicalize project hooks path before use
If the top-level .repo directory is moved somewhere else (e.g. a
different drive) and replaced with a symlink, _InitHooks() will create
broken symlinks. Resolving symlinks before computing the relative path
for the symlink keeps the path within the repo tree, so the tree can
be moved anywhere.
Change-Id: Ifa5c07869e3477186ddd2c255c6c607f547bc1fe
| -rw-r--r-- | project.py | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -82,7 +82,7 @@ def _ProjectHooks(): | |||
| 82 | """ | 82 | """ |
| 83 | global _project_hook_list | 83 | global _project_hook_list |
| 84 | if _project_hook_list is None: | 84 | if _project_hook_list is None: |
| 85 | d = os.path.abspath(os.path.dirname(__file__)) | 85 | d = os.path.realpath(os.path.abspath(os.path.dirname(__file__))) |
| 86 | d = os.path.join(d , 'hooks') | 86 | d = os.path.join(d , 'hooks') |
| 87 | _project_hook_list = [os.path.join(d, x) for x in os.listdir(d)] | 87 | _project_hook_list = [os.path.join(d, x) for x in os.listdir(d)] |
| 88 | return _project_hook_list | 88 | return _project_hook_list |
| @@ -1955,7 +1955,7 @@ class Project(object): | |||
| 1955 | self._InitHooks() | 1955 | self._InitHooks() |
| 1956 | 1956 | ||
| 1957 | def _InitHooks(self): | 1957 | def _InitHooks(self): |
| 1958 | hooks = self._gitdir_path('hooks') | 1958 | hooks = os.path.realpath(self._gitdir_path('hooks')) |
| 1959 | if not os.path.exists(hooks): | 1959 | if not os.path.exists(hooks): |
| 1960 | os.makedirs(hooks) | 1960 | os.makedirs(hooks) |
| 1961 | for stock_hook in _ProjectHooks(): | 1961 | for stock_hook in _ProjectHooks(): |
