From dea73ff7835e8e79dd5472278a652f28c817599d Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Fri, 7 Oct 2022 10:10:25 -0400 Subject: [PATCH] when failing to clone a repository, include the used protocol It fits decently well in the error message, and can help people catch assumptions such as "I tried to clone a mercurial repository without hg+", which resulted in builds.sr.ht thinking it was git, and attempting to use `git clone`. The error messages from git/hg themselves are not super obvious. For `git clone` it prints: ``` fatal: repository 'https://hg.sr.ht/~username/reponame/' not found ``` For `hg clone` it prints: ``` abort: HTTP Error 404: NOT FOUND ``` Neither one makes it obvious that you attempted to clone with the wrong VCS program, and mercurial also doesn't make it obvious if you attempted to clone with the wrong url, but it's particularly non-obvious to debug the case of accidentally using git. --- worker/tasks.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worker/tasks.go b/worker/tasks.go index 5d21a92..92fb055 100644 --- a/worker/tasks.go +++ b/worker/tasks.go @@ -405,7 +405,7 @@ func (ctx *JobContext) CloneGitRepo(srcurl, repo_name, ref string) error { git.Stdout = ctx.LogFile git.Stderr = ctx.LogFile if err := git.Run(); err != nil { - ctx.Log.Println("Failed to clone repository. " + + ctx.Log.Println("Failed to clone git repository. " + "If this a private repository, make sure you've " + "added a suitable SSH key.") ctx.Log.Println("https://man.sr.ht/builds.sr.ht/private-repos.md") @@ -443,7 +443,7 @@ func (ctx *JobContext) CloneGit9Repo(srcurl, repo_name, ref string) error { git.Stdout = ctx.LogFile git.Stderr = ctx.LogFile if err := git.Run(); err != nil { - ctx.Log.Println("Failed to clone repository.") + ctx.Log.Println("Failed to clone git repository.") return errors.Wrap(err, "git clone") } if ref != "" { @@ -512,7 +512,7 @@ func (ctx *JobContext) CloneRepos() error { hg.Stdout = ctx.LogFile hg.Stderr = ctx.LogFile if err := hg.Run(); err != nil { - ctx.Log.Println("Failed to clone repository. " + + ctx.Log.Println("Failed to clone mercurial repository. " + "If this a private repository, make sure you've " + "added a suitable SSH key.") ctx.Log.Println("https://man.sr.ht/builds.sr.ht/private-repos.md") -- 2.38.5