From 42db8cde4f032a9ddb5ec6239c56d2c4a41d4c63 Mon Sep 17 00:00:00 2001 From: Stephen Brown II Date: Mon, 4 Nov 2019 13:48:23 -0700 Subject: [PATCH] Fix git reference for tags to get actual latest tag --- pre_commit/commands/autoupdate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index d56a88fb..23bf37c7 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -41,7 +41,11 @@ def _update_repo(repo_config, store, tags_only): git.init_repo(repo_path, repo_config['repo']) cmd_output_b('git', 'fetch', 'origin', 'HEAD', '--tags', cwd=repo_path) - tag_cmd = ('git', 'describe', 'FETCH_HEAD', '--tags') + # Get the latest tagged commit + latest_tag_cmd = ('git', 'rev-list', '--tags', '--max-count=1') + latest_tagged = cmd_output(*latest_tag_cmd, cwd=repo_path)[1].strip() + + tag_cmd = ('git', 'describe', latest_tagged, '--tags') if tags_only: tag_cmd += ('--abbrev=0',) else: