~comcloudway/builds.sr.ht

dea73ff7835e8e79dd5472278a652f28c817599d — Eli Schwartz 2 years ago 2a9b879
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.
1 files changed, 3 insertions(+), 3 deletions(-)

M worker/tasks.go
M worker/tasks.go => worker/tasks.go +3 -3
@@ 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")