From 34166dbd71a1d2320296761594e976eced50931a Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 15 Feb 2023 14:50:14 -0800 Subject: [PATCH] Add more context to "git fetch" failures This makes it a lot easier to see/debug what's going wrong: ```console $ BASHBREW_CACHE=/tmp/foo bashbrew fetch --arch-filter ubuntu:bionic failed fetching git repo for "ubuntu" (tags "18.04, bionic-20230126, bionic" on arch "amd64") failed fetching "f127810992c0981574cc137b9c83937ca1a304dc:refs/remotes/temp3848952252/temp": server does not support exact SHA1 refspec failed finding Git commit "f127810992c0981574cc137b9c83937ca1a304dc" after fetching "refs/tags/dist-bionic-amd64-20230126:refs/remotes/temp3848952252/temp": object not found ``` --- cmd/bashbrew/git.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/bashbrew/git.go b/cmd/bashbrew/git.go index 74b3477..2158228 100644 --- a/cmd/bashbrew/git.go +++ b/cmd/bashbrew/git.go @@ -254,13 +254,14 @@ func (r Repo) fetchGitRepo(arch string, entry *manifest.Manifest2822Entry) (stri //Progress: os.Stdout, }) if err != nil { - fetchErrors = append(fetchErrors, err) + fetchErrors = append(fetchErrors, fmt.Errorf("failed fetching %q: %w", fetchString, err)) continue } - commit, err = getGitCommit(entry.ArchGitCommit(arch)) + archCommit := entry.ArchGitCommit(arch) + commit, err = getGitCommit(archCommit) if err != nil { - fetchErrors = append(fetchErrors, err) + fetchErrors = append(fetchErrors, fmt.Errorf("failed finding Git commit %q after fetching %q: %w", archCommit, fetchString, err)) continue }