feature: fetch tag pointing to HEAD in shallow clone#3617
feature: fetch tag pointing to HEAD in shallow clone#3617gnought wants to merge 3 commits intopre-commit:mainfrom
Conversation
|
unless you can make this happen in a single fetch I can't accept this. I've tried but have been unable to get the right refspec as written this invokes 3 remote operations which from some local testing is often slower than the full clone which defeats the entire purpose of shallow fetching in the first place |
|
@asottile Thank you for your feedback. I understand that there is no simple way to fetch a single remote tag efficiently. For repositories that require version metadata, and where most Although the |
| git_config = 'protocol.version=2' | ||
| git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1') | ||
| git_cmd('checkout', 'FETCH_HEAD') | ||
| git_cmd('tag', '-a', '-m', '""', ref, 'FETCH_HEAD') |
There was a problem hiding this comment.
I don't think this is good either. this will tag non-tags (and invoke signing mechanisms)
There was a problem hiding this comment.
Yes, this will tag non-tag revisions but limit to local. As long as pre-commit does not push changes, this will not affect the remote or introduce signing issues.
There was a problem hiding this comment.
-m invokes signing. and if this tags things differently than the actual repo that's not ok
There was a problem hiding this comment.
My understanding is that -m does not trigger signing unless -s is used.
git does not provide a direct way to fetch a specific tag at a particular commit. The only single-command option is to use --tags with git fetch, but that would retrieve all tags and be slower than creating a fake local tag.
What do you think about the 3rd proposal on git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1', '--tags') ?
There was a problem hiding this comment.
your understanding is slightly wrong. and no --tags will not work that will fetch a bunch of unnecessary stuff
pre-commitshallow clones do not fetch tags, which leads to errors when a repository depends on tag metadata (see golangci/golangci-lint#6347).This PR adds logic to resolve and fetch the remote tag associated with FETCH_HEAD when present.