From 46012d28325bda1139f25963e632a30ad45d311b Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Wed, 9 Apr 2025 09:29:42 +0800 Subject: [PATCH] fix: git checkout with short commit hash Signed-off-by: Frost Ming --- src/unearth/vcs/git.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/unearth/vcs/git.py b/src/unearth/vcs/git.py index 4c42a82..53a2f7c 100644 --- a/src/unearth/vcs/git.py +++ b/src/unearth/vcs/git.py @@ -55,8 +55,7 @@ def fetch_new( self.run_command(["clone", *flags, url, str(location)], extra_env=env) if rev is not None: - self.run_command(["fetch", "-q", url, rev], cwd=location) - self.run_command(["checkout", "FETCH_HEAD"], cwd=location) + self.run_command(["checkout", rev], cwd=location) revision = self.get_revision(location) logger.info("Resolved %s to commit %s", url, revision) self._update_submodules(location) @@ -73,9 +72,8 @@ def update( ) -> None: self.run_command(["fetch", "-q", "--tags"], cwd=location) if rev is not None: - url = self.get_remote_url(location) - self.run_command(["fetch", "-q", url, rev], cwd=location) - resolved = self._resolve_revision(location, "FETCH_HEAD") + self.run_command(["checkout", rev], cwd=location) + resolved = self._resolve_revision(location, "HEAD") else: try: # try as if the rev is a branch name or HEAD