Return the real path of a valid work-tree or None. Arguments: validate (bool): If True check whether the file is part of a valid git repository or return the cached working tree path only on False.
(self, validate=False)
| 167 | self._git_tree) if self._git_tree else '(None)' |
| 168 | |
| 169 | def work_tree(self, validate=False): |
| 170 | """Return the real path of a valid work-tree or None. |
| 171 | |
| 172 | Arguments: |
| 173 | validate (bool): If True check whether the file is part of a valid |
| 174 | git repository or return the cached working tree |
| 175 | path only on False. |
| 176 | """ |
| 177 | if validate: |
| 178 | # Check if file exists |
| 179 | file_name = path.realpath(self.view.file_name()) |
| 180 | if not file_name or not os.path.isfile(file_name): |
| 181 | self._view_file_name = None |
| 182 | self._git_tree = None |
| 183 | self._git_path = None |
| 184 | return None |
| 185 | # Check if file was renamed |
| 186 | is_renamed = file_name != self._view_file_name |
| 187 | if is_renamed or not path.is_work_tree(self._git_tree): |
| 188 | self._view_file_name = file_name |
| 189 | self._git_tree, self._git_path = path.split_work_tree(file_name) |
| 190 | self.invalidate_git_file() |
| 191 | return self._git_tree |
| 192 | |
| 193 | def work_tree_supported(self): |
| 194 | """The path of the working directory is accessible by git. |
no test coverage detected