best-effort fetch tag for HEAD in shallow clone

This commit is contained in:
gnought 2026-02-14 21:49:34 +08:00
parent da180668ab
commit 55f9ae755e
No known key found for this signature in database
GPG key ID: 04D7C0864CCDDF10

View file

@ -186,6 +186,7 @@ class Store:
git_config = 'protocol.version=2' git_config = 'protocol.version=2'
git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1') git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1')
git_cmd('-c', git_config, 'fetch', 'origin', f'refs/tags/{ref}:refs/tags/{ref}', '--depth=1', check=False)
git_cmd('checkout', 'FETCH_HEAD') git_cmd('checkout', 'FETCH_HEAD')
git_cmd( git_cmd(
'-c', git_config, 'submodule', 'update', '--init', '--recursive', '-c', git_config, 'submodule', 'update', '--init', '--recursive',
@ -199,8 +200,8 @@ class Store:
git.init_repo(directory, repo) git.init_repo(directory, repo)
env = git.no_git_env() env = git.no_git_env()
def _git_cmd(*args: str) -> None: def _git_cmd(*args: str, check=True) -> None:
cmd_output_b('git', *args, cwd=directory, env=env) cmd_output_b('git', *args, cwd=directory, env=env, check=check)
try: try:
self._shallow_clone(ref, _git_cmd) self._shallow_clone(ref, _git_cmd)