-
-
Notifications
You must be signed in to change notification settings - Fork 932
Description
describe your issue
I got an autoupdate PR from pre-commit.ci at https://github.com/mblayman/atlas/pull/29/files
The autoupdate is trying to update the luacheck hook from v0.26.0 to latest. This is not ideal because latest is a moving target while v0.26.0 is fixed.
As of this writing, luacheck has three tags on the latest tagged release:

I inspected the autoupdate command and found the source of this issue at
pre-commit/pre_commit/commands/autoupdate.py
Lines 40 to 43 in db44ad3
| tag_cmd = ( | |
| *git_cmd, 'describe', | |
| 'FETCH_HEAD', '--tags', '--abbrev=0', | |
| ) |
autoupdate basically runs git describe FETCH_HEAD --tags --abbrev=0. In the case of the luacheck repo, this returns latest.
➜ luacheck git:(master) git describe FETCH_HEAD --tags --abbrev=0
latestI was able to replicate the behavior of this command in the pre-commit repo itself by adding a latest tag to the same SHA as v2.17.0.
git tag latest d3bdf1403d92f8cf2dc77bd99a5da42f0a6cef17
git describe --tags FETCH_HEAD --abbrev=0
latestWhile git describe FETCH_HEAD --tags --abbrev=0 is elegant in its simplicity, it can only return a single tag, so it's limited in this multiple tags case.
Possible solution
pre-commit could look for the latest tag, then check to see if there are multiple tags on that SHA. If so, a tag could be preferred if it looks more "version-y." Maybe that's a semver style regex or something like that.
One of the tricks, I think, is to figure out how to check for multiple tags. I think the simplest way would be to get the output from tag_cmd and run that through git tag --points-at <tag_cmd output>. If there are multiple lines, then the version checking kind of stuff could occur.
Before trying this out, I wanted to check if this seems like a reasonable path or if there are other preferential ways to tackle this kind of thing.
pre-commit --version
pre-commit 2.17.0
.pre-commit-config.yaml
ci:
# The compilation time is too long so CI hits a timeout.
skip: [luaformatter]
repos:
- repo: https://github.com/lunarmodules/luacheck
rev: "v0.26.0"
hooks:
- id: luacheck
- repo: https://github.com/mblayman/LuaFormatter
rev: "ad94bea01ca027ca46541af727e15d002aa5ce74"
hooks:
- id: luaformatter~/.cache/pre-commit/pre-commit.log (if present)
No response