def update(self, tags_only: bool, freeze: bool) -> 'RevInfo': if tags_only: tag_cmd = ('git', 'describe', 'FETCH_HEAD', '--tags', '--abbrev=0') else: tag_cmd = ('git', 'describe', 'FETCH_HEAD', '--tags', '--exact') with tmpdir() as tmp: git.init_repo(tmp, self.repo) cmd_output_b('git', 'fetch', 'origin', 'HEAD', '--tags', cwd=tmp) try: rev = cmd_output(*tag_cmd, cwd=tmp)[1].strip() except CalledProcessError: cmd = ('git', 'rev-parse', 'FETCH_HEAD') rev = cmd_output(*cmd, cwd=tmp)[1].strip() frozen = None if freeze: exact = cmd_output('git', 'rev-parse', rev, cwd=tmp)[1].strip() if exact != rev: rev, frozen = exact, rev return self._replace(rev=rev, frozen=frozen)
def test_init_repo_no_hooks(tmpdir): git.init_repo(str(tmpdir), remote='dne') assert not tmpdir.join('.git/hooks').exists()