Update file from git index and write it to a temporary file. Query the compare target's object id from git, if the compare target is not a specific hash already. Then read the file from git index only, if the commit has changed since last call. If the commit is still the
(self)
| 293 | self._git_env = None |
| 294 | |
| 295 | def update_git_file(self): |
| 296 | """Update file from git index and write it to a temporary file. |
| 297 | |
| 298 | Query the compare target's object id from git, if the compare target |
| 299 | is not a specific hash already. Then read the file from git index only, |
| 300 | if the commit has changed since last call. If the commit is still the |
| 301 | same the file did not change, too and reading it would waste resources. |
| 302 | |
| 303 | Returns: |
| 304 | Promise resolved with True if the temporary file was updated. |
| 305 | """ |
| 306 | # Always resolve with False if temporary file is marked up to date. |
| 307 | if self._git_temp_file_valid: |
| 308 | return Promise.resolve(False) |
| 309 | self._git_temp_file_valid = True |
| 310 | |
| 311 | # Read commit hash from git if compare target is a reference. |
| 312 | refs = self.get_compare_against() |
| 313 | if 'HEAD' in refs or '/' in refs: |
| 314 | return self.git_compare_commit(refs).then(self._update_from_commit) |
| 315 | return self._update_from_commit(refs) |
| 316 | |
| 317 | def _update_from_commit(self, compared_id): |
| 318 | """Update git file from commit, if the commit id changed. |
no test coverage detected