diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index 1fc464a2b..b4d559c8e 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -43,7 +43,7 @@ def get_best_candidate_tag(self, rev: str, git_repo: str) -> str: 'git', *git.NO_FS_MONITOR, 'tag', '--points-at', rev, cwd=git_repo, )[1].split() for tag in tags: - if '.' in tag and re.match(r'^[a-zA-Z0-9.]+$', tag): + if '.' in tag: return tag return rev @@ -70,7 +70,8 @@ def update(self, tags_only: bool, freeze: bool) -> RevInfo: try: rev = cmd_output(*tag_cmd, cwd=tmp)[1].strip() - rev = self.get_best_candidate_tag(rev, tmp) + if tags_only: + rev = self.get_best_candidate_tag(rev, tmp) except CalledProcessError: cmd = (*git_cmd, 'rev-parse', 'FETCH_HEAD') rev = cmd_output(*cmd, cwd=tmp)[1].strip()