Skip to content

Commit 85f925b

Browse files
author
Jay Conrod
committed
cmd/gorelease: detect problems before releasing new module versions
gorelease is an experimental tool that helps module authors avoid common problems before releasing a new version of a module. gorelease is intended to eventually be merged into the go command as "go release". Updates golang/go#26420 Change-Id: I23fbab171b2cb9f4598fa525ecef5dcf006dc7c4 Reviewed-on: https://go-review.googlesource.com/c/exp/+/197299 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent f17229e commit 85f925b

File tree

135 files changed

+3336
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+3336
-3
lines changed

cmd/gorelease/errors.go

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"flag"
9+
"fmt"
10+
"os/exec"
11+
"strings"
12+
13+
"golang.org/x/mod/module"
14+
"golang.org/x/xerrors"
15+
)
16+
17+
type usageError struct {
18+
err error
19+
}
20+
21+
func usageErrorf(format string, args ...interface{}) error {
22+
return &usageError{err: fmt.Errorf(format, args...)}
23+
}
24+
25+
const usageText = `usage: gorelease -base=version [-version=version]`
26+
27+
func (e *usageError) Error() string {
28+
msg := ""
29+
if !xerrors.Is(e.err, flag.ErrHelp) {
30+
msg = e.err.Error()
31+
}
32+
return usageText + "\n" + msg + "\nFor more information, run go doc golang.org/x/exp/cmd/gorelease"
33+
}
34+
35+
type downloadError struct {
36+
m module.Version
37+
err error
38+
}
39+
40+
func (e *downloadError) Error() string {
41+
var msg string
42+
if xerr, ok := e.err.(*exec.ExitError); ok {
43+
msg = strings.TrimSpace(string(xerr.Stderr))
44+
} else {
45+
msg = e.err.Error()
46+
}
47+
sep := " "
48+
if strings.Contains(msg, "\n") {
49+
sep = "\n"
50+
}
51+
return fmt.Sprintf("error downloading module %s@%s:%s%s", e.m.Path, e.m.Version, sep, msg)
52+
}

0 commit comments

Comments
 (0)