MCPcopy
hub / github.com/jisaacks/GitGutter / update_git_file

Method update_git_file

modules/handler.py:295–315  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

diffMethod · 0.95

Calls 5

get_compare_againstMethod · 0.95
git_compare_commitMethod · 0.95
_update_from_commitMethod · 0.95
resolveMethod · 0.80
thenMethod · 0.80

Tested by

no test coverage detected