[git] Add a user-agent to git clone (#487)

Following #474, also use the endoflife.date user agent when cloning git repositories.
This commit is contained in:
Nemo
2025-08-05 16:22:14 +05:30
committed by Marc Wrobel
parent 648ad62966
commit 44bee91053

View File

@@ -3,6 +3,8 @@ from hashlib import sha1
from pathlib import Path
from subprocess import run
from . import http
class Git:
"""Git cli wrapper
@@ -39,6 +41,7 @@ class Git:
"""Fetch and return tags matching the given`pattern`"""
# See https://stackoverflow.com/a/65746233/374236
self._run("config --local extensions.partialClone true")
self._run(f"config --local http.userAgent '{http.ENDOFLIFE_BOT_USER_AGENT}'")
# Using --force to avoid error like "would clobber existing tag".
# See https://stackoverflow.com/questions/58031165/how-to-get-rid-of-would-clobber-existing-tag.
self._run("fetch --force --tags --filter=blob:none --depth=1 origin")