os.environ['GIT_COMMITTER_EMAIL'] = 'test_git_cache@example.com'
os.environ['BACKOFF_MAX_TIME'] = '0'
+ os.environ['FORCE_WARNING_TIME'] = '0' # ONLY FOR TEST USE!
self.tempdir = tempfile.TemporaryDirectory(prefix='git_cache_test-')
self.upstream = os.path.join(self.tempdir.name, 'upstream')
- subprocess.run(['git', 'init', self.upstream], check=True)
+ subprocess.run(['git', '-c', 'init.defaultBranch=master',
+ 'init', self.upstream], check=True)
_commit_file(self.upstream, 'file', 'Contents', 'First commit')
def tearDown(self) -> None:
with self.assertRaises(Exception):
git_cache.ensure_rev_available(self.upstream, 'master', rev)
+ def test_force_fetch_after_amend(self) -> None:
+ git_cache.fetch(self.upstream, 'master')
+ _git(self.upstream, 'commit', '--amend', '-m', 'Amended')
+ git_cache.fetch(self.upstream, 'master', force=True)
+
+ def test_force_ensure_after_amend(self) -> None:
+ git_cache.fetch(self.upstream, 'master')
+ _git(self.upstream, 'commit', '--amend', '-m', 'Amended')
+ rev = _git(self.upstream, 'log', '--format=%H', '-n1').strip().decode()
+ git_cache.ensure_rev_available(
+ self.upstream, 'master', rev, force=True)
+
+ def test_force_fetch_after_amend_and_cache_delete(self) -> None:
+ d, _ = git_cache.fetch(self.upstream, 'master')
+ shutil.rmtree(d)
+ _git(self.upstream, 'commit', '--amend', '-m', 'Amended')
+ git_cache.fetch(self.upstream, 'master', force=True)
+
+ def test_force_ensure_after_amend_and_cache_delete(self) -> None:
+ d, _ = git_cache.fetch(self.upstream, 'master')
+ shutil.rmtree(d)
+ _git(self.upstream, 'commit', '--amend', '-m', 'Amended')
+ rev = _git(self.upstream, 'log', '--format=%H', '-n1').strip().decode()
+ git_cache.ensure_rev_available(
+ self.upstream, 'master', rev, force=True)
+
if __name__ == '__main__':
unittest.main()