diff options
Diffstat (limited to 'dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd')
224 files changed, 7223 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/apidiff/main.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/apidiff/main.go new file mode 100644 index 0000000..92b763c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/apidiff/main.go @@ -0,0 +1,163 @@ +// Command apidiff determines whether two versions of a package are compatible +package main + +import ( + "bufio" + "flag" + "fmt" + "go/token" + "go/types" + "os" + "strings" + + "golang.org/x/exp/apidiff" + "golang.org/x/tools/go/gcexportdata" + "golang.org/x/tools/go/packages" +) + +var ( + exportDataOutfile = flag.String("w", "", "file for export data") + incompatibleOnly = flag.Bool("incompatible", false, "display only incompatible changes") + allowInternal = flag.Bool("allow-internal", false, "allow apidiff to compare internal packages") +) + +func main() { + flag.Usage = func() { + w := flag.CommandLine.Output() + fmt.Fprintf(w, "usage:\n") + fmt.Fprintf(w, "apidiff OLD NEW\n") + fmt.Fprintf(w, " compares OLD and NEW package APIs\n") + fmt.Fprintf(w, " where OLD and NEW are either import paths or files of export data\n") + fmt.Fprintf(w, "apidiff -w FILE IMPORT_PATH\n") + fmt.Fprintf(w, " writes export data of the package at IMPORT_PATH to FILE\n") + fmt.Fprintf(w, " NOTE: In a GOPATH-less environment, this option consults the\n") + fmt.Fprintf(w, " module cache by default, unless used in the directory that\n") + fmt.Fprintf(w, " contains the go.mod module definition that IMPORT_PATH belongs\n") + fmt.Fprintf(w, " to. In most cases users want the latter behavior, so be sure\n") + fmt.Fprintf(w, " to cd to the exact directory which contains the module\n") + fmt.Fprintf(w, " definition of IMPORT_PATH.\n") + flag.PrintDefaults() + } + + flag.Parse() + if *exportDataOutfile != "" { + if len(flag.Args()) != 1 { + flag.Usage() + os.Exit(2) + } + pkg := mustLoadPackage(flag.Arg(0)) + if err := writeExportData(pkg, *exportDataOutfile); err != nil { + die("writing export data: %v", err) + } + } else { + if len(flag.Args()) != 2 { + flag.Usage() + os.Exit(2) + } + oldpkg := mustLoadOrRead(flag.Arg(0)) + newpkg := mustLoadOrRead(flag.Arg(1)) + if !*allowInternal { + if isInternalPackage(oldpkg.Path()) && isInternalPackage(newpkg.Path()) { + fmt.Fprintf(os.Stderr, "Ignoring internal package %s\n", oldpkg.Path()) + os.Exit(0) + } + } + report := apidiff.Changes(oldpkg, newpkg) + var err error + if *incompatibleOnly { + err = report.TextIncompatible(os.Stdout, false) + } else { + err = report.Text(os.Stdout) + } + if err != nil { + die("writing report: %v", err) + } + } +} + +func mustLoadOrRead(importPathOrFile string) *types.Package { + fileInfo, err := os.Stat(importPathOrFile) + if err == nil && fileInfo.Mode().IsRegular() { + pkg, err := readExportData(importPathOrFile) + if err != nil { + die("reading export data from %s: %v", importPathOrFile, err) + } + return pkg + } else { + return mustLoadPackage(importPathOrFile).Types + } +} + +func mustLoadPackage(importPath string) *packages.Package { + pkg, err := loadPackage(importPath) + if err != nil { + die("loading %s: %v", importPath, err) + } + return pkg +} + +func loadPackage(importPath string) (*packages.Package, error) { + cfg := &packages.Config{Mode: packages.LoadTypes | + packages.NeedName | packages.NeedTypes | packages.NeedImports | packages.NeedDeps, + } + pkgs, err := packages.Load(cfg, importPath) + if err != nil { + return nil, err + } + if len(pkgs) == 0 { + return nil, fmt.Errorf("found no packages for import %s", importPath) + } + if len(pkgs[0].Errors) > 0 { + return nil, pkgs[0].Errors[0] + } + return pkgs[0], nil +} + +func readExportData(filename string) (*types.Package, error) { + f, err := os.Open(filename) + if err != nil { + return nil, err + } + defer f.Close() + r := bufio.NewReader(f) + m := map[string]*types.Package{} + pkgPath, err := r.ReadString('\n') + if err != nil { + return nil, err + } + pkgPath = pkgPath[:len(pkgPath)-1] // remove delimiter + return gcexportdata.Read(r, token.NewFileSet(), m, pkgPath) +} + +func writeExportData(pkg *packages.Package, filename string) error { + f, err := os.Create(filename) + if err != nil { + return err + } + // Include the package path in the file. The exportdata format does + // not record the path of the package being written. + fmt.Fprintln(f, pkg.PkgPath) + err1 := gcexportdata.Write(f, pkg.Fset, pkg.Types) + err2 := f.Close() + if err1 != nil { + return err1 + } + return err2 +} + +func die(format string, args ...interface{}) { + fmt.Fprintf(os.Stderr, format+"\n", args...) + os.Exit(1) +} + +func isInternalPackage(pkgPath string) bool { + switch { + case strings.HasSuffix(pkgPath, "/internal"): + return true + case strings.Contains(pkgPath, "/internal/"): + return true + case pkgPath == "internal", strings.HasPrefix(pkgPath, "internal/"): + return true + } + return false +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/errors.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/errors.go new file mode 100644 index 0000000..d99f840 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/errors.go @@ -0,0 +1,81 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "errors" + "flag" + "fmt" + "os/exec" + "strings" + + "golang.org/x/mod/module" +) + +type usageError struct { + err error +} + +func usageErrorf(format string, args ...interface{}) error { + return &usageError{err: fmt.Errorf(format, args...)} +} + +const usageText = `usage: gorelease [-base=version] [-version=version]` + +func (e *usageError) Error() string { + msg := "" + if !errors.Is(e.err, flag.ErrHelp) { + msg = e.err.Error() + } + return usageText + "\n" + msg + "\nFor more information, run go doc golang.org/x/exp/cmd/gorelease" +} + +type baseVersionError struct { + err error + modPath string +} + +func (e *baseVersionError) Error() string { + firstVersion := "v0.1.0" + _, major, _ := module.SplitPathVersion(e.modPath) + if major != "" { + firstVersion = major[1:] + ".0.0" + } + + return fmt.Sprintf("could not find base version. Consider setting -version=%s if this is a first release, or explicitly set -base=none: %v", firstVersion, e.err) +} + +func (e *baseVersionError) Unwrap() error { + return e.err +} + +type downloadError struct { + m module.Version + err error +} + +func (e *downloadError) Error() string { + msg := e.err.Error() + sep := " " + if strings.Contains(msg, "\n") { + sep = "\n" + } + return fmt.Sprintf("error downloading module %s@%s:%s%s", e.m.Path, e.m.Version, sep, msg) +} + +// cleanCmdError simplifies error messages from os/exec.Cmd.Run. +// For ExitErrors, it trims and returns stderr. This is useful for go commands +// that print well-formatted errors. By default, ExitError prints the exit +// status but not stderr. +// +// cleanCmdError returns other errors unmodified. +func cleanCmdError(err error) error { + if xerr, ok := err.(*exec.ExitError); ok { + if stderr := strings.TrimSpace(string(xerr.Stderr)); stderr != "" { + return errors.New(stderr) + } + } + return err +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/gorelease.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/gorelease.go new file mode 100644 index 0000000..b0ee1e9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/gorelease.go @@ -0,0 +1,1517 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// gorelease is an experimental tool that helps module authors avoid common +// problems before releasing a new version of a module. +// +// Usage: +// +// gorelease [-base={version|none}] [-version=version] +// +// Examples: +// +// # Compare with the latest version and suggest a new version. +// gorelease +// +// # Compare with a specific version and suggest a new version. +// gorelease -base=v1.2.3 +// +// # Compare with the latest version and check a specific new version for compatibility. +// gorelease -version=v1.3.0 +// +// # Compare with a specific version and check a specific new version for compatibility. +// gorelease -base=v1.2.3 -version=v1.3.0 +// +// gorelease analyzes changes in the public API and dependencies of the main +// module. It compares a base version (set with -base) with the currently +// checked out revision. Given a proposed version to release (set with +// -version), gorelease reports whether the changes are consistent with +// semantic versioning. If no version is proposed with -version, gorelease +// suggests the lowest version consistent with semantic versioning. +// +// If there are no visible changes in the module's public API, gorelease +// accepts versions that increment the minor or patch version numbers. For +// example, if the base version is "v2.3.1", gorelease would accept "v2.3.2" or +// "v2.4.0" or any prerelease of those versions, like "v2.4.0-beta". If no +// version is proposed, gorelease would suggest "v2.3.2". +// +// If there are only backward compatible differences in the module's public +// API, gorelease only accepts versions that increment the minor version. For +// example, if the base version is "v2.3.1", gorelease would accept "v2.4.0" +// but not "v2.3.2". +// +// If there are incompatible API differences for a proposed version with +// major version 1 or higher, gorelease will exit with a non-zero status. +// Incompatible differences may only be released in a new major version, which +// requires creating a module with a different path. For example, if +// incompatible changes are made in the module "example.com/mod", a +// new major version must be released as a new module, "example.com/mod/v2". +// For a proposed version with major version 0, which allows incompatible +// changes, gorelease will describe all changes, but incompatible changes +// will not affect its exit status. +// +// For more information on semantic versioning, see https://semver.org. +// +// Note: gorelease does not accept build metadata in releases (like +// v1.0.0+debug). Although it is valid semver, the Go tool and other tools in +// the ecosystem do not support it, so its use is not recommended. +// +// gorelease accepts the following flags: +// +// -base=version: The version that the current version of the module will be +// compared against. This may be a version like "v1.5.2", a version query like +// "latest", or "none". If the version is "none", gorelease will not compare the +// current version against any previous version; it will only validate the +// current version. This is useful for checking the first release of a new major +// version. The version may be preceded by a different module path and an '@', +// like -base=example.com/mod/v2@v2.5.2. This is useful to compare against +// an earlier major version or a fork. If -base is not specified, gorelease will +// attempt to infer a base version from the -version flag and available released +// versions. +// +// -version=version: The proposed version to be released. If specified, +// gorelease will confirm whether this version is consistent with changes made +// to the module's public API. gorelease will exit with a non-zero status if the +// version is not valid. +// +// gorelease is eventually intended to be merged into the go command +// as "go release". See golang.org/issues/26420. +package main + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "flag" + "fmt" + "go/build" + "io" + "io/ioutil" + "log" + "os" + "os/exec" + "path" + "path/filepath" + "sort" + "strings" + "unicode" + + "golang.org/x/exp/apidiff" + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" + "golang.org/x/mod/semver" + "golang.org/x/mod/zip" + "golang.org/x/tools/go/packages" +) + +// IDEAS: +// * Should we suggest versions at all or should -version be mandatory? +// * Verify downstream modules have licenses. May need an API or library +// for this. Be clear that we can't provide legal advice. +// * Internal packages may be relevant to submodules (for example, +// golang.org/x/tools/internal/lsp is imported by golang.org/x/tools). +// gorelease should detect whether this is the case and include internal +// directories in comparison. It should be possible to opt out or specify +// a different list of submodules. +// * Decide what to do about build constraints, particularly GOOS and GOARCH. +// The API may be different on some platforms (e.g., x/sys). +// Should gorelease load packages in multiple configurations in the same run? +// Is it a compatible change if the same API is available for more platforms? +// Is it an incompatible change for fewer? +// How about cgo? Is adding a new cgo dependency an incompatible change? +// * Support splits and joins of nested modules. For example, if we are +// proposing to tag a particular commit as both cloud.google.com/go v0.46.2 +// and cloud.google.com/go/storage v1.0.0, we should ensure that the sets of +// packages provided by those modules are disjoint, and we should not report +// the packages moved from one to the other as an incompatible change (since +// the APIs are still compatible, just with a different module split). + +// TODO(jayconrod): +// * Clean up overuse of fmt.Errorf. +// * Support migration to modules after v2.x.y+incompatible. Requires comparing +// packages with different module paths. +// * Error when packages import from earlier major version of same module. +// (this may be intentional; look for real examples first). +// * Mechanism to suppress error messages. + +func main() { + log.SetFlags(0) + log.SetPrefix("gorelease: ") + wd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + ctx := context.WithValue(context.Background(), "env", append(os.Environ(), "GO111MODULE=on")) + success, err := runRelease(ctx, os.Stdout, wd, os.Args[1:]) + if err != nil { + if _, ok := err.(*usageError); ok { + fmt.Fprintln(os.Stderr, err) + os.Exit(2) + } else { + log.Fatal(err) + } + } + if !success { + os.Exit(1) + } +} + +// runRelease is the main function of gorelease. It's called by tests, so +// it writes to w instead of os.Stdout and returns an error instead of +// exiting. +func runRelease(ctx context.Context, w io.Writer, dir string, args []string) (success bool, err error) { + // Validate arguments and flags. We'll print our own errors, since we want to + // test without printing to stderr. + fs := flag.NewFlagSet("gorelease", flag.ContinueOnError) + fs.Usage = func() {} + fs.SetOutput(ioutil.Discard) + var baseOpt, releaseVersion string + fs.StringVar(&baseOpt, "base", "", "previous version to compare against") + fs.StringVar(&releaseVersion, "version", "", "proposed version to be released") + if err := fs.Parse(args); err != nil { + return false, &usageError{err: err} + } + + if len(fs.Args()) > 0 { + return false, usageErrorf("no arguments allowed") + } + + if releaseVersion != "" { + if semver.Build(releaseVersion) != "" { + return false, usageErrorf("release version %q is not a canonical semantic version: build metadata is not supported", releaseVersion) + } + if c := semver.Canonical(releaseVersion); c != releaseVersion { + return false, usageErrorf("release version %q is not a canonical semantic version", releaseVersion) + } + } + + var baseModPath, baseVersion string + if at := strings.Index(baseOpt, "@"); at >= 0 { + baseModPath = baseOpt[:at] + baseVersion = baseOpt[at+1:] + } else if dot, slash := strings.Index(baseOpt, "."), strings.Index(baseOpt, "/"); dot >= 0 && slash >= 0 && dot < slash { + baseModPath = baseOpt + } else { + baseVersion = baseOpt + } + if baseModPath == "" { + if baseVersion != "" && semver.Canonical(baseVersion) == baseVersion && releaseVersion != "" { + if cmp := semver.Compare(baseOpt, releaseVersion); cmp == 0 { + return false, usageErrorf("-base and -version must be different") + } else if cmp > 0 { + return false, usageErrorf("base version (%q) must be lower than release version (%q)", baseVersion, releaseVersion) + } + } + } else if baseModPath != "" && baseVersion == "none" { + return false, usageErrorf(`base version (%q) cannot have version "none" with explicit module path`, baseOpt) + } + + // Find the local module and repository root directories. + modRoot, err := findModuleRoot(dir) + if err != nil { + return false, err + } + repoRoot := findRepoRoot(modRoot) + + // Load packages for the version to be released from the local directory. + release, err := loadLocalModule(ctx, modRoot, repoRoot, releaseVersion) + if err != nil { + return false, err + } + + // Find the base version if there is one, download it, and load packages from + // the module cache. + var max string + if baseModPath == "" { + if baseVersion != "" && semver.Canonical(baseVersion) == baseVersion && module.Check(release.modPath, baseVersion) != nil { + // Base version was specified, but it's not consistent with the release + // module path, for example, the module path is example.com/m/v2, but + // the user said -base=v1.0.0. Instead of making the user explicitly + // specify the base module path, we'll adjust the major version suffix. + prefix, _, _ := module.SplitPathVersion(release.modPath) + major := semver.Major(baseVersion) + if strings.HasPrefix(prefix, "gopkg.in/") { + baseModPath = prefix + "." + semver.Major(baseVersion) + } else if major >= "v2" { + baseModPath = prefix + "/" + major + } else { + baseModPath = prefix + } + } else { + baseModPath = release.modPath + max = releaseVersion + } + } + base, err := loadDownloadedModule(ctx, baseModPath, baseVersion, max) + if err != nil { + return false, err + } + + // Compare packages and check for other issues. + report, err := makeReleaseReport(ctx, base, release) + if err != nil { + return false, err + } + if _, err := fmt.Fprint(w, report.String()); err != nil { + return false, err + } + return report.isSuccessful(), nil +} + +type moduleInfo struct { + modRoot string // module root directory + repoRoot string // repository root directory (may be "") + modPath string // module path in go.mod + version string // resolved version or "none" + versionQuery string // a query like "latest" or "dev-branch", if specified + versionInferred bool // true if the version was unspecified and inferred + highestTransitiveVersion string // version of the highest transitive self-dependency (cycle) + modPathMajor string // major version suffix like "/v3" or ".v2" + tagPrefix string // prefix for version tags if module not in repo root + + goModPath string // file path to go.mod + goModData []byte // content of go.mod + goSumData []byte // content of go.sum + goModFile *modfile.File // parsed go.mod file + + diagnostics []string // problems not related to loading specific packages + pkgs []*packages.Package // loaded packages with type information + + // Versions of this module which already exist. Only loaded for release + // (not base). + existingVersions []string +} + +// loadLocalModule loads information about a module and its packages from a +// local directory. +// +// modRoot is the directory containing the module's go.mod file. +// +// repoRoot is the root directory of the repository containing the module or "". +// +// version is a proposed version for the module or "". +func loadLocalModule(ctx context.Context, modRoot, repoRoot, version string) (m moduleInfo, err error) { + if repoRoot != "" && !hasFilePathPrefix(modRoot, repoRoot) { + return moduleInfo{}, fmt.Errorf("module root %q is not in repository root %q", modRoot, repoRoot) + } + + // Load the go.mod file and check the module path and go version. + m = moduleInfo{ + modRoot: modRoot, + repoRoot: repoRoot, + version: version, + goModPath: filepath.Join(modRoot, "go.mod"), + } + + if version != "" && semver.Compare(version, "v0.0.0-99999999999999-zzzzzzzzzzzz") < 0 { + m.diagnostics = append(m.diagnostics, fmt.Sprintf("Version %s is lower than most pseudo-versions. Consider releasing v0.1.0-0 instead.", version)) + } + + m.goModData, err = ioutil.ReadFile(m.goModPath) + if err != nil { + return moduleInfo{}, err + } + m.goModFile, err = modfile.ParseLax(m.goModPath, m.goModData, nil) + if err != nil { + return moduleInfo{}, err + } + if m.goModFile.Module == nil { + return moduleInfo{}, fmt.Errorf("%s: module directive is missing", m.goModPath) + } + m.modPath = m.goModFile.Module.Mod.Path + if err := checkModPath(m.modPath); err != nil { + return moduleInfo{}, err + } + var ok bool + _, m.modPathMajor, ok = module.SplitPathVersion(m.modPath) + if !ok { + // we just validated the path above. + panic(fmt.Sprintf("could not find version suffix in module path %q", m.modPath)) + } + if m.goModFile.Go == nil { + m.diagnostics = append(m.diagnostics, "go.mod: go directive is missing") + } + + // Determine the version tag prefix for the module within the repository. + if repoRoot != "" && modRoot != repoRoot { + if strings.HasPrefix(m.modPathMajor, ".") { + m.diagnostics = append(m.diagnostics, fmt.Sprintf("%s: module path starts with gopkg.in and must be declared in the root directory of the repository", m.modPath)) + } else { + codeDir := filepath.ToSlash(modRoot[len(repoRoot)+1:]) + var altGoModPath string + if m.modPathMajor == "" { + // module has no major version suffix. + // codeDir must be a suffix of modPath. + // tagPrefix is codeDir with a trailing slash. + if strings.HasSuffix(m.modPath, "/"+codeDir) { + m.tagPrefix = codeDir + "/" + } else { + m.diagnostics = append(m.diagnostics, fmt.Sprintf("%s: module path must end with %[2]q, since it is in subdirectory %[2]q", m.modPath, codeDir)) + } + } else { + if strings.HasSuffix(m.modPath, "/"+codeDir) { + // module has a major version suffix and is in a major version subdirectory. + // codeDir must be a suffix of modPath. + // tagPrefix must not include the major version. + m.tagPrefix = codeDir[:len(codeDir)-len(m.modPathMajor)+1] + altGoModPath = modRoot[:len(modRoot)-len(m.modPathMajor)+1] + "go.mod" + } else if strings.HasSuffix(m.modPath, "/"+codeDir+m.modPathMajor) { + // module has a major version suffix and is not in a major version subdirectory. + // codeDir + modPathMajor is a suffix of modPath. + // tagPrefix is codeDir with a trailing slash. + m.tagPrefix = codeDir + "/" + altGoModPath = filepath.Join(modRoot, m.modPathMajor[1:], "go.mod") + } else { + m.diagnostics = append(m.diagnostics, fmt.Sprintf("%s: module path must end with %[2]q or %q, since it is in subdirectory %[2]q", m.modPath, codeDir, codeDir+m.modPathMajor)) + } + } + + // Modules with major version suffixes can be defined in two places + // (e.g., sub/go.mod and sub/v2/go.mod). They must not be defined in both. + if altGoModPath != "" { + if data, err := ioutil.ReadFile(altGoModPath); err == nil { + if altModPath := modfile.ModulePath(data); m.modPath == altModPath { + goModRel, _ := filepath.Rel(repoRoot, m.goModPath) + altGoModRel, _ := filepath.Rel(repoRoot, altGoModPath) + m.diagnostics = append(m.diagnostics, fmt.Sprintf("module is defined in two locations:\n\t%s\n\t%s", goModRel, altGoModRel)) + } + } + } + } + } + + // Load the module's packages. + // We pack the module into a zip file and extract it to a temporary directory + // as if it were published and downloaded. We'll detect any errors that would + // occur (for example, invalid file names). We avoid loading it as the + // main module. + tmpModRoot, err := copyModuleToTempDir(repoRoot, m.modPath, m.modRoot) + if err != nil { + return moduleInfo{}, err + } + defer func() { + if rerr := os.RemoveAll(tmpModRoot); err == nil && rerr != nil { + err = fmt.Errorf("removing temporary module directory: %v", rerr) + } + }() + tmpLoadDir, tmpGoModData, tmpGoSumData, pkgPaths, prepareDiagnostics, err := prepareLoadDir(ctx, m.goModFile, m.modPath, tmpModRoot, version, false) + if err != nil { + return moduleInfo{}, err + } + defer func() { + if rerr := os.RemoveAll(tmpLoadDir); err == nil && rerr != nil { + err = fmt.Errorf("removing temporary load directory: %v", rerr) + } + }() + + var loadDiagnostics []string + m.pkgs, loadDiagnostics, err = loadPackages(ctx, m.modPath, tmpModRoot, tmpLoadDir, tmpGoModData, tmpGoSumData, pkgPaths) + if err != nil { + return moduleInfo{}, err + } + + m.diagnostics = append(m.diagnostics, prepareDiagnostics...) + m.diagnostics = append(m.diagnostics, loadDiagnostics...) + + highestVersion, err := findSelectedVersion(ctx, tmpLoadDir, m.modPath) + if err != nil { + return moduleInfo{}, err + } + + if highestVersion != "" { + // A version of the module is included in the transitive dependencies. + // Add it to the moduleInfo so that the release report stage can use it + // in verifying the version or suggestion a new version, depending on + // whether the user provided a version already. + m.highestTransitiveVersion = highestVersion + } + + retracted, err := loadRetractions(ctx, tmpLoadDir) + if err != nil { + return moduleInfo{}, err + } + m.diagnostics = append(m.diagnostics, retracted...) + + return m, nil +} + +// loadDownloadedModule downloads a module and loads information about it and +// its packages from the module cache. +// +// modPath is the module path used to fetch the module. The module's path in +// go.mod (m.modPath) may be different, for example in a soft fork intended as +// a replacement. +// +// version is the version to load. It may be "none" (indicating nothing should +// be loaded), "" (the highest available version below max should be used), a +// version query (to be resolved with 'go list'), or a canonical version. +// +// If version is "" and max is not "", available versions greater than or equal +// to max will not be considered. Typically, loadDownloadedModule is used to +// load the base version, and max is the release version. +func loadDownloadedModule(ctx context.Context, modPath, version, max string) (m moduleInfo, err error) { + // Check the module path and version. + // If the version is a query, resolve it to a canonical version. + m = moduleInfo{modPath: modPath} + if err := checkModPath(modPath); err != nil { + return moduleInfo{}, err + } + + var ok bool + _, m.modPathMajor, ok = module.SplitPathVersion(modPath) + if !ok { + // we just validated the path above. + panic(fmt.Sprintf("could not find version suffix in module path %q", modPath)) + } + + if version == "none" { + // We don't have a base version to compare against. + m.version = "none" + return m, nil + } + if version == "" { + // Unspecified version: use the highest version below max. + m.versionInferred = true + if m.version, err = inferBaseVersion(ctx, modPath, max); err != nil { + return moduleInfo{}, err + } + if m.version == "none" { + return m, nil + } + } else if version != module.CanonicalVersion(version) { + // Version query: find the real version. + m.versionQuery = version + if m.version, err = queryVersion(ctx, modPath, version); err != nil { + return moduleInfo{}, err + } + if m.version != "none" && max != "" && semver.Compare(m.version, max) >= 0 { + // TODO(jayconrod): reconsider this comparison for pseudo-versions in + // general. A query might match different pseudo-versions over time, + // depending on ancestor versions, so this might start failing with + // no local change. + return moduleInfo{}, fmt.Errorf("base version %s (%s) must be lower than release version %s", m.version, m.versionQuery, max) + } + } else { + // Canonical version: make sure it matches the module path. + if err := module.CheckPathMajor(version, m.modPathMajor); err != nil { + // TODO(golang.org/issue/39666): don't assume this is the base version + // or that we're comparing across major versions. + return moduleInfo{}, fmt.Errorf("can't compare major versions: base version %s does not belong to module %s", version, modPath) + } + m.version = version + } + + // Download the module into the cache and load the mod file. + // Note that goModPath is $GOMODCACHE/cache/download/$modPath/@v/$version.mod, + // which is not inside modRoot. This is what the go command uses. Even if + // the module didn't have a go.mod file, one will be synthesized there. + v := module.Version{Path: modPath, Version: m.version} + if m.modRoot, m.goModPath, err = downloadModule(ctx, v); err != nil { + return moduleInfo{}, err + } + if m.goModData, err = ioutil.ReadFile(m.goModPath); err != nil { + return moduleInfo{}, err + } + if m.goModFile, err = modfile.ParseLax(m.goModPath, m.goModData, nil); err != nil { + return moduleInfo{}, err + } + if m.goModFile.Module == nil { + return moduleInfo{}, fmt.Errorf("%s: missing module directive", m.goModPath) + } + m.modPath = m.goModFile.Module.Mod.Path + + // Load packages. + tmpLoadDir, tmpGoModData, tmpGoSumData, pkgPaths, _, err := prepareLoadDir(ctx, nil, m.modPath, m.modRoot, m.version, true) + if err != nil { + return moduleInfo{}, err + } + defer func() { + if rerr := os.RemoveAll(tmpLoadDir); err == nil && rerr != nil { + err = fmt.Errorf("removing temporary load directory: %v", err) + } + }() + + if m.pkgs, _, err = loadPackages(ctx, m.modPath, m.modRoot, tmpLoadDir, tmpGoModData, tmpGoSumData, pkgPaths); err != nil { + return moduleInfo{}, err + } + + // Calculate the existing versions. + ev, err := existingVersions(ctx, m.modPath, tmpLoadDir) + if err != nil { + return moduleInfo{}, err + } + m.existingVersions = ev + + return m, nil +} + +// makeReleaseReport returns a report comparing the current version of a +// module with a previously released version. The report notes any backward +// compatible and incompatible changes in the module's public API. It also +// diagnoses common problems, such as go.mod or go.sum being incomplete. +// The report recommends or validates a release version and indicates a +// version control tag to use (with an appropriate prefix, for modules not +// in the repository root directory). +func makeReleaseReport(ctx context.Context, base, release moduleInfo) (report, error) { + // Compare each pair of packages. + // Ignore internal packages. + // If we don't have a base version to compare against just check the new + // packages for errors. + shouldCompare := base.version != "none" + isInternal := func(modPath, pkgPath string) bool { + if !hasPathPrefix(pkgPath, modPath) { + panic(fmt.Sprintf("package %s not in module %s", pkgPath, modPath)) + } + for pkgPath != modPath { + if path.Base(pkgPath) == "internal" { + return true + } + pkgPath = path.Dir(pkgPath) + } + return false + } + r := report{ + base: base, + release: release, + } + for _, pair := range zipPackages(base.modPath, base.pkgs, release.modPath, release.pkgs) { + basePkg, releasePkg := pair.base, pair.release + switch { + case releasePkg == nil: + // Package removed + if internal := isInternal(base.modPath, basePkg.PkgPath); !internal || len(basePkg.Errors) > 0 { + pr := packageReport{ + path: basePkg.PkgPath, + baseErrors: basePkg.Errors, + } + if !internal { + pr.Report = apidiff.Report{ + Changes: []apidiff.Change{{ + Message: "package removed", + Compatible: false, + }}, + } + } + r.addPackage(pr) + } + + case basePkg == nil: + // Package added + if internal := isInternal(release.modPath, releasePkg.PkgPath); !internal && shouldCompare || len(releasePkg.Errors) > 0 { + pr := packageReport{ + path: releasePkg.PkgPath, + releaseErrors: releasePkg.Errors, + } + if !internal && shouldCompare { + // If we aren't comparing against a base version, don't say + // "package added". Only report packages with errors. + pr.Report = apidiff.Report{ + Changes: []apidiff.Change{{ + Message: "package added", + Compatible: true, + }}, + } + } + r.addPackage(pr) + } + + default: + // Matched packages + // Both packages are internal or neither; we only consider path components + // after the module path. + internal := isInternal(release.modPath, releasePkg.PkgPath) + if !internal && basePkg.Name != "main" && releasePkg.Name != "main" { + pr := packageReport{ + path: basePkg.PkgPath, + baseErrors: basePkg.Errors, + releaseErrors: releasePkg.Errors, + Report: apidiff.Changes(basePkg.Types, releasePkg.Types), + } + r.addPackage(pr) + } + } + } + + if r.canVerifyReleaseVersion() { + if release.version == "" { + r.suggestReleaseVersion() + } else { + r.validateReleaseVersion() + } + } + + return r, nil +} + +// existingVersions returns the versions that already exist for the given +// modPath. +func existingVersions(ctx context.Context, modPath, modRoot string) (versions []string, err error) { + defer func() { + if err != nil { + err = fmt.Errorf("listing versions of %s: %w", modPath, err) + } + }() + + type listVersions struct { + Versions []string + } + cmd := exec.CommandContext(ctx, "go", "list", "-json", "-m", "-versions", modPath) + cmd.Env = copyEnv(ctx, cmd.Env) + cmd.Dir = modRoot + out, err := cmd.Output() + if err != nil { + return nil, cleanCmdError(err) + } + if len(out) == 0 { + return nil, nil + } + + var lv listVersions + if err := json.Unmarshal(out, &lv); err != nil { + return nil, err + } + return lv.Versions, nil +} + +// findRepoRoot finds the root directory of the repository that contains dir. +// findRepoRoot returns "" if it can't find the repository root. +func findRepoRoot(dir string) string { + vcsDirs := []string{".git", ".hg", ".svn", ".bzr"} + d := filepath.Clean(dir) + for { + for _, vcsDir := range vcsDirs { + if _, err := os.Stat(filepath.Join(d, vcsDir)); err == nil { + return d + } + } + parent := filepath.Dir(d) + if parent == d { + return "" + } + d = parent + } +} + +// findModuleRoot finds the root directory of the module that contains dir. +func findModuleRoot(dir string) (string, error) { + d := filepath.Clean(dir) + for { + if fi, err := os.Stat(filepath.Join(d, "go.mod")); err == nil && !fi.IsDir() { + return dir, nil + } + parent := filepath.Dir(d) + if parent == d { + break + } + d = parent + } + return "", fmt.Errorf("%s: cannot find go.mod file", dir) +} + +// checkModPath is like golang.org/x/mod/module.CheckPath, but it returns +// friendlier error messages for common mistakes. +// +// TODO(jayconrod): update module.CheckPath and delete this function. +func checkModPath(modPath string) error { + if path.IsAbs(modPath) || filepath.IsAbs(modPath) { + // TODO(jayconrod): improve error message in x/mod instead of checking here. + return fmt.Errorf("module path %q must not be an absolute path.\nIt must be an address where your module may be found.", modPath) + } + if suffix := dirMajorSuffix(modPath); suffix == "v0" || suffix == "v1" { + return fmt.Errorf("module path %q has major version suffix %q.\nA major version suffix is only allowed for v2 or later.", modPath, suffix) + } else if strings.HasPrefix(suffix, "v0") { + return fmt.Errorf("module path %q has major version suffix %q.\nA major version may not have a leading zero.", modPath, suffix) + } else if strings.ContainsRune(suffix, '.') { + return fmt.Errorf("module path %q has major version suffix %q.\nA major version may not contain dots.", modPath, suffix) + } + return module.CheckPath(modPath) +} + +// inferBaseVersion returns an appropriate base version if one was not specified +// explicitly. +// +// If max is not "", inferBaseVersion returns the highest available release +// version of the module lower than max. Otherwise, inferBaseVersion returns the +// highest available release version. Pre-release versions are not considered. +// If there is no available version, and max appears to be the first release +// version (for example, "v0.1.0", "v2.0.0"), "none" is returned. +func inferBaseVersion(ctx context.Context, modPath, max string) (baseVersion string, err error) { + defer func() { + if err != nil { + err = &baseVersionError{err: err, modPath: modPath} + } + }() + + versions, err := loadVersions(ctx, modPath) + if err != nil { + return "", err + } + + for i := len(versions) - 1; i >= 0; i-- { + v := versions[i] + if semver.Prerelease(v) == "" && + (max == "" || semver.Compare(v, max) < 0) { + return v, nil + } + } + + if max == "" || maybeFirstVersion(max) { + return "none", nil + } + return "", fmt.Errorf("no versions found lower than %s", max) +} + +// queryVersion returns the canonical version for a given module version query. +func queryVersion(ctx context.Context, modPath, query string) (resolved string, err error) { + defer func() { + if err != nil { + err = fmt.Errorf("could not resolve version %s@%s: %w", modPath, query, err) + } + }() + if query == "upgrade" || query == "patch" { + return "", errors.New("query is based on requirements in main go.mod file") + } + + tmpDir, err := ioutil.TempDir("", "") + if err != nil { + return "", err + } + defer func() { + if rerr := os.Remove(tmpDir); rerr != nil && err == nil { + err = rerr + } + }() + arg := modPath + "@" + query + cmd := exec.CommandContext(ctx, "go", "list", "-m", "-f", "{{.Version}}", "--", arg) + cmd.Env = copyEnv(ctx, cmd.Env) + cmd.Dir = tmpDir + cmd.Env = append(cmd.Env, "GO111MODULE=on") + out, err := cmd.Output() + if err != nil { + return "", cleanCmdError(err) + } + return strings.TrimSpace(string(out)), nil +} + +// loadVersions loads the list of versions for the given module using +// 'go list -m -versions'. The returned versions are sorted in ascending +// semver order. +func loadVersions(ctx context.Context, modPath string) (versions []string, err error) { + defer func() { + if err != nil { + err = fmt.Errorf("could not load versions for %s: %v", modPath, err) + } + }() + + tmpDir, err := ioutil.TempDir("", "") + if err != nil { + return nil, err + } + defer func() { + if rerr := os.Remove(tmpDir); rerr != nil && err == nil { + err = rerr + } + }() + cmd := exec.CommandContext(ctx, "go", "list", "-m", "-versions", "--", modPath) + cmd.Env = copyEnv(ctx, cmd.Env) + cmd.Dir = tmpDir + out, err := cmd.Output() + if err != nil { + return nil, cleanCmdError(err) + } + versions = strings.Fields(string(out)) + if len(versions) > 0 { + versions = versions[1:] // skip module path + } + + // Sort versions defensively. 'go list -m -versions' should always returns + // a sorted list of versions, but it's fast and easy to sort them here, too. + sort.Slice(versions, func(i, j int) bool { + return semver.Compare(versions[i], versions[j]) < 0 + }) + return versions, nil +} + +// maybeFirstVersion returns whether v appears to be the first version +// of a module. +func maybeFirstVersion(v string) bool { + major, minor, patch, _, _, err := parseVersion(v) + if err != nil { + return false + } + if major == "0" { + return minor == "0" && patch == "0" || + minor == "0" && patch == "1" || + minor == "1" && patch == "0" + } + return minor == "0" && patch == "0" +} + +// dirMajorSuffix returns a major version suffix for a slash-separated path. +// For example, for the path "foo/bar/v2", dirMajorSuffix would return "v2". +// If no major version suffix is found, "" is returned. +// +// dirMajorSuffix is less strict than module.SplitPathVersion so that incorrect +// suffixes like "v0", "v02", "v1.2" can be detected. It doesn't handle +// special cases for gopkg.in paths. +func dirMajorSuffix(path string) string { + i := len(path) + for i > 0 && ('0' <= path[i-1] && path[i-1] <= '9') || path[i-1] == '.' { + i-- + } + if i <= 1 || i == len(path) || path[i-1] != 'v' || (i > 1 && path[i-2] != '/') { + return "" + } + return path[i-1:] +} + +// copyModuleToTempDir copies module files from modRoot to a subdirectory of +// scratchDir. Submodules, vendor directories, and irregular files are excluded. +// An error is returned if the module contains any files or directories that +// can't be included in a module zip file (due to special characters, +// excessive sizes, etc.). +func copyModuleToTempDir(repoRoot, modPath, modRoot string) (dir string, err error) { + // Generate a fake version consistent with modPath. We need a canonical + // version to create a zip file. + version := "v0.0.0-gorelease" + _, majorPathSuffix, _ := module.SplitPathVersion(modPath) + if majorPathSuffix != "" { + version = majorPathSuffix[1:] + ".0.0-gorelease" + } + m := module.Version{Path: modPath, Version: version} + + zipFile, err := ioutil.TempFile("", "gorelease-*.zip") + if err != nil { + return "", err + } + defer func() { + zipFile.Close() + os.Remove(zipFile.Name()) + }() + + dir, err = ioutil.TempDir("", "gorelease") + if err != nil { + return "", err + } + defer func() { + if err != nil { + os.RemoveAll(dir) + dir = "" + } + }() + + var fallbackToDir bool + if repoRoot != "" { + var err error + fallbackToDir, err = tryCreateFromVCS(zipFile, m, modRoot, repoRoot) + if err != nil { + return "", err + } + } + + if repoRoot == "" || fallbackToDir { + // Not a recognised repo: fall back to creating from dir. + if err := zip.CreateFromDir(zipFile, m, modRoot); err != nil { + var e zip.FileErrorList + if errors.As(err, &e) { + return "", e + } + return "", err + } + } + + if err := zipFile.Close(); err != nil { + return "", err + } + if err := zip.Unzip(dir, m, zipFile.Name()); err != nil { + return "", err + } + return dir, nil +} + +// tryCreateFromVCS tries to create a module zip file from VCS. If it succeeds, +// it returns fallBackToDir false and a nil err. If it fails in a recoverable +// way, it returns fallBackToDir true and a nil err. If it fails in an +// unrecoverable way, it returns a non-nil err. +func tryCreateFromVCS(zipFile io.Writer, m module.Version, modRoot, repoRoot string) (fallbackToDir bool, _ error) { + // We recognised a repo: create from VCS. + if !hasFilePathPrefix(modRoot, repoRoot) { + panic(fmt.Sprintf("repo root %q is not a prefix of mod root %q", repoRoot, modRoot)) + } + hasUncommitted, err := hasGitUncommittedChanges(repoRoot) + if err != nil { + // Fallback to CreateFromDir. + return true, nil + } + if hasUncommitted { + return false, fmt.Errorf("repo %s has uncommitted changes", repoRoot) + } + modRel := filepath.ToSlash(trimFilePathPrefix(modRoot, repoRoot)) + if err := zip.CreateFromVCS(zipFile, m, repoRoot, "HEAD", modRel); err != nil { + var fel zip.FileErrorList + if errors.As(err, &fel) { + return false, fel + } + var uve *zip.UnrecognizedVCSError + if errors.As(err, &uve) { + // Fallback to CreateFromDir. + return true, nil + } + return false, err + } + // Success! + return false, nil +} + +// downloadModule downloads a specific version of a module to the +// module cache using 'go mod download'. +func downloadModule(ctx context.Context, m module.Version) (modRoot, goModPath string, err error) { + defer func() { + if err != nil { + err = &downloadError{m: m, err: cleanCmdError(err)} + } + }() + + // Run 'go mod download' from a temporary directory to avoid needing to load + // go.mod from gorelease's working directory (or a parent). + // go.mod may be broken, and we don't need it. + // TODO(golang.org/issue/36812): 'go mod download' reads go.mod even though + // we don't need information about the main module or the build list. + // If it didn't read go.mod in this case, we wouldn't need a temp directory. + tmpDir, err := ioutil.TempDir("", "gorelease-download") + if err != nil { + return "", "", err + } + defer os.Remove(tmpDir) + cmd := exec.CommandContext(ctx, "go", "mod", "download", "-json", "--", m.Path+"@"+m.Version) + cmd.Env = copyEnv(ctx, cmd.Env) + cmd.Dir = tmpDir + out, err := cmd.Output() + var xerr *exec.ExitError + if err != nil { + var ok bool + if xerr, ok = err.(*exec.ExitError); !ok { + return "", "", err + } + } + + // If 'go mod download' exited unsuccessfully but printed well-formed JSON + // with an error, return that error. + parsed := struct{ Dir, GoMod, Error string }{} + if jsonErr := json.Unmarshal(out, &parsed); jsonErr != nil { + if xerr != nil { + return "", "", cleanCmdError(xerr) + } + return "", "", jsonErr + } + if parsed.Error != "" { + return "", "", errors.New(parsed.Error) + } + if xerr != nil { + return "", "", cleanCmdError(xerr) + } + return parsed.Dir, parsed.GoMod, nil +} + +// prepareLoadDir creates a temporary directory and a go.mod file that requires +// the module being loaded. go.sum is copied if present. It also creates a .go +// file that imports every package in the given modPath. This temporary module +// is useful for two reasons. First, replace and exclude directives from the +// target module aren't applied, so we have the same view as a dependent module. +// Second, we can run commands like 'go get' without modifying the original +// go.mod and go.sum files. +// +// modFile is the pre-parsed go.mod file. If non-nil, its requirements and +// go version will be copied so that incomplete and out-of-date requirements +// may be reported later. +// +// modPath is the module's path. +// +// modRoot is the module's root directory. +// +// version is the version of the module being loaded. If must be canonical +// for modules loaded from the cache. Otherwise, it may be empty (for example, +// when no release version is proposed). +// +// cached indicates whether the module is being loaded from the module cache. +// If cached is true, then the module lives in the cache at +// $GOMODCACHE/$modPath@$version/. Its go.mod file is at +// $GOMODCACHE/cache/download/$modPath/@v/$version.mod. It must be referenced +// with a simple require. A replace directive won't work because it may not have +// a go.mod file in modRoot. +// If cached is false, then modRoot is somewhere outside the module cache +// (ex /tmp). We'll reference it with a local replace directive. It must have a +// go.mod file in modRoot. +// +// dir is the location of the temporary directory. +// +// goModData and goSumData are the contents of the go.mod and go.sum files, +// respectively. +// +// pkgPaths are the import paths of the module being loaded, including the path +// to any main packages (as if they were importable). +func prepareLoadDir(ctx context.Context, modFile *modfile.File, modPath, modRoot, version string, cached bool) (dir string, goModData, goSumData []byte, pkgPaths []string, diagnostics []string, err error) { + defer func() { + if err != nil { + if cached { + err = fmt.Errorf("preparing to load packages for %s@%s: %w", modPath, version, err) + } else { + err = fmt.Errorf("preparing to load packages for %s: %w", modPath, err) + } + } + }() + + if module.Check(modPath, version) != nil { + // If no version is proposed or if the version isn't valid, use a fake + // version that matches the module's major version suffix. If the version + // is invalid, that will be reported elsewhere. + version = "v0.0.0-gorelease" + if _, pathMajor, _ := module.SplitPathVersion(modPath); pathMajor != "" { + version = pathMajor[1:] + ".0.0-gorelease" + } + } + + dir, err = ioutil.TempDir("", "gorelease-load") + if err != nil { + return "", nil, nil, nil, nil, err + } + + f := &modfile.File{} + f.AddModuleStmt("gorelease-load-module") + f.AddRequire(modPath, version) + if !cached { + f.AddReplace(modPath, version, modRoot, "") + } + if modFile != nil { + if modFile.Go != nil { + f.AddGoStmt(modFile.Go.Version) + } + for _, r := range modFile.Require { + f.AddRequire(r.Mod.Path, r.Mod.Version) + } + } + goModData, err = f.Format() + if err != nil { + return "", nil, nil, nil, nil, err + } + if err := ioutil.WriteFile(filepath.Join(dir, "go.mod"), goModData, 0666); err != nil { + return "", nil, nil, nil, nil, err + } + + goSumData, err = ioutil.ReadFile(filepath.Join(modRoot, "go.sum")) + if err != nil && !os.IsNotExist(err) { + return "", nil, nil, nil, nil, err + } + if err := ioutil.WriteFile(filepath.Join(dir, "go.sum"), goSumData, 0666); err != nil { + return "", nil, nil, nil, nil, err + } + + // Add a .go file with requirements, so that `go get` won't blat + // requirements. + fakeImports := &strings.Builder{} + fmt.Fprint(fakeImports, "package tmp\n") + imps, err := collectImportPaths(modPath, modRoot) + if err != nil { + return "", nil, nil, nil, nil, err + } + for _, imp := range imps { + fmt.Fprintf(fakeImports, "import _ %q\n", imp) + } + if err := ioutil.WriteFile(filepath.Join(dir, "tmp.go"), []byte(fakeImports.String()), 0666); err != nil { + return "", nil, nil, nil, nil, err + } + + // Add missing requirements. + cmd := exec.CommandContext(ctx, "go", "get", "-d", ".") + cmd.Env = copyEnv(ctx, cmd.Env) + cmd.Dir = dir + if _, err := cmd.Output(); err != nil { + return "", nil, nil, nil, nil, fmt.Errorf("looking for missing dependencies: %w", cleanCmdError(err)) + } + + // Report new requirements in go.mod. + goModPath := filepath.Join(dir, "go.mod") + loadReqs := func(data []byte) (reqs []module.Version, err error) { + modFile, err := modfile.ParseLax(goModPath, data, nil) + if err != nil { + return nil, err + } + for _, r := range modFile.Require { + reqs = append(reqs, r.Mod) + } + return reqs, nil + } + + oldReqs, err := loadReqs(goModData) + if err != nil { + return "", nil, nil, nil, nil, err + } + newGoModData, err := ioutil.ReadFile(goModPath) + if err != nil { + return "", nil, nil, nil, nil, err + } + newReqs, err := loadReqs(newGoModData) + if err != nil { + return "", nil, nil, nil, nil, err + } + + oldMap := make(map[module.Version]bool) + for _, req := range oldReqs { + oldMap[req] = true + } + var missing []module.Version + for _, req := range newReqs { + // Ignore cyclic imports, since a module never needs to require itself. + if req.Path == modPath { + continue + } + if !oldMap[req] { + missing = append(missing, req) + } + } + + if len(missing) > 0 { + var missingReqs []string + for _, m := range missing { + missingReqs = append(missingReqs, m.String()) + } + diagnostics = append(diagnostics, fmt.Sprintf("go.mod: the following requirements are needed\n\t%s\nRun 'go mod tidy' to add missing requirements.", strings.Join(missingReqs, "\n\t"))) + return dir, goModData, goSumData, imps, diagnostics, nil + } + + // Cached modules may have no go.sum. + // We skip comparison because a downloaded module is outside the user's + // control. + if !cached { + // Check if 'go get' added new hashes to go.sum. + goSumPath := filepath.Join(dir, "go.sum") + newGoSumData, err := ioutil.ReadFile(goSumPath) + if err != nil { + if !os.IsNotExist(err) { + return "", nil, nil, nil, nil, err + } + // If the sum doesn't exist, that's ok: we'll treat "no go.sum" like + // "empty go.sum". + } + + if !sumsMatchIgnoringPath(string(goSumData), string(newGoSumData), modPath) { + diagnostics = append(diagnostics, "go.sum: one or more sums are missing. Run 'go mod tidy' to add missing sums.") + } + } + + return dir, goModData, goSumData, imps, diagnostics, nil +} + +// sumsMatchIgnoringPath checks whether the two sums match. It ignores any lines +// which contains the given modPath. +func sumsMatchIgnoringPath(sum1, sum2, modPathToIgnore string) bool { + lines1 := make(map[string]bool) + for _, line := range strings.Split(string(sum1), "\n") { + if line == "" { + continue + } + lines1[line] = true + } + for _, line := range strings.Split(string(sum2), "\n") { + if line == "" { + continue + } + parts := strings.Fields(line) + if len(parts) < 1 { + panic(fmt.Sprintf("go.sum malformed: unexpected line %s", line)) + } + if parts[0] == modPathToIgnore { + continue + } + + if !lines1[line] { + return false + } + } + + lines2 := make(map[string]bool) + for _, line := range strings.Split(string(sum2), "\n") { + if line == "" { + continue + } + lines2[line] = true + } + for _, line := range strings.Split(string(sum1), "\n") { + if line == "" { + continue + } + parts := strings.Fields(line) + if len(parts) < 1 { + panic(fmt.Sprintf("go.sum malformed: unexpected line %s", line)) + } + if parts[0] == modPathToIgnore { + continue + } + + if !lines2[line] { + return false + } + } + + return true +} + +// collectImportPaths visits the given root and traverses its directories +// recursively, collecting the import paths of all importable packages in each +// directory along the way. +// +// modPath is the module path. +// root is the root directory of the module to collect imports for (the root +// of the modPath module). +// +// Note: the returned importPaths will include main if it exists in root. +func collectImportPaths(modPath, root string) (importPaths []string, _ error) { + err := filepath.Walk(root, func(walkPath string, fi os.FileInfo, err error) error { + if err != nil { + return err + } + + // Avoid .foo, _foo, and testdata subdirectory trees. + if !fi.IsDir() { + return nil + } + base := filepath.Base(walkPath) + if strings.HasPrefix(base, ".") || strings.HasPrefix(base, "_") || base == "testdata" || base == "internal" { + return filepath.SkipDir + } + + p, err := build.Default.ImportDir(walkPath, 0) + if err != nil { + if nogoErr := (*build.NoGoError)(nil); errors.As(err, &nogoErr) { + // No .go files found in directory. That's ok, we'll keep + // searching. + return nil + } + return err + } + + // Construct the import path. + importPath := path.Join(modPath, filepath.ToSlash(trimFilePathPrefix(p.Dir, root))) + importPaths = append(importPaths, importPath) + + return nil + }) + if err != nil { + return nil, fmt.Errorf("listing packages in %s: %v", root, err) + } + + return importPaths, nil +} + +// loadPackages returns a list of all packages in the module modPath, sorted by +// package path. modRoot is the module root directory, but packages are loaded +// from loadDir, which must contain go.mod and go.sum containing goModData and +// goSumData. +// +// We load packages from a temporary external module so that replace and exclude +// directives are not applied. The loading process may also modify go.mod and +// go.sum, and we want to detect and report differences. +// +// Package loading errors will be returned in the Errors field of each package. +// Other diagnostics (such as the go.sum file being incomplete) will be +// returned through diagnostics. +// err will be non-nil in case of a fatal error that prevented packages +// from being loaded. +func loadPackages(ctx context.Context, modPath, modRoot, loadDir string, goModData, goSumData []byte, pkgPaths []string) (pkgs []*packages.Package, diagnostics []string, err error) { + // Load packages. + // TODO(jayconrod): if there are errors loading packages in the release + // version, try loading in the release directory. Errors there would imply + // that packages don't load without replace / exclude directives. + cfg := &packages.Config{ + Mode: packages.NeedName | packages.NeedTypes | packages.NeedImports | packages.NeedDeps, + Dir: loadDir, + Context: ctx, + } + cfg.Env = copyEnv(ctx, cfg.Env) + if len(pkgPaths) > 0 { + pkgs, err = packages.Load(cfg, pkgPaths...) + if err != nil { + return nil, nil, err + } + } + + // Sort the returned packages by path. + // packages.Load makes no guarantee about the order of returned packages. + sort.Slice(pkgs, func(i, j int) bool { + return pkgs[i].PkgPath < pkgs[j].PkgPath + }) + + // Trim modRoot from file paths in errors. + prefix := modRoot + string(os.PathSeparator) + for _, pkg := range pkgs { + for i := range pkg.Errors { + pkg.Errors[i].Pos = strings.TrimPrefix(pkg.Errors[i].Pos, prefix) + } + } + + return pkgs, diagnostics, nil +} + +type packagePair struct { + base, release *packages.Package +} + +// zipPackages combines two lists of packages, sorted by package path, +// and returns a sorted list of pairs of packages with matching paths. +// If a package is in one list but not the other (because it was added or +// removed between releases), a pair will be returned with a nil +// base or release field. +func zipPackages(baseModPath string, basePkgs []*packages.Package, releaseModPath string, releasePkgs []*packages.Package) []packagePair { + baseIndex, releaseIndex := 0, 0 + var pairs []packagePair + for baseIndex < len(basePkgs) || releaseIndex < len(releasePkgs) { + var basePkg, releasePkg *packages.Package + var baseSuffix, releaseSuffix string + if baseIndex < len(basePkgs) { + basePkg = basePkgs[baseIndex] + baseSuffix = trimPathPrefix(basePkg.PkgPath, baseModPath) + } + if releaseIndex < len(releasePkgs) { + releasePkg = releasePkgs[releaseIndex] + releaseSuffix = trimPathPrefix(releasePkg.PkgPath, releaseModPath) + } + + var pair packagePair + if basePkg != nil && (releasePkg == nil || baseSuffix < releaseSuffix) { + // Package removed + pair = packagePair{basePkg, nil} + baseIndex++ + } else if releasePkg != nil && (basePkg == nil || releaseSuffix < baseSuffix) { + // Package added + pair = packagePair{nil, releasePkg} + releaseIndex++ + } else { + // Matched packages. + pair = packagePair{basePkg, releasePkg} + baseIndex++ + releaseIndex++ + } + pairs = append(pairs, pair) + } + return pairs +} + +// findSelectedVersion returns the highest version of the given modPath at +// modDir, if a module cycle exists. modDir should be a writable directory +// containing the go.mod for modPath. +// +// If no module cycle exists, it returns empty string. +func findSelectedVersion(ctx context.Context, modDir, modPath string) (latestVersion string, err error) { + defer func() { + if err != nil { + err = fmt.Errorf("could not find selected version for %s: %v", modPath, err) + } + }() + + cmd := exec.CommandContext(ctx, "go", "list", "-m", "-f", "{{.Version}}", "--", modPath) + cmd.Env = copyEnv(ctx, cmd.Env) + cmd.Dir = modDir + out, err := cmd.Output() + if err != nil { + return "", cleanCmdError(err) + } + return strings.TrimSpace(string(out)), nil +} + +func copyEnv(ctx context.Context, current []string) []string { + env, ok := ctx.Value("env").([]string) + if !ok { + return current + } + clone := make([]string, len(env)) + copy(clone, env) + return clone +} + +// loadRetractions lists all retracted deps found at the modRoot. +func loadRetractions(ctx context.Context, modRoot string) ([]string, error) { + cmd := exec.CommandContext(ctx, "go", "list", "-json", "-m", "-u", "all") + if env, ok := ctx.Value("env").([]string); ok { + cmd.Env = env + } + cmd.Dir = modRoot + out, err := cmd.Output() + if err != nil { + return nil, cleanCmdError(err) + } + + var retracted []string + type message struct { + Path string + Version string + Retracted []string + } + + dec := json.NewDecoder(bytes.NewBuffer(out)) + for { + var m message + if err := dec.Decode(&m); err == io.EOF { + break + } else if err != nil { + return nil, err + } + if len(m.Retracted) == 0 { + continue + } + rationale, ok := shortRetractionRationale(m.Retracted) + if ok { + retracted = append(retracted, fmt.Sprintf("required module %s@%s retracted by module author: %s", m.Path, m.Version, rationale)) + } else { + retracted = append(retracted, fmt.Sprintf("required module %s@%s retracted by module author", m.Path, m.Version)) + } + } + + return retracted, nil +} + +// ShortRetractionRationale returns a retraction rationale string that is safe +// to print in a terminal. It returns hard-coded strings if the rationale +// is empty, too long, or contains non-printable characters. +// +// It returns true if the rationale was printable, and false if it was not (too +// long, contains graphics, etc). +func shortRetractionRationale(rationales []string) (string, bool) { + if len(rationales) == 0 { + return "", false + } + rationale := rationales[0] + + const maxRationaleBytes = 500 + if i := strings.Index(rationale, "\n"); i >= 0 { + rationale = rationale[:i] + } + rationale = strings.TrimSpace(rationale) + if rationale == "" || rationale == "retracted by module author" { + return "", false + } + if len(rationale) > maxRationaleBytes { + return "", false + } + for _, r := range rationale { + if !unicode.IsGraphic(r) && !unicode.IsSpace(r) { + return "", false + } + } + // NOTE: the go.mod parser rejects invalid UTF-8, so we don't check that here. + return rationale, true +} + +// hasGitUncommittedChanges checks if the given directory has uncommitteed git +// changes. +func hasGitUncommittedChanges(dir string) (bool, error) { + stdout := &bytes.Buffer{} + cmd := exec.Command("git", "status", "--porcelain") + cmd.Dir = dir + cmd.Stdout = stdout + if err := cmd.Run(); err != nil { + return false, cleanCmdError(err) + } + return stdout.Len() != 0, nil +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/gorelease_test.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/gorelease_test.go new file mode 100644 index 0000000..216c747 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/gorelease_test.go @@ -0,0 +1,504 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "context" + "flag" + "fmt" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "sync" + "testing" + + "golang.org/x/mod/module" + "golang.org/x/tools/txtar" +) + +var ( + testwork = flag.Bool("testwork", false, "preserve work directory") + updateGolden = flag.Bool("u", false, "update expected text in test files instead of failing") +) + +var hasGitCache struct { + once sync.Once + found bool +} + +// hasGit reports whether the git executable exists on the PATH. +func hasGit() bool { + hasGitCache.once.Do(func() { + if _, err := exec.LookPath("git"); err != nil { + return + } + hasGitCache.found = true + }) + return hasGitCache.found +} + +// prepareProxy creates a proxy dir and returns an associated ctx. +// +// proxyVersions must be a map of module version to true. If proxyVersions is +// empty, all modules in mod/ will be included in the proxy list. If proxy +// versions is non-empty, only those modules in mod/ that match an entry in +// proxyVersions will be included. +// +// ctx must be used in runRelease. +// cleanup must be called when the relevant tests are finished. +func prepareProxy(proxyVersions map[module.Version]bool, tests []*test) (ctx context.Context, cleanup func(), _ error) { + env := append(os.Environ(), "GO111MODULE=on", "GOSUMDB=off") + + proxyDir, proxyURL, err := buildProxyDir(proxyVersions, tests) + if err != nil { + return nil, nil, fmt.Errorf("error building proxy dir: %v", err) + } + env = append(env, fmt.Sprintf("GOPROXY=%s", proxyURL)) + + cacheDir, err := ioutil.TempDir("", "gorelease_test-gocache") + if err != nil { + return nil, nil, err + } + env = append(env, fmt.Sprintf("GOPATH=%s", cacheDir)) + + return context.WithValue(context.Background(), "env", env), func() { + if *testwork { + fmt.Fprintf(os.Stderr, "test cache dir: %s\n", cacheDir) + fmt.Fprintf(os.Stderr, "test proxy dir: %s\ntest proxy URL: %s\n", proxyDir, proxyURL) + } else { + cmd := exec.Command("go", "clean", "-modcache") + cmd.Env = env + if err := cmd.Run(); err != nil { + fmt.Fprintln(os.Stderr, fmt.Errorf("error running go clean: %v", err)) + } + + if err := os.RemoveAll(cacheDir); err != nil { + fmt.Fprintln(os.Stderr, fmt.Errorf("error removing cache dir %s: %v", cacheDir, err)) + } + if err := os.RemoveAll(proxyDir); err != nil { + fmt.Fprintln(os.Stderr, fmt.Errorf("error removing proxy dir %s: %v", proxyDir, err)) + } + } + }, nil +} + +// test describes an individual test case, written as a .test file in the +// testdata directory. +// +// Each test is a txtar archive (see golang.org/x/tools/txtar). The comment +// section (before the first file) contains a sequence of key=value pairs +// (one per line) that configure the test. +// +// Most tests include a file named "want". The output of gorelease is compared +// against this file. If the -u flag is set, this file is replaced with the +// actual output of gorelease, and the test is written back to disk. This is +// useful for updating tests after cosmetic changes. +type test struct { + txtar.Archive + + // testPath is the name of the .test file describing the test. + testPath string + + // modPath (set with mod=...) is the path of the module being tested. Used + // to retrieve files from the test proxy. + modPath string + + // version (set with version=...) is the name of a version to check out + // from the test proxy into the working directory. Some tests use this + // instead of specifying files they need in the txtar archive. + version string + + // baseVersion (set with base=...) is the value of the -base flag to pass + // to gorelease. + baseVersion string + + // releaseVersion (set with release=...) is the value of the -version flag + // to pass to gorelease. + releaseVersion string + + // dir (set with dir=...) is the directory where gorelease should be invoked. + // If unset, gorelease is invoked in the directory where the txtar archive + // is unpacked. This is useful for invoking gorelease in a subdirectory. + dir string + + // wantError (set with error=...) is true if the test expects a hard error + // (returned by runRelease). + wantError bool + + // wantSuccess (set with success=...) is true if the test expects a report + // to be returned without errors or diagnostics. True by default. + wantSuccess bool + + // skip (set with skip=...) is non-empty if the test should be skipped. + skip string + + // want is set to the contents of the file named "want" in the txtar archive. + want []byte + + // proxyVersions is used to set the exact contents of the GOPROXY. + // + // If empty, all of testadata/mod/ will be included in the proxy. + // If it is not empty, each entry must be of the form <modpath>@v<version> + // and exist in testdata/mod/. + proxyVersions map[module.Version]bool + + // vcs is used to set the VCS that the root of the test should + // emulate. Allowed values are git, and hg. + vcs string +} + +// readTest reads and parses a .test file with the given name. +func readTest(testPath string) (*test, error) { + arc, err := txtar.ParseFile(testPath) + if err != nil { + return nil, err + } + t := &test{ + Archive: *arc, + testPath: testPath, + wantSuccess: true, + } + + for n, line := range bytes.Split(t.Comment, []byte("\n")) { + lineNum := n + 1 + if i := bytes.IndexByte(line, '#'); i >= 0 { + line = line[:i] + } + line = bytes.TrimSpace(line) + if len(line) == 0 { + continue + } + + var key, value string + if i := bytes.IndexByte(line, '='); i < 0 { + return nil, fmt.Errorf("%s:%d: no '=' found", testPath, lineNum) + } else { + key = strings.TrimSpace(string(line[:i])) + value = strings.TrimSpace(string(line[i+1:])) + } + switch key { + case "mod": + t.modPath = value + case "version": + t.version = value + case "base": + t.baseVersion = value + case "release": + t.releaseVersion = value + case "dir": + t.dir = value + case "skip": + t.skip = value + case "success": + t.wantSuccess, err = strconv.ParseBool(value) + if err != nil { + return nil, fmt.Errorf("%s:%d: %v", testPath, lineNum, err) + } + case "error": + t.wantError, err = strconv.ParseBool(value) + if err != nil { + return nil, fmt.Errorf("%s:%d: %v", testPath, lineNum, err) + } + case "proxyVersions": + if len(value) == 0 { + break + } + proxyVersions := make(map[module.Version]bool) + parts := strings.Split(value, ",") + for _, modpathWithVersion := range parts { + vParts := strings.Split(modpathWithVersion, "@") + if len(vParts) != 2 { + return nil, fmt.Errorf("proxyVersions entry %s is invalid: it should be of the format <modpath>@v<semver> (ex: github.com/foo/bar@v1.2.3)", modpathWithVersion) + } + modPath, version := vParts[0], vParts[1] + mv := module.Version{ + Path: modPath, + Version: version, + } + proxyVersions[mv] = true + } + t.proxyVersions = proxyVersions + case "vcs": + t.vcs = value + default: + return nil, fmt.Errorf("%s:%d: unknown key: %q", testPath, lineNum, key) + } + } + if t.modPath == "" && (t.version != "" || (t.baseVersion != "" && t.baseVersion != "none")) { + return nil, fmt.Errorf("%s: version or base was set but mod was not set", testPath) + } + + haveFiles := false + for _, f := range t.Files { + if f.Name == "want" { + t.want = bytes.TrimSpace(f.Data) + continue + } + haveFiles = true + } + + if haveFiles && t.version != "" { + return nil, fmt.Errorf("%s: version is set but files are present", testPath) + } + + return t, nil +} + +// updateTest replaces the contents of the file named "want" within a test's +// txtar archive, then formats and writes the test file. +func updateTest(t *test, want []byte) error { + var wantFile *txtar.File + for i := range t.Files { + if t.Files[i].Name == "want" { + wantFile = &t.Files[i] + break + } + } + if wantFile == nil { + t.Files = append(t.Files, txtar.File{Name: "want"}) + wantFile = &t.Files[len(t.Files)-1] + } + + wantFile.Data = want + data := txtar.Format(&t.Archive) + return ioutil.WriteFile(t.testPath, data, 0666) +} + +func TestRelease(t *testing.T) { + testPaths, err := filepath.Glob(filepath.FromSlash("testdata/*/*.test")) + if err != nil { + t.Fatal(err) + } + if len(testPaths) == 0 { + t.Fatal("no .test files found in testdata directory") + } + + var tests []*test + for _, testPath := range testPaths { + test, err := readTest(testPath) + if err != nil { + t.Fatal(err) + } + tests = append(tests, test) + } + + defaultContext, cleanup, err := prepareProxy(nil, tests) + if err != nil { + t.Fatalf("preparing test proxy: %v", err) + } + t.Cleanup(cleanup) + + for _, test := range tests { + testName := strings.TrimSuffix(strings.TrimPrefix(filepath.ToSlash(test.testPath), "testdata/"), ".test") + t.Run(testName, testRelease(defaultContext, tests, test)) + } +} + +func TestRelease_gitRepo_uncommittedChanges(t *testing.T) { + ctx := context.Background() + buf := &bytes.Buffer{} + releaseDir, err := ioutil.TempDir("", "") + if err != nil { + t.Fatal(err) + } + + goModInit(t, releaseDir) + gitInit(t, releaseDir) + + // Create an uncommitted change. + bContents := `package b +const B = "b"` + if err := ioutil.WriteFile(filepath.Join(releaseDir, "b.go"), []byte(bContents), 0644); err != nil { + t.Fatal(err) + } + + success, err := runRelease(ctx, buf, releaseDir, nil) + if got, want := err.Error(), fmt.Sprintf("repo %s has uncommitted changes", releaseDir); got != want { + t.Errorf("runRelease:\ngot error:\n%q\nwant error\n%q", got, want) + } + if success { + t.Errorf("runRelease: expected failure, got success") + } +} + +func testRelease(ctx context.Context, tests []*test, test *test) func(t *testing.T) { + return func(t *testing.T) { + if test.skip != "" { + t.Skip(test.skip) + } + + t.Parallel() + + if len(test.proxyVersions) > 0 { + var cleanup func() + var err error + ctx, cleanup, err = prepareProxy(test.proxyVersions, tests) + if err != nil { + t.Fatalf("preparing test proxy: %v", err) + } + t.Cleanup(cleanup) + } + + // Extract the files in the release version. They may be part of the + // test archive or in testdata/mod. + testDir, err := ioutil.TempDir("", "") + if err != nil { + t.Fatal(err) + } + if *testwork { + fmt.Fprintf(os.Stderr, "test dir: %s\n", testDir) + } else { + t.Cleanup(func() { + os.RemoveAll(testDir) + }) + } + + var arc *txtar.Archive + if test.version != "" { + arcBase := fmt.Sprintf("%s_%s.txt", strings.ReplaceAll(test.modPath, "/", "_"), test.version) + arcPath := filepath.Join("testdata/mod", arcBase) + var err error + arc, err = txtar.ParseFile(arcPath) + if err != nil { + t.Fatal(err) + } + } else { + arc = &test.Archive + } + if err := extractTxtar(testDir, arc); err != nil { + t.Fatal(err) + } + + switch test.vcs { + case "git": + // Convert testDir to a git repository with a single commit, to + // simulate a real user's module-in-a-git-repo. + gitInit(t, testDir) + case "hg": + // Convert testDir to a mercurial repository to simulate a real + // user's module-in-a-hg-repo. + hgInit(t, testDir) + case "": + // No VCS. + default: + t.Fatalf("unknown vcs %q", test.vcs) + } + + // Generate the report and compare it against the expected text. + var args []string + if test.baseVersion != "" { + args = append(args, "-base="+test.baseVersion) + } + if test.releaseVersion != "" { + args = append(args, "-version="+test.releaseVersion) + } + buf := &bytes.Buffer{} + releaseDir := filepath.Join(testDir, test.dir) + success, err := runRelease(ctx, buf, releaseDir, args) + if err != nil { + if !test.wantError { + t.Fatalf("unexpected error: %v", err) + } + if errMsg := []byte(err.Error()); !bytes.Equal(errMsg, bytes.TrimSpace(test.want)) { + if *updateGolden { + if err := updateTest(test, errMsg); err != nil { + t.Fatal(err) + } + } else { + t.Fatalf("got error: %s; want error: %s", errMsg, test.want) + } + } + return + } + if test.wantError { + t.Fatalf("got success; want error %s", test.want) + } + + got := bytes.TrimSpace(buf.Bytes()) + if filepath.Separator != '/' { + got = bytes.ReplaceAll(got, []byte{filepath.Separator}, []byte{'/'}) + } + if !bytes.Equal(got, test.want) { + if *updateGolden { + if err := updateTest(test, got); err != nil { + t.Fatal(err) + } + } else { + t.Fatalf("got:\n%s\n\nwant:\n%s", got, test.want) + } + } + if success != test.wantSuccess { + t.Fatalf("got success: %v; want success %v", success, test.wantSuccess) + } + } +} + +// hgInit initialises a directory as a mercurial repo. +func hgInit(t *testing.T, dir string) { + t.Helper() + + if err := os.Mkdir(filepath.Join(dir, ".hg"), 0777); err != nil { + t.Fatal(err) + } + + if err := ioutil.WriteFile(filepath.Join(dir, ".hg", "branch"), []byte("default"), 0777); err != nil { + t.Fatal(err) + } +} + +// gitInit initialises a directory as a git repo, and adds a simple commit. +func gitInit(t *testing.T, dir string) { + t.Helper() + + if !hasGit() { + t.Skip("PATH does not contain git") + } + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + + for _, args := range [][]string{ + {"git", "init"}, + {"git", "config", "user.name", "Gopher"}, + {"git", "config", "user.email", "gopher@golang.org"}, + {"git", "checkout", "-b", "test"}, + {"git", "add", "-A"}, + {"git", "commit", "-m", "test"}, + } { + cmd := exec.Command(args[0], args[1:]...) + cmd.Dir = dir + cmd.Stdout = stdout + cmd.Stderr = stderr + if err := cmd.Run(); err != nil { + cmdArgs := strings.Join(args, " ") + t.Fatalf("%s\n%s\nerror running %q on dir %s: %v", stdout.String(), stderr.String(), cmdArgs, dir, err) + } + } +} + +// goModInit runs `go mod init` in the given directory. +func goModInit(t *testing.T, dir string) { + t.Helper() + + aContents := `package a +const A = "a"` + if err := ioutil.WriteFile(filepath.Join(dir, "a.go"), []byte(aContents), 0644); err != nil { + t.Fatal(err) + } + + stdout := &bytes.Buffer{} + stderr := &bytes.Buffer{} + cmd := exec.Command("go", "mod", "init", "example.com/uncommitted") + cmd.Stdout = stdout + cmd.Stderr = stderr + cmd.Dir = dir + if err := cmd.Run(); err != nil { + t.Fatalf("error running `go mod init`: %s, %v", stderr.String(), err) + } +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/path.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/path.go new file mode 100644 index 0000000..bfe1f20 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/path.go @@ -0,0 +1,87 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "path/filepath" + "strings" +) + +// hasPathPrefix reports whether the slash-separated path s +// begins with the elements in prefix. +// Copied from cmd/go/internal/str.HasPathPrefix. +func hasPathPrefix(s, prefix string) bool { + if len(s) == len(prefix) { + return s == prefix + } + if prefix == "" { + return true + } + if len(s) > len(prefix) { + if prefix[len(prefix)-1] == '/' || s[len(prefix)] == '/' { + return s[:len(prefix)] == prefix + } + } + return false +} + +// hasFilePathPrefix reports whether the filesystem path s +// begins with the elements in prefix. +// Copied from cmd/go/internal/str.HasFilePathPrefix. +func hasFilePathPrefix(s, prefix string) bool { + sv := strings.ToUpper(filepath.VolumeName(s)) + pv := strings.ToUpper(filepath.VolumeName(prefix)) + s = s[len(sv):] + prefix = prefix[len(pv):] + switch { + default: + return false + case pv != "" && sv != pv: + return false + case len(s) == len(prefix): + return s == prefix + case prefix == "": + return true + case len(s) > len(prefix): + if prefix[len(prefix)-1] == filepath.Separator { + return strings.HasPrefix(s, prefix) + } + return s[len(prefix)] == filepath.Separator && s[:len(prefix)] == prefix + } +} + +// trimFilePathPrefix returns the given filesystem path s without the leading +// prefix. +func trimFilePathPrefix(s, prefix string) string { + sv := strings.ToUpper(filepath.VolumeName(s)) + pv := strings.ToUpper(filepath.VolumeName(prefix)) + s = s[len(sv):] + prefix = prefix[len(pv):] + + if !hasFilePathPrefix(s, prefix) || len(prefix) == 0 { + return s + } + if len(s) == len(prefix) { + return "" + } + if prefix[len(prefix)-1] == filepath.Separator { + return strings.TrimPrefix(s, prefix) + } + return s[len(prefix)+1:] +} + +// trimPathPrefix returns p without the leading prefix. Unlike +// strings.TrimPrefix, the prefix will only match on slash-separted component +// boundaries, so trimPathPrefix("aa/b", "aa") returns "b", but +// trimPathPrefix("aa/b", "a") returns "aa/b". +func trimPathPrefix(p, prefix string) string { + if prefix == "" { + return p + } + if prefix == p { + return "" + } + return strings.TrimPrefix(p, prefix+"/") +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/path_test.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/path_test.go new file mode 100644 index 0000000..57dfd98 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/path_test.go @@ -0,0 +1,227 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "runtime" + "testing" +) + +func TestHasPathPrefix(t *testing.T) { + for _, test := range []struct { + desc, path, prefix string + want bool + }{ + { + desc: "empty_prefix", + path: "a/b", + prefix: "", + want: true, + }, { + desc: "partial_prefix", + path: "a/b", + prefix: "a", + want: true, + }, { + desc: "full_prefix", + path: "a/b", + prefix: "a/b", + want: true, + }, { + desc: "partial_component", + path: "aa/b", + prefix: "a", + want: false, + }, + } { + t.Run(test.desc, func(t *testing.T) { + if got := hasPathPrefix(test.path, test.prefix); got != test.want { + t.Errorf("hasPathPrefix(%q, %q): got %v, want %v", test.path, test.prefix, got, test.want) + } + }) + } +} + +func TestHasFilePathPrefix(t *testing.T) { + type test struct { + desc, path, prefix string + want bool + } + var tests []test + if runtime.GOOS == "windows" { + tests = []test{ + { + desc: "empty_prefix", + path: `c:\a\b`, + prefix: "", + want: true, + }, { + desc: "drive_prefix", + path: `c:\a\b`, + prefix: `c:\`, + want: true, + }, { + desc: "partial_prefix", + path: `c:\a\b`, + prefix: `c:\a`, + want: true, + }, { + desc: "full_prefix", + path: `c:\a\b`, + prefix: `c:\a\b`, + want: true, + }, { + desc: "partial_component", + path: `c:\aa\b`, + prefix: `c:\a`, + want: false, + }, + } + } else { + tests = []test{ + { + desc: "empty_prefix", + path: "/a/b", + prefix: "", + want: true, + }, { + desc: "partial_prefix", + path: "/a/b", + prefix: "/a", + want: true, + }, { + desc: "full_prefix", + path: "/a/b", + prefix: "/a/b", + want: true, + }, { + desc: "partial_component", + path: "/aa/b", + prefix: "/a", + want: false, + }, + } + } + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + if got := hasFilePathPrefix(test.path, test.prefix); got != test.want { + t.Errorf("hasFilePathPrefix(%q, %q): got %v, want %v", test.path, test.prefix, got, test.want) + } + }) + } +} + +func TestTrimFilePathPrefix(t *testing.T) { + type test struct { + desc, path, prefix, want string + } + var tests []test + if runtime.GOOS == "windows" { + tests = []test{ + // Note: these two cases in which the result preserves the leading \ + // don't come up in reality in gorelease. That's because prefix is + // always far to the right of the path parts (ex github.com/foo/bar + // in C:\Users\foo\AppData\Local\Temp\...\github.com\foo\bar). + { + desc: "empty_prefix", + path: `c:\a\b`, + prefix: "", + want: `\a\b`, + }, { + desc: "partial_component", + path: `c:\aa\b`, + prefix: `c:\a`, + want: `\aa\b`, + }, + + { + desc: "drive_prefix", + path: `c:\a\b`, + prefix: `c:\`, + want: `a\b`, + }, { + desc: "partial_prefix", + path: `c:\a\b`, + prefix: `c:\a`, + want: `b`, + }, { + desc: "full_prefix", + path: `c:\a\b`, + prefix: `c:\a\b`, + want: "", + }, + } + } else { + tests = []test{ + { + desc: "empty_prefix", + path: "/a/b", + prefix: "", + want: "/a/b", + }, { + desc: "partial_prefix", + path: "/a/b", + prefix: "/a", + want: "b", + }, { + desc: "full_prefix", + path: "/a/b", + prefix: "/a/b", + want: "", + }, { + desc: "partial_component", + path: "/aa/b", + prefix: "/a", + want: "/aa/b", + }, + } + } + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + if got := trimFilePathPrefix(test.path, test.prefix); got != test.want { + t.Errorf("hasFilePathPrefix(%q, %q): got %v, want %v", test.path, test.prefix, got, test.want) + } + }) + } +} + +func TestTrimPathPrefix(t *testing.T) { + for _, test := range []struct { + desc, path, prefix, want string + }{ + { + desc: "empty_prefix", + path: "a/b", + prefix: "", + want: "a/b", + }, { + desc: "abs_empty_prefix", + path: "/a/b", + prefix: "", + want: "/a/b", + }, { + desc: "partial_prefix", + path: "a/b", + prefix: "a", + want: "b", + }, { + desc: "full_prefix", + path: "a/b", + prefix: "a/b", + want: "", + }, { + desc: "partial_component", + path: "aa/b", + prefix: "a", + want: "aa/b", + }, + } { + t.Run(test.desc, func(t *testing.T) { + if got := trimPathPrefix(test.path, test.prefix); got != test.want { + t.Errorf("trimPathPrefix(%q, %q): got %q, want %q", test.path, test.prefix, got, test.want) + } + }) + } +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/proxy_test.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/proxy_test.go new file mode 100644 index 0000000..d91d983 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/proxy_test.go @@ -0,0 +1,207 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "sort" + "strings" + "time" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" + "golang.org/x/mod/zip" + "golang.org/x/tools/txtar" +) + +// buildProxyDir constructs a temporary directory suitable for use as a +// module proxy with a file:// URL. The caller is responsible for deleting +// the directory when it's no longer needed. +// +// proxyVersions must be a map of module version true. If proxyVersions is +// empty, all modules in mod/ will be included in the proxy list. If proxy +// versions is non-empty, only those modules in mod/ that match an entry in +// proxyVersions will be included. +func buildProxyDir(proxyVersions map[module.Version]bool, tests []*test) (proxyDir, proxyURL string, err error) { + proxyDir, err = ioutil.TempDir("", "gorelease-proxy") + if err != nil { + return "", "", err + } + + txtarPaths, err := filepath.Glob(filepath.FromSlash("testdata/mod/*.txt")) + if err != nil { + return "", "", err + } + + // Map of modPath to versions for that modPath. + versionLists := make(map[string][]string) + + for _, t := range tests { + versionLists[t.modPath] = []string{} + modDir := filepath.Join(proxyDir, t.modPath, "@v") + if err := os.MkdirAll(modDir, 0777); err != nil { + return "", "", err + } + } + + for _, txtarPath := range txtarPaths { + base := filepath.Base(txtarPath) + stem := base[:len(base)-len(".txt")] + i := strings.LastIndexByte(base, '_') + if i < 0 { + return "", "", fmt.Errorf("invalid module archive: %s", base) + } + modPath := strings.ReplaceAll(stem[:i], "_", "/") + version := stem[i+1:] + mv := module.Version{ + Path: modPath, + Version: version, + } + + // User has supplied proxyVersions. Honor proxy versions by only + // accepting those versions supplied in proxyVersions. + if len(proxyVersions) > 0 { + if !proxyVersions[mv] { + // modPath@version is not in proxyVersions: skip. + continue + } + } + + versionLists[modPath] = append(versionLists[modPath], version) + + modDir := filepath.Join(proxyDir, modPath, "@v") + if err := os.MkdirAll(modDir, 0777); err != nil { + return "", "", err + } + + arc, err := txtar.ParseFile(txtarPath) + if err != nil { + return "", "", err + } + + isCanonical := version == module.CanonicalVersion(version) + var zipContents []zip.File + var haveInfo, haveMod bool + var goMod txtar.File + for _, af := range arc.Files { + if !isCanonical && af.Name != ".info" { + return "", "", fmt.Errorf("%s: version is non-canonical but contains files other than .info", txtarPath) + } + if af.Name == ".info" || af.Name == ".mod" { + if af.Name == ".info" { + haveInfo = true + } else { + haveMod = true + } + outPath := filepath.Join(modDir, version+af.Name) + if err := ioutil.WriteFile(outPath, af.Data, 0666); err != nil { + return "", "", err + } + continue + } + if af.Name == "go.mod" { + goMod = af + } + + zipContents = append(zipContents, txtarFile{af}) + } + if !isCanonical && !haveInfo { + return "", "", fmt.Errorf("%s: version is non-canonical but does not have .info", txtarPath) + } + + if !haveInfo { + outPath := filepath.Join(modDir, version+".info") + outContent := fmt.Sprintf(`{"Version":"%s"}`, version) + if err := ioutil.WriteFile(outPath, []byte(outContent), 0666); err != nil { + return "", "", err + } + } + if !haveMod && goMod.Name != "" { + outPath := filepath.Join(modDir, version+".mod") + if err := ioutil.WriteFile(outPath, goMod.Data, 0666); err != nil { + return "", "", err + } + } + + if len(zipContents) > 0 { + zipPath := filepath.Join(modDir, version+".zip") + zipFile, err := os.Create(zipPath) + if err != nil { + return "", "", err + } + defer zipFile.Close() + if err := zip.Create(zipFile, module.Version{Path: modPath, Version: version}, zipContents); err != nil { + return "", "", err + } + if err := zipFile.Close(); err != nil { + return "", "", err + } + } + } + + buf := &bytes.Buffer{} + for modPath, versions := range versionLists { + outPath := filepath.Join(proxyDir, modPath, "@v", "list") + sort.Slice(versions, func(i, j int) bool { + return semver.Compare(versions[i], versions[j]) < 0 + }) + for _, v := range versions { + fmt.Fprintln(buf, v) + } + if err := ioutil.WriteFile(outPath, buf.Bytes(), 0666); err != nil { + return "", "", err + } + buf.Reset() + } + + // Make sure the URL path starts with a slash on Windows. Absolute paths + // normally start with a drive letter. + // TODO(golang.org/issue/32456): use url.FromFilePath when implemented. + if strings.HasPrefix(proxyDir, "/") { + proxyURL = "file://" + proxyDir + } else { + proxyURL = "file:///" + filepath.FromSlash(proxyDir) + } + return proxyDir, proxyURL, nil +} + +type txtarFile struct { + f txtar.File +} + +func (f txtarFile) Path() string { return f.f.Name } +func (f txtarFile) Lstat() (os.FileInfo, error) { return txtarFileInfo{f.f}, nil } +func (f txtarFile) Open() (io.ReadCloser, error) { + return ioutil.NopCloser(bytes.NewReader(f.f.Data)), nil +} + +type txtarFileInfo struct { + f txtar.File +} + +func (f txtarFileInfo) Name() string { return f.f.Name } +func (f txtarFileInfo) Size() int64 { return int64(len(f.f.Data)) } +func (f txtarFileInfo) Mode() os.FileMode { return 0444 } +func (f txtarFileInfo) ModTime() time.Time { return time.Time{} } +func (f txtarFileInfo) IsDir() bool { return false } +func (f txtarFileInfo) Sys() interface{} { return nil } + +func extractTxtar(destDir string, arc *txtar.Archive) error { + for _, f := range arc.Files { + outPath := filepath.Join(destDir, f.Name) + if err := os.MkdirAll(filepath.Dir(outPath), 0777); err != nil { + return err + } + if err := ioutil.WriteFile(outPath, f.Data, 0666); err != nil { + return err + } + } + return nil +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/report.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/report.go new file mode 100644 index 0000000..3895c98 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/report.go @@ -0,0 +1,463 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "strings" + + "golang.org/x/exp/apidiff" + "golang.org/x/mod/module" + "golang.org/x/mod/semver" + "golang.org/x/tools/go/packages" +) + +// report describes the differences in the public API between two versions +// of a module. +type report struct { + // base contains information about the "old" module version being compared + // against. base.version may be "none", indicating there is no base version + // (for example, if this is the first release). base.version may not be "". + base moduleInfo + + // release contains information about the version of the module to release. + // The version may be set explicitly with -version or suggested using + // suggestVersion, in which case release.versionInferred is true. + release moduleInfo + + // packages is a list of package reports, describing the differences + // for individual packages, sorted by package path. + packages []packageReport + + // versionInvalid explains why the proposed or suggested version is not valid. + versionInvalid *versionMessage + + // haveCompatibleChanges is true if there are any backward-compatible + // changes in non-internal packages. + haveCompatibleChanges bool + + // haveIncompatibleChanges is true if there are any backward-incompatible + // changes in non-internal packages. + haveIncompatibleChanges bool + + // haveBaseErrors is true if there were errors loading packages + // in the base version. + haveBaseErrors bool + + // haveReleaseErrors is true if there were errors loading packages + // in the release version. + haveReleaseErrors bool +} + +// String returns a human-readable report that lists errors, compatible changes, +// and incompatible changes in each package. If releaseVersion is set, the +// report states whether releaseVersion is valid (and why). If releaseVersion is +// not set, it suggests a new version. +func (r *report) String() string { + buf := &strings.Builder{} + for _, p := range r.packages { + buf.WriteString(p.String()) + } + + if !r.canVerifyReleaseVersion() { + return buf.String() + } + + if len(r.release.diagnostics) > 0 { + buf.WriteString("# diagnostics\n") + for _, d := range r.release.diagnostics { + fmt.Fprintln(buf, d) + } + buf.WriteByte('\n') + } + + buf.WriteString("# summary\n") + baseVersion := r.base.version + if r.base.modPath != r.release.modPath { + baseVersion = r.base.modPath + "@" + baseVersion + } + if r.base.versionInferred { + fmt.Fprintf(buf, "Inferred base version: %s\n", baseVersion) + } else if r.base.versionQuery != "" { + fmt.Fprintf(buf, "Base version: %s (%s)\n", baseVersion, r.base.versionQuery) + } + + if r.versionInvalid != nil { + fmt.Fprintln(buf, r.versionInvalid) + } else if r.release.versionInferred { + if r.release.tagPrefix == "" { + fmt.Fprintf(buf, "Suggested version: %s\n", r.release.version) + } else { + fmt.Fprintf(buf, "Suggested version: %[1]s (with tag %[2]s%[1]s)\n", r.release.version, r.release.tagPrefix) + } + } else if r.release.version != "" { + if r.release.tagPrefix == "" { + fmt.Fprintf(buf, "%s is a valid semantic version for this release.\n", r.release.version) + + if semver.Compare(r.release.version, "v0.0.0-99999999999999-zzzzzzzzzzzz") < 0 { + fmt.Fprintf(buf, `Note: %s sorts lower in MVS than pseudo-versions, which may be +unexpected for users. So, it may be better to choose a different suffix.`, r.release.version) + } + } else { + fmt.Fprintf(buf, "%[1]s (with tag %[2]s%[1]s) is a valid semantic version for this release\n", r.release.version, r.release.tagPrefix) + } + } + + if r.versionInvalid == nil && r.haveBaseErrors { + fmt.Fprintln(buf, "Errors were found in the base version. Some API changes may be omitted.") + } + + return buf.String() +} + +func (r *report) addPackage(p packageReport) { + r.packages = append(r.packages, p) + if len(p.baseErrors) == 0 && len(p.releaseErrors) == 0 { + // Only count compatible and incompatible changes if there were no errors. + // When there are errors, definitions may be missing, and fixes may appear + // incompatible when they are not. Changes will still be reported, but + // they won't affect version validation or suggestions. + for _, c := range p.Changes { + if !c.Compatible && len(p.releaseErrors) == 0 { + r.haveIncompatibleChanges = true + } else if c.Compatible && len(p.baseErrors) == 0 && len(p.releaseErrors) == 0 { + r.haveCompatibleChanges = true + } + } + } + if len(p.baseErrors) > 0 { + r.haveBaseErrors = true + } + if len(p.releaseErrors) > 0 { + r.haveReleaseErrors = true + } +} + +// validateReleaseVersion checks whether r.release.version is valid. +// If r.release.version is not valid, an error is returned explaining why. +// r.release.version must be set. +func (r *report) validateReleaseVersion() { + if r.release.version == "" { + panic("validateVersion called without version") + } + setNotValid := func(format string, args ...interface{}) { + r.versionInvalid = &versionMessage{ + message: fmt.Sprintf("%s is not a valid semantic version for this release.", r.release.version), + reason: fmt.Sprintf(format, args...), + } + } + + if r.haveReleaseErrors { + if r.haveReleaseErrors { + setNotValid("Errors were found in one or more packages.") + return + } + } + + // TODO(jayconrod): link to documentation for all of these errors. + + // Check that the major version matches the module path. + _, suffix, ok := module.SplitPathVersion(r.release.modPath) + if !ok { + setNotValid("%s: could not find version suffix in module path", r.release.modPath) + return + } + if suffix != "" { + if suffix[0] != '/' && suffix[0] != '.' { + setNotValid("%s: unknown module path version suffix: %q", r.release.modPath, suffix) + return + } + pathMajor := suffix[1:] + major := semver.Major(r.release.version) + if pathMajor != major { + setNotValid(`The major version %s does not match the major version suffix +in the module path: %s`, major, r.release.modPath) + return + } + } else if major := semver.Major(r.release.version); major != "v0" && major != "v1" { + setNotValid(`The module path does not end with the major version suffix /%s, +which is required for major versions v2 or greater.`, major) + return + } + + for _, v := range r.base.existingVersions { + if semver.Compare(v, r.release.version) == 0 { + setNotValid("version %s already exists", v) + } + } + + // Check that compatible / incompatible changes are consistent. + if semver.Major(r.base.version) == "v0" || r.base.modPath != r.release.modPath { + return + } + if r.haveIncompatibleChanges { + setNotValid("There are incompatible changes.") + return + } + if r.haveCompatibleChanges && semver.MajorMinor(r.base.version) == semver.MajorMinor(r.release.version) { + setNotValid(`There are compatible changes, but the minor version is not incremented +over the base version (%s).`, r.base.version) + return + } + + if r.release.highestTransitiveVersion != "" && semver.Compare(r.release.highestTransitiveVersion, r.release.version) > 0 { + setNotValid(`Module indirectly depends on a higher version of itself (%s). + `, r.release.highestTransitiveVersion) + } +} + +// suggestReleaseVersion suggests a new version consistent with observed +// changes. +func (r *report) suggestReleaseVersion() { + setNotValid := func(format string, args ...interface{}) { + r.versionInvalid = &versionMessage{ + message: "Cannot suggest a release version.", + reason: fmt.Sprintf(format, args...), + } + } + setVersion := func(v string) { + r.release.version = v + r.release.versionInferred = true + } + + if r.base.modPath != r.release.modPath { + setNotValid("Base module path is different from release.") + return + } + + if r.haveReleaseErrors || r.haveBaseErrors { + setNotValid("Errors were found.") + return + } + + var major, minor, patch, pre string + if r.base.version != "none" { + minVersion := r.base.version + if r.release.highestTransitiveVersion != "" && semver.Compare(r.release.highestTransitiveVersion, minVersion) > 0 { + setNotValid("Module indirectly depends on a higher version of itself (%s) than the base version (%s).", r.release.highestTransitiveVersion, r.base.version) + return + } + + var err error + major, minor, patch, pre, _, err = parseVersion(minVersion) + if err != nil { + panic(fmt.Sprintf("could not parse base version: %v", err)) + } + } + + if r.haveIncompatibleChanges && r.base.version != "none" && pre == "" && major != "0" { + setNotValid("Incompatible changes were detected.") + return + // TODO(jayconrod): briefly explain how to prepare major version releases + // and link to documentation. + } + + // Check whether we're comparing to the latest version of base. + // + // This could happen further up, but we want the more pressing errors above + // to take precedence. + var latestForBaseMajor string + for _, v := range r.base.existingVersions { + if semver.Major(v) != semver.Major(r.base.version) { + continue + } + if latestForBaseMajor == "" || semver.Compare(latestForBaseMajor, v) < 0 { + latestForBaseMajor = v + } + } + if latestForBaseMajor != "" && latestForBaseMajor != r.base.version { + setNotValid(fmt.Sprintf("Can only suggest a release version when compared against the most recent version of this major: %s.", latestForBaseMajor)) + return + } + + if r.base.version == "none" { + if _, pathMajor, ok := module.SplitPathVersion(r.release.modPath); !ok { + panic(fmt.Sprintf("could not parse module path %q", r.release.modPath)) + } else if pathMajor == "" { + setVersion("v0.1.0") + } else { + setVersion(pathMajor[1:] + ".0.0") + } + return + } + + if pre != "" { + // suggest non-prerelease version + } else if r.haveCompatibleChanges || (r.haveIncompatibleChanges && major == "0") || r.requirementsChanged() { + minor = incDecimal(minor) + patch = "0" + } else { + patch = incDecimal(patch) + } + setVersion(fmt.Sprintf("v%s.%s.%s", major, minor, patch)) + return +} + +// canVerifyReleaseVersion returns true if we can safely suggest a new version +// or if we can verify the version passed in with -version is safe to tag. +func (r *report) canVerifyReleaseVersion() bool { + // For now, return true if the base and release module paths are the same, + // ignoring the major version suffix. + // TODO(#37562, #39192, #39666, #40267): there are many more situations when + // we can't verify a new version. + basePath := strings.TrimSuffix(r.base.modPath, r.base.modPathMajor) + releasePath := strings.TrimSuffix(r.release.modPath, r.release.modPathMajor) + return basePath == releasePath +} + +// requirementsChanged reports whether requirements have changed from base to +// version. +// +// requirementsChanged reports true for, +// - A requirement was upgraded to a higher minor version. +// - A requirement was added. +// - The version of Go was incremented. +// +// It does not report true when, for example, a requirement was downgraded or +// remove. We care more about the former since that might force dependent +// modules that have the same dependency to upgrade. +func (r *report) requirementsChanged() bool { + if r.base.goModFile == nil { + // There wasn't a modfile before, and now there is. + return true + } + + // baseReqs is a map of module path to MajorMinor of the base module + // requirements. + baseReqs := make(map[string]string) + for _, r := range r.base.goModFile.Require { + baseReqs[r.Mod.Path] = r.Mod.Version + } + + for _, r := range r.release.goModFile.Require { + if _, ok := baseReqs[r.Mod.Path]; !ok { + // A module@version was added to the "require" block between base + // and release. + return true + } + if semver.Compare(semver.MajorMinor(r.Mod.Version), semver.MajorMinor(baseReqs[r.Mod.Path])) > 0 { + // The version of r.Mod.Path increased from base to release. + return true + } + } + + if r.release.goModFile.Go != nil && r.base.goModFile.Go != nil { + if r.release.goModFile.Go.Version > r.base.goModFile.Go.Version { + // The Go version increased from base to release. + return true + } + } + + return false +} + +// isSuccessful returns true the module appears to be safe to release at the +// proposed or suggested version. +func (r *report) isSuccessful() bool { + return len(r.release.diagnostics) == 0 && r.versionInvalid == nil +} + +type versionMessage struct { + message, reason string +} + +func (m versionMessage) String() string { + return m.message + "\n" + m.reason + "\n" +} + +// incDecimal returns the decimal string incremented by 1. +func incDecimal(decimal string) string { + // Scan right to left turning 9s to 0s until you find a digit to increment. + digits := []byte(decimal) + i := len(digits) - 1 + for ; i >= 0 && digits[i] == '9'; i-- { + digits[i] = '0' + } + if i >= 0 { + digits[i]++ + } else { + // digits is all zeros + digits[0] = '1' + digits = append(digits, '0') + } + return string(digits) +} + +type packageReport struct { + apidiff.Report + path string + baseErrors, releaseErrors []packages.Error +} + +func (p *packageReport) String() string { + if len(p.Changes) == 0 && len(p.baseErrors) == 0 && len(p.releaseErrors) == 0 { + return "" + } + buf := &strings.Builder{} + fmt.Fprintf(buf, "# %s\n", p.path) + if len(p.baseErrors) > 0 { + fmt.Fprintf(buf, "## errors in base version:\n") + for _, e := range p.baseErrors { + fmt.Fprintln(buf, e) + } + buf.WriteByte('\n') + } + if len(p.releaseErrors) > 0 { + fmt.Fprintf(buf, "## errors in release version:\n") + for _, e := range p.releaseErrors { + fmt.Fprintln(buf, e) + } + buf.WriteByte('\n') + } + if len(p.Changes) > 0 { + var compatible, incompatible []apidiff.Change + for _, c := range p.Changes { + if c.Compatible { + compatible = append(compatible, c) + } else { + incompatible = append(incompatible, c) + } + } + if len(incompatible) > 0 { + fmt.Fprintf(buf, "## incompatible changes\n") + for _, c := range incompatible { + fmt.Fprintln(buf, c.Message) + } + } + if len(compatible) > 0 { + fmt.Fprintf(buf, "## compatible changes\n") + for _, c := range compatible { + fmt.Fprintln(buf, c.Message) + } + } + buf.WriteByte('\n') + } + return buf.String() +} + +// parseVersion returns the major, minor, and patch numbers, prerelease text, +// and metadata for a given version. +// +// TODO(jayconrod): extend semver to do this and delete this function. +func parseVersion(vers string) (major, minor, patch, pre, meta string, err error) { + if !strings.HasPrefix(vers, "v") { + return "", "", "", "", "", fmt.Errorf("version %q does not start with 'v'", vers) + } + base := vers[1:] + if i := strings.IndexByte(base, '+'); i >= 0 { + meta = base[i+1:] + base = base[:i] + } + if i := strings.IndexByte(base, '-'); i >= 0 { + pre = base[i+1:] + base = base[:i] + } + parts := strings.Split(base, ".") + if len(parts) != 3 { + return "", "", "", "", "", fmt.Errorf("version %q should have three numbers", vers) + } + major, minor, patch = parts[0], parts[1], parts[2] + return major, minor, patch, pre, meta, nil +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/README.md b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/README.md new file mode 100644 index 0000000..3c4880a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/README.md @@ -0,0 +1,95 @@ +This directory contains most tests for gorelease. Each test runs gorelease (the +`runRelease` function) with a given set of flags in a temporary directory +populated with files specified in the test itself or files from the module test +proxy. The output is compared against a golden `want` file specified in the +test. + +## Test flags + +A specific test may be run with a command like: + + go test -run=TestRelease/basic/v0_patch_suggest + +where `basic/v0_patch_suggest` matches the file +`testdata/basic/v0_patch_suggest.test`. + +The `-u` flag adds or updates the `want` file in each test to match the output. +This is useful for fixing tests after an intended change in behavior. + + go test -run=TestRelease/basic/v0_patch_suggest -u + +The `-testwork` flag instructs the test framework to leave the test's temporary +directory and module proxy in place after running the test. This is useful +for debugging. + +## Test format + +Tests are written in `.test` files in `testdata` subdirectories. Each `.test` +file is a valid txtar file (see `golang.org/x/tools/txtar`). The comment section +contains the test parameters, which are a series of `key=value` pairs. Blank +lines and comments starting with `#` are allowed in this section. Valid keys +are: + +* `mod`: sets the module path. Must be specified together with `version`. Copies + the content of a module out of the test proxy into a temporary directory + where `gorelease` is run. +* `version`: specified together with `mod`, it sets the version to retrieve from + the test proxy. See more information below. +* `base`: the value of the `-base` flag passed to `gorelease`. +* `release`: the value of the `-version` flag passed to `gorelease`. +* `dir`: the directory where `gorelease` should be invoked. Useful when the test + describes a whole repository, and `gorelease` should be invoked in a + subdirectory. +* `error`: true if the test expects a hard error. False by default. +* `success`: true if the test expects a report to be printed with no errors + or diagnostics. True by default. +* `skip`: non-empty if the test should be skipped. The value is a string passed + to `t.Skip`. +* `proxyVersions`: empty if the test should include all `mod/` entries in the + proxy, or else a comma-separated list of the modpath@version's it should + include. + +Test archives have a file named `want`, containing the expected output of the +test. A test will fail if the actual output differs from `want`. + +If the `mod` and `version` parameters are not set, other files will be extracted +to the temporary directory where `gorelease` runs. + +## Populating module contents + +When building a test in `testdata/`, there are two ways to populate the module +directory being tested: + +### Option 1: inline + +You can inline files in the `.test` folder as described in +https://pkg.go.dev/golang.org/x/tools/txtar#hdr-Txtar_format. For example, + +``` +-- some.file -- +the contents +of the file +``` + +### Option 2: specify an existing file + +Often, multiple tests want to share the same setup - the same files. So, users +can write these common files in `testdata/mod/`, and use one of these files as +the module directory contents. + +To specify a file in `testdata/mod/` to use as the module contents. + +## Module format + +Tests run with `GOPROXY` set to a local URL that points to a test proxy. The +test proxy serves modules described by `.txt` files in the `testdata/mod/` +subdirectory. + +Each module is a txtar archive named `$modpath_$version.txt` where `$modpath` +is the module path (with slashes replaced with underscores) and `$version` is +the version. If the archive contains a file named `.mod`, that will be used to +respond to `.mod` requests; otherwise, `go.mod` will be used (`.mod` is only +necessary for modules that lack `go.mod` files). If the archive contains a +file named `.info`, that will be used to respond to `.info` requests; otherwise, +`.info` is synthesized from the version. All other files in the archive are +packed into a `.zip` file to satisfy `.zip` requests. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_major.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_major.test new file mode 100644 index 0000000..bea8be6 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_major.test @@ -0,0 +1,24 @@ +mod=example.com/basic +base=v1.0.1 +success=false +# A() was removed, which is a breaking change: it shouldn't try to suggest a +# higher version. +-- want -- +# example.com/basic/a +## incompatible changes +A: removed +## compatible changes +B: added + +# summary +Cannot suggest a release version. +Incompatible changes were detected. +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func B() int { return 0 } + diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_minor.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_minor.test new file mode 100644 index 0000000..40eda64 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_minor.test @@ -0,0 +1,23 @@ +mod=example.com/basic +base=v0.0.1 +success=false +# B() was added, so now it should suggest a new minor version. But, there's a +# later version that already exists: so it should not try to suggest anything at +# all. +-- want -- +# example.com/basic/a +## compatible changes +B: added + +# summary +Cannot suggest a release version. +Can only suggest a release version when compared against the most recent version of this major: v0.1.2. +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } +func B() int { return 0 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_patch.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_patch.test new file mode 100644 index 0000000..209d9a9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_suggest_patch.test @@ -0,0 +1,23 @@ +mod=example.com/basic +base=v0.1.0 +success=false +# A() was changed in a small way, so now it should suggest a new patch version. +# But, there's a later version that already exists: so it should not try to +# suggest anything at all. +-- want -- +# summary +Cannot suggest a release version. +Can only suggest a release version when compared against the most recent version of this major: v0.1.2. +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_verify.test new file mode 100644 index 0000000..8ba7cfc --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/alreadyexists/alreadyexists_verify.test @@ -0,0 +1,18 @@ +mod=example.com/basic +base=v0.0.1 +release=v0.1.0 +success=false +# The contents below are a copy of the v0.0.1 contents - nothing has changed. +# But v0.1.0 already exists, so it should present a diagnostic. +-- want -- +# summary +v0.1.0 is not a valid semantic version for this release. +version v0.1.0 already exists +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/README.txt new file mode 100644 index 0000000..708a0c1 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/README.txt @@ -0,0 +1,11 @@ +Module example.com/basic tests basic functionality of gorelease. +It verifies that versions are correctly suggested or verified after +various changes. + +All revisions are stored in the mod directory. The same series of +changes is made across three major versions, v0, v1, and v2: + +vX.0.1 - simple package +vX.1.0 - compatible change: add a function and a package +vX.1.1 - internal change: function returns different value +vX.1.2 - incompatible change: delete a function and a package diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest.test new file mode 100644 index 0000000..6560f55 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic +version=v0.1.0 +base=v0.0.1 +proxyVersions=example.com/basic@v0.0.1 +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/b +## compatible changes +package added + +# summary +Suggested version: v0.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest_git.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest_git.test new file mode 100644 index 0000000..080cafd --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest_git.test @@ -0,0 +1,16 @@ +mod=example.com/basic +version=v0.1.0 +base=v0.0.1 +proxyVersions=example.com/basic@v0.0.1 +vcs=git +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/b +## compatible changes +package added + +# summary +Suggested version: v0.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest_hg.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest_hg.test new file mode 100644 index 0000000..329ea88 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_suggest_hg.test @@ -0,0 +1,16 @@ +mod=example.com/basic +version=v0.1.0 +base=v0.0.1 +proxyVersions=example.com/basic@v0.0.1 +vcs=hg +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/b +## compatible changes +package added + +# summary +Suggested version: v0.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_verify.test new file mode 100644 index 0000000..b5c726d --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_compatible_verify.test @@ -0,0 +1,16 @@ +mod=example.com/basic +version=v0.1.0 +base=v0.0.1 +release=v0.1.0 +proxyVersions=example.com/basic@v0.0.1 +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/b +## compatible changes +package added + +# summary +v0.1.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_incompatible_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_incompatible_suggest.test new file mode 100644 index 0000000..d07a48f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_incompatible_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic +version=v0.1.2 +base=v0.1.1 +proxyVersions=example.com/basic@v0.1.1 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +Suggested version: v0.2.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_incompatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_incompatible_verify.test new file mode 100644 index 0000000..b8355ea --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_incompatible_verify.test @@ -0,0 +1,16 @@ +mod=example.com/basic +version=v0.1.2 +base=v0.1.1 +release=v0.1.2 +proxyVersions=example.com/basic@v0.1.1 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +v0.1.2 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_nobase_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_nobase_suggest.test new file mode 100644 index 0000000..b059fc0 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_nobase_suggest.test @@ -0,0 +1,6 @@ +mod=example.com/basic +version=v0.1.1 +base=none +-- want -- +# summary +Suggested version: v0.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_patch_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_patch_suggest.test new file mode 100644 index 0000000..a5f957a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_patch_suggest.test @@ -0,0 +1,7 @@ +mod=example.com/basic +version=v0.1.1 +base=v0.1.0 +proxyVersions=example.com/basic@v0.1.0 +-- want -- +# summary +Suggested version: v0.1.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_patch_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_patch_verify.test new file mode 100644 index 0000000..d26ff70 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_patch_verify.test @@ -0,0 +1,8 @@ +mod=example.com/basic +version=v0.1.1 +base=v0.1.0 +release=v0.1.1 +proxyVersions=example.com/basic@v0.1.0 +-- want -- +# summary +v0.1.1 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_pre_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_pre_suggest.test new file mode 100644 index 0000000..ca45c40 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_pre_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic +version=v0.1.2 +base=v0.1.1-pre +proxyVersions=example.com/basic@v0.1.1-pre +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +Suggested version: v0.1.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_v1_incompatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_v1_incompatible_verify.test new file mode 100644 index 0000000..7a68306 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v0_v1_incompatible_verify.test @@ -0,0 +1,15 @@ +mod=example.com/basic +version=v0.1.2 +base=v0.1.1 +release=v1.0.0 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +v1.0.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_autobase_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_autobase_suggest.test new file mode 100644 index 0000000..100cc4c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_autobase_suggest.test @@ -0,0 +1,6 @@ +mod=example.com/basic +version=v0.1.2 +-- want -- +# summary +Inferred base version: v1.1.2 +Suggested version: v1.1.3 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_autobase_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_autobase_verify.test new file mode 100644 index 0000000..6df9c6e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_autobase_verify.test @@ -0,0 +1,7 @@ +mod=example.com/basic +version=v1.0.1 +release=v1.0.2 +-- want -- +# summary +Inferred base version: v1.0.1 +v1.0.2 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_compatible_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_compatible_suggest.test new file mode 100644 index 0000000..fe63e75 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_compatible_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic +version=v1.1.0 +base=v1.0.1 +proxyVersions=example.com/basic@v1.0.1 +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/b +## compatible changes +package added + +# summary +Suggested version: v1.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_compatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_compatible_verify.test new file mode 100644 index 0000000..f552aef --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_compatible_verify.test @@ -0,0 +1,16 @@ +mod=example.com/basic +version=v1.1.0 +base=v1.0.1 +release=v1.1.0 +proxyVersions=example.com/basic@v1.0.1 +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/b +## compatible changes +package added + +# summary +v1.1.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_fork_base_modpath_version_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_fork_base_modpath_version_verify.test new file mode 100644 index 0000000..a662cb1 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_fork_base_modpath_version_verify.test @@ -0,0 +1,11 @@ +mod=example.com/basicfork +base=example.com/basic@v1.1.1 +version=v1.1.2 +release=v1.1.2 +proxyVersions=example.com/basic@v1.1.1 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed +## compatible changes +A3: added diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_fork_base_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_fork_base_verify.test new file mode 100644 index 0000000..ff3faab --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_fork_base_verify.test @@ -0,0 +1,15 @@ +# Compare a fork (with module path example.com/basic, downloaded from +# example.com/basicfork) with a local module (with module path +# example.com/basic). +mod=example.com/basic +version=v1.1.2 +base=example.com/basicfork@v1.1.2 +release=v1.1.3 +-- want -- +# example.com/basicfork/a +## incompatible changes +A3: removed + +# example.com/basicfork/b +## incompatible changes +package removed diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_incompatible_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_incompatible_suggest.test new file mode 100644 index 0000000..a955b10 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_incompatible_suggest.test @@ -0,0 +1,16 @@ +mod=example.com/basic +version=v1.1.2 +base=v1.1.1 +success=false +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +Cannot suggest a release version. +Incompatible changes were detected. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_incompatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_incompatible_verify.test new file mode 100644 index 0000000..655ed6a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_incompatible_verify.test @@ -0,0 +1,18 @@ +mod=example.com/basic +version=v1.1.2 +base=v1.1.1 +success=false +release=v1.1.2 +proxyVersions=example.com/basic@v1.1.1 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +v1.1.2 is not a valid semantic version for this release. +There are incompatible changes. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_patch_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_patch_suggest.test new file mode 100644 index 0000000..936f26a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_patch_suggest.test @@ -0,0 +1,7 @@ +mod=example.com/basic +version=v1.1.1 +base=v1.1.0 +proxyVersions=example.com/basic@v1.1.0 +-- want -- +# summary +Suggested version: v1.1.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_patch_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_patch_verify.test new file mode 100644 index 0000000..f134744 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_patch_verify.test @@ -0,0 +1,8 @@ +mod=example.com/basic +version=v1.1.1 +base=v1.1.0 +release=v1.1.1 +proxyVersions=example.com/basic@v1.1.0 +-- want -- +# summary +v1.1.1 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_pre_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_pre_suggest.test new file mode 100644 index 0000000..c715603 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_pre_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic +version=v1.1.2 +base=v1.1.1-pre +proxyVersions=example.com/basic@v1.1.1-pre +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +Suggested version: v1.1.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_higher.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_higher.test new file mode 100644 index 0000000..ba6838f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_higher.test @@ -0,0 +1,7 @@ +mod=example.com/basic +version=v1.0.1 +release=v1.0.1 +base=>v1.0.1 +error=true +-- want -- +base version v1.1.0 (>v1.0.1) must be lower than release version v1.0.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_suggest.test new file mode 100644 index 0000000..c1dfb9d --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_suggest.test @@ -0,0 +1,8 @@ +mod=example.com/basic +version=v1.0.1 +base=version-1.0.1 +proxyVersions=example.com/basic@version-1.0.1,example.com/basic@v1.0.1 +-- want -- +# summary +Base version: v1.0.1 (version-1.0.1) +Suggested version: v1.0.2 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_verify.test new file mode 100644 index 0000000..9383c3f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_querybase_verify.test @@ -0,0 +1,8 @@ +mod=example.com/basic +version=v1.0.1 +base=version-1.0.1 +release=v1.0.2 +-- want -- +# summary +Base version: v1.0.1 (version-1.0.1) +v1.0.2 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_query_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_query_verify.test new file mode 100644 index 0000000..ce6b674 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_query_verify.test @@ -0,0 +1,17 @@ +mod=example.com/basic/v2 +base=example.com/basic@>=v1.1.0 +version=v2.0.1 +release=v2.0.1 +proxyVersions=example.com/basic@v1.1.0 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +Base version: example.com/basic@v1.1.0 (>=v1.1.0) +v2.0.1 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_suggest.test new file mode 100644 index 0000000..d70ecc9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_suggest.test @@ -0,0 +1,17 @@ +mod=example.com/basic/v2 +base=example.com/basic +version=v2.1.0 +success=false +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/v2/b +## compatible changes +package added + +# summary +Inferred base version: example.com/basic@v1.1.2 +Cannot suggest a release version. +Base module path is different from release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_verify.test new file mode 100644 index 0000000..85f7f86 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_verify.test @@ -0,0 +1,17 @@ +mod=example.com/basic/v2 +base=example.com/basic +version=v2.1.0 +release=v2.1.0 +proxyVersions=example.com/basic@v1.1.2 +-- want -- +# example.com/basic/a +## compatible changes +A2: added + +# example.com/basic/v2/b +## compatible changes +package added + +# summary +Inferred base version: example.com/basic@v1.1.2 +v2.1.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_version_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_version_verify.test new file mode 100644 index 0000000..63d3322 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_modpath_version_verify.test @@ -0,0 +1,16 @@ +mod=example.com/basic/v2 +base=example.com/basic@v1.1.0 +version=v2.0.1 +release=v2.0.1 +proxyVersions=example.com/basic@v1.1.0 +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +v2.0.1 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_version_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_version_suggest.test new file mode 100644 index 0000000..683bb33 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_version_suggest.test @@ -0,0 +1,8 @@ +mod=example.com/basic/v2 +base=v1.1.0 +version=v2.1.0 +success=false +-- want -- +# summary +Cannot suggest a release version. +Base module path is different from release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_version_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_version_verify.test new file mode 100644 index 0000000..bc8e31a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_base_version_verify.test @@ -0,0 +1,7 @@ +mod=example.com/basic/v2 +base=v1.1.0 +version=v2.1.0 +release=v2.1.0 +-- want -- +# summary +v2.1.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_incompatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_incompatible_verify.test new file mode 100644 index 0000000..07bbde9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v1_v2_incompatible_verify.test @@ -0,0 +1,18 @@ +mod=example.com/basic +version=v1.1.2 +base=v1.1.1 +release=v2.0.0 +success=false +-- want -- +# example.com/basic/a +## incompatible changes +A2: removed + +# example.com/basic/b +## incompatible changes +package removed + +# summary +v2.0.0 is not a valid semantic version for this release. +The module path does not end with the major version suffix /v2, +which is required for major versions v2 or greater. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_compatible_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_compatible_suggest.test new file mode 100644 index 0000000..86e60cb --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_compatible_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic/v2 +version=v2.1.0 +base=v2.0.1 +proxyVersions=example.com/basic/v2@v2.0.1 +-- want -- +# example.com/basic/v2/a +## compatible changes +A2: added + +# example.com/basic/v2/b +## compatible changes +package added + +# summary +Suggested version: v2.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_compatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_compatible_verify.test new file mode 100644 index 0000000..79eca35 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_compatible_verify.test @@ -0,0 +1,16 @@ +mod=example.com/basic/v2 +version=v2.1.0 +base=v2.0.1 +release=v2.1.0 +proxyVersions=example.com/basic/v2@v2.0.1 +-- want -- +# example.com/basic/v2/a +## compatible changes +A2: added + +# example.com/basic/v2/b +## compatible changes +package added + +# summary +v2.1.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_incompatible_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_incompatible_suggest.test new file mode 100644 index 0000000..43aa3fe --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_incompatible_suggest.test @@ -0,0 +1,16 @@ +mod=example.com/basic/v2 +version=v2.1.2 +base=v2.1.1 +success=false +-- want -- +# example.com/basic/v2/a +## incompatible changes +A2: removed + +# example.com/basic/v2/b +## incompatible changes +package removed + +# summary +Cannot suggest a release version. +Incompatible changes were detected. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_incompatible_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_incompatible_verify.test new file mode 100644 index 0000000..68b7321 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_incompatible_verify.test @@ -0,0 +1,18 @@ +mod=example.com/basic/v2 +version=v2.1.2 +base=v2.1.1 +success=false +release=v2.1.2 +proxyVersions=example.com/basic/v2@v2.1.1 +-- want -- +# example.com/basic/v2/a +## incompatible changes +A2: removed + +# example.com/basic/v2/b +## incompatible changes +package removed + +# summary +v2.1.2 is not a valid semantic version for this release. +There are incompatible changes. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_nobase_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_nobase_suggest.test new file mode 100644 index 0000000..605edf9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_nobase_suggest.test @@ -0,0 +1,6 @@ +mod=example.com/basic/v2 +version=v2.1.1 +base=none +-- want -- +# summary +Suggested version: v2.0.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_patch_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_patch_suggest.test new file mode 100644 index 0000000..b16a863 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_patch_suggest.test @@ -0,0 +1,7 @@ +mod=example.com/basic/v2 +version=v2.1.1 +base=v2.1.0 +proxyVersions=example.com/basic/v2@v2.1.0 +-- want -- +# summary +Suggested version: v2.1.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_patch_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_patch_verify.test new file mode 100644 index 0000000..35d617a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_patch_verify.test @@ -0,0 +1,8 @@ +mod=example.com/basic/v2 +version=v2.1.1 +base=v2.1.0 +release=v2.1.1 +proxyVersions=example.com/basic/v2@v2.1.0 +-- want -- +# summary +v2.1.1 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_pre_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_pre_suggest.test new file mode 100644 index 0000000..75d0c39 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v2_pre_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/basic/v2 +version=v2.1.2 +base=v2.1.1-pre +proxyVersions=example.com/basic/v2@v2.1.1-pre +-- want -- +# example.com/basic/v2/a +## incompatible changes +A2: removed + +# example.com/basic/v2/b +## incompatible changes +package removed + +# summary +Suggested version: v2.1.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_suggest.test new file mode 100644 index 0000000..eda87d2 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_suggest.test @@ -0,0 +1,9 @@ +mod=example.com/basic/v3 +-- go.mod -- +module example.com/basic/v3 + +go 1.13 +-- want -- +# summary +Inferred base version: none +Suggested version: v3.0.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_verify_error.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_verify_error.test new file mode 100644 index 0000000..9519d65 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_verify_error.test @@ -0,0 +1,6 @@ +mod=example.com/basic/v3 +version=v3.0.0-ignore +release=v3.1.0 +error=true +-- want -- +could not find base version. Consider setting -version=v3.0.0 if this is a first release, or explicitly set -base=none: no versions found lower than v3.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_verify_first.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_verify_first.test new file mode 100644 index 0000000..1cae913 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/basic/v3_autobase_verify_first.test @@ -0,0 +1,7 @@ +mod=example.com/basic/v3 +version=v3.0.0-ignore +release=v3.0.0 +-- want -- +# summary +Inferred base version: none +v3.0.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cgo/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cgo/README.txt new file mode 100644 index 0000000..8bbf9c6 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cgo/README.txt @@ -0,0 +1,7 @@ +Module example.com/cgo is used to test that packages with cgo code +can be loaded without errors when cgo is enabled. + +TODO(jayconrod): test modules with cgo-only and cgo / pure Go implementations +with CGO_ENABLED=0 and 1. But first, decide how multiple platforms and +build constraints should be handled. Currently, gorelease only considers +the same configuration as 'go list'.
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cgo/cgo.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cgo/cgo.test new file mode 100644 index 0000000..b6cea21 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cgo/cgo.test @@ -0,0 +1,16 @@ +base=none +release=v1.0.0 +-- go.mod -- +module example.com/cgo + +go 1.13 +-- c.go -- +package cgo + +// const int x = 12; +import "C" + +func X() int { return int(C.x) } +-- want -- +# summary +v1.0.0 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/README.md b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/README.md new file mode 100644 index 0000000..3596c8b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/README.md @@ -0,0 +1 @@ +This directory is for tests related to module cycles.
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_suggest.test new file mode 100644 index 0000000..fc108d7 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_suggest.test @@ -0,0 +1,6 @@ +mod=example.com/cycle/v2 +version=v2.0.0 +-- want -- +# summary +Inferred base version: v2.0.0 +Suggested version: v2.0.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_suggest_error.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_suggest_error.test new file mode 100644 index 0000000..133e4e3 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_suggest_error.test @@ -0,0 +1,8 @@ +mod=example.com/cycle +base=v1.0.0 +version=v1.0.0 +success=false +-- want -- +# summary +Cannot suggest a release version. +Module indirectly depends on a higher version of itself (v1.5.0) than the base version (v1.0.0). diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_verify.test new file mode 100644 index 0000000..84b4106 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/cycle/cycle_verify.test @@ -0,0 +1,9 @@ +mod=example.com/cycle +base=v1.0.0 +version=v1.0.0 +release=v1.0.1 +success=false +-- want -- +# summary +v1.0.1 is not a valid semantic version for this release. +Module indirectly depends on a higher version of itself (v1.5.0). diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/empty/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/empty/README.txt new file mode 100644 index 0000000..283befa --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/empty/README.txt @@ -0,0 +1,2 @@ +Module example.com/empty is used to test that gorelease works +in a module with no packages. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/empty/empty.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/empty/empty.test new file mode 100644 index 0000000..e9bebb4 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/empty/empty.test @@ -0,0 +1,8 @@ +mod=example.com/empty +base=v0.0.1 +version=v0.0.2 +release=v0.0.2 +proxyVersions=example.com/empty@v0.0.1 +-- want -- +# summary +v0.0.2 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/README.txt new file mode 100644 index 0000000..071708a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/README.txt @@ -0,0 +1,2 @@ +Tests in this directory check that user errors invoking gorelease +are correctly reported. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/bad_filenames.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/bad_filenames.test new file mode 100644 index 0000000..c8bf6e0 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/bad_filenames.test @@ -0,0 +1,17 @@ +mod=example.com/ziperrors +dir=x +base=none +error=true +vcs=git +-- want -- +testdata/this_file_also_has_a_bad_filename'.txt: malformed file path "testdata/this_file_also_has_a_bad_filename'.txt": invalid char '\'' +testdata/this_file_has_a_bad_filename'.txt: malformed file path "testdata/this_file_has_a_bad_filename'.txt": invalid char '\'' +-- x/go.mod -- +module example.com/x + +go 1.12 +-- x/testdata/this_file_has_a_bad_filename'.txt -- +-- x/testdata/this_file_also_has_a_bad_filename'.txt -- +# Verify that errors in submodules are not reported. +-- x/y/go.mod -- +-- x/y/submodule_bad_filename'.txt --
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/bad_release.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/bad_release.test new file mode 100644 index 0000000..74dc009 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/bad_release.test @@ -0,0 +1,8 @@ +mod=example.com/errors +base=v0.1.0 +release=master +error=true +-- want -- +usage: gorelease [-base=version] [-version=version] +release version "master" is not a canonical semantic version +For more information, run go doc golang.org/x/exp/cmd/gorelease diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/base_higher.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/base_higher.test new file mode 100644 index 0000000..a2325f9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/base_higher.test @@ -0,0 +1,8 @@ +mod=example.com/errors +base=v0.2.0 +release=v0.1.0 +error=true +-- want -- +usage: gorelease [-base=version] [-version=version] +base version ("v0.2.0") must be lower than release version ("v0.1.0") +For more information, run go doc golang.org/x/exp/cmd/gorelease diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/base_modpath_none.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/base_modpath_none.test new file mode 100644 index 0000000..74a6946 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/base_modpath_none.test @@ -0,0 +1,7 @@ +mod=example.com/basic/v2 +base=example.com/basic@none +error=true +-- want -- +usage: gorelease [-base=version] [-version=version] +base version ("example.com/basic@none") cannot have version "none" with explicit module path +For more information, run go doc golang.org/x/exp/cmd/gorelease diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/errors.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/errors.test new file mode 100644 index 0000000..81adeb5 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/errors.test @@ -0,0 +1,38 @@ +mod=example.com/errors +version=v0.2.0 +base=v0.1.0 +release=v0.2.0 +success=false +proxyVersions=example.com/errors@v0.1.0 +-- want -- +# example.com/errors/added +## errors in release version: +added/added.go:3:15: undeclared name: Missing + +## compatible changes +package added + +# example.com/errors/broken +## errors in release version: +broken/broken.go:3:15: undeclared name: Missing + +## incompatible changes +X: value changed from 12 to unknown + +# example.com/errors/deleted +## errors in base version: +deleted/deleted.go:3:15: undeclared name: Missing + +## incompatible changes +package removed + +# example.com/errors/fixed +## errors in base version: +fixed/fixed.go:3:15: undeclared name: Missing + +## incompatible changes +X: value changed from unknown to 12 + +# summary +v0.2.0 is not a valid semantic version for this release. +Errors were found in one or more packages. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/same_base_release.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/same_base_release.test new file mode 100644 index 0000000..4da457b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/same_base_release.test @@ -0,0 +1,8 @@ +mod=example.com/errors +base=v0.1.0 +release=v0.1.0 +error=true +-- want -- +usage: gorelease [-base=version] [-version=version] +-base and -version must be different +For more information, run go doc golang.org/x/exp/cmd/gorelease diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/upgrade_base.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/upgrade_base.test new file mode 100644 index 0000000..994b3b7 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/errors/upgrade_base.test @@ -0,0 +1,6 @@ +mod=example.com/errors +version=v0.1.0 +base=upgrade +error=true +-- want -- +could not resolve version example.com/errors@upgrade: query is based on requirements in main go.mod file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/README.txt new file mode 100644 index 0000000..c735527 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/README.txt @@ -0,0 +1 @@ +Module example.com/first is used to test the first tag for a major version. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_0_0.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_0_0.test new file mode 100644 index 0000000..5d473ee --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_0_0.test @@ -0,0 +1,12 @@ +mod=example.com/first +base=none +release=v0.0.0 +-- want -- +# summary +v0.0.0 is a valid semantic version for this release. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_0_1.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_0_1.test new file mode 100644 index 0000000..f32c69e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_0_1.test @@ -0,0 +1,12 @@ +mod=example.com/first +base=none +release=v0.0.1 +-- want -- +# summary +v0.0.1 is a valid semantic version for this release. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_1_0-alpha.1.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_1_0-alpha.1.test new file mode 100644 index 0000000..90985ee --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_1_0-alpha.1.test @@ -0,0 +1,12 @@ +mod=example.com/first +base=none +release=v0.1.0-alpha.1 +-- want -- +# summary +v0.1.0-alpha.1 is a valid semantic version for this release. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_1_0.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_1_0.test new file mode 100644 index 0000000..05eef2a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_1_0.test @@ -0,0 +1,12 @@ +mod=example.com/first +base=none +release=v0.1.0 +-- want -- +# summary +v0.1.0 is a valid semantic version for this release. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_err.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_err.test new file mode 100644 index 0000000..c655554 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v0_err.test @@ -0,0 +1,19 @@ +mod=example.com/first +base=none +release=v0.0.0 +success=false + +# TODO(golang.org/issue/36087): go list doesn't report positions in correct +# place for scanner errors. +skip=packages.Load gives error with extra "-: " prefix +-- want -- +example.com/first +----------------- +errors in new version: + p.go:1:9: illegal character U+003F '?' +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package ? diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v1_0_0.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v1_0_0.test new file mode 100644 index 0000000..c7400dc --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v1_0_0.test @@ -0,0 +1,12 @@ +mod=example.com/first +base=none +release=v1.0.0 +-- want -- +# summary +v1.0.0 is a valid semantic version for this release. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v1_2_3_explicit_none_base.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v1_2_3_explicit_none_base.test new file mode 100644 index 0000000..2e1588f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v1_2_3_explicit_none_base.test @@ -0,0 +1,13 @@ +mod=example.com/first +base=none +release=v1.2.3 +proxyVersions= +-- want -- +# summary +v1.2.3 is a valid semantic version for this release. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v2_err.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v2_err.test new file mode 100644 index 0000000..dfc71d5 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v2_err.test @@ -0,0 +1,19 @@ +mod=example.com/first/v2 +base=none +release=v2.0.0 +success=false + +# TODO(golang.org/issue/36087): go list doesn't report positions in correct +# place for scanner errors. +skip=packages.Load gives error with extra "-: " prefix +-- want -- +example.com/first +----------------- +errors in new version: + p.go:1:9: illegal character U+003F '?' +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package ? diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v2_moderr.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v2_moderr.test new file mode 100644 index 0000000..833cfa9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/first/v2_moderr.test @@ -0,0 +1,15 @@ +mod=example.com/first +base=none +release=v2.0.0 +success=false +-- want -- +# summary +v2.0.0 is not a valid semantic version for this release. +The module path does not end with the major version suffix /v2, +which is required for major versions v2 or greater. +-- go.mod -- +module example.com/first + +go 1.12 +-- p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/README.txt new file mode 100644 index 0000000..e153198 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/README.txt @@ -0,0 +1,7 @@ +Tests in this directory cover scenarios where errors in a package are fixed. + +v1.0.0 is used as the base version for all tests. +It has an error: the return type of bad.Broken is undefined. + +Each test fixes the error and may make other changes (compatible or not). +Note that fixing a type error in the API appears to be an incompatible change. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_suggest.test new file mode 100644 index 0000000..d545be8 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_suggest.test @@ -0,0 +1,19 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-compatible-other +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# example.com/fix/good +## compatible changes +Better: added + +# summary +Cannot suggest a release version. +Errors were found. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_verify.test new file mode 100644 index 0000000..484c2af --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_verify.test @@ -0,0 +1,19 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-compatible-other +release=v1.1.0 +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# example.com/fix/good +## compatible changes +Better: added + +# summary +v1.1.0 is a valid semantic version for this release. +Errors were found in the base version. Some API changes may be omitted. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_verify_err.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_verify_err.test new file mode 100644 index 0000000..d8d3a92 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_other_verify_err.test @@ -0,0 +1,21 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-compatible-other +release=v1.0.1 +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# example.com/fix/good +## compatible changes +Better: added + +# summary +v1.0.1 is not a valid semantic version for this release. +There are compatible changes, but the minor version is not incremented +over the base version (v1.0.0). diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_same_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_same_suggest.test new file mode 100644 index 0000000..a57baa2 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_same_suggest.test @@ -0,0 +1,17 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-compatible-same +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int +## compatible changes +Worse: added + +# summary +Cannot suggest a release version. +Errors were found. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_same_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_same_verify.test new file mode 100644 index 0000000..6f1c335 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/compatible_same_verify.test @@ -0,0 +1,17 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-compatible-same +release=v1.0.1 # not actually valid, but gorelease can't tell +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int +## compatible changes +Worse: added + +# summary +v1.0.1 is a valid semantic version for this release. +Errors were found in the base version. Some API changes may be omitted. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_other_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_other_suggest.test new file mode 100644 index 0000000..6432119 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_other_suggest.test @@ -0,0 +1,19 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-incompatible-other +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# example.com/fix/good +## incompatible changes +Good: changed from func() int to func() string + +# summary +Cannot suggest a release version. +Errors were found. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_other_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_other_verify.test new file mode 100644 index 0000000..f6fa31c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_other_verify.test @@ -0,0 +1,20 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-incompatible-other +release=v1.1.0 +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# example.com/fix/good +## incompatible changes +Good: changed from func() int to func() string + +# summary +v1.1.0 is not a valid semantic version for this release. +There are incompatible changes. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_same_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_same_suggest.test new file mode 100644 index 0000000..6ad492c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_same_suggest.test @@ -0,0 +1,16 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-incompatible-same +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Bad: changed from func() int to func() string +Broken: changed from func() invalid type to func() int + +# summary +Cannot suggest a release version. +Errors were found. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_same_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_same_verify.test new file mode 100644 index 0000000..e210aec --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/incompatible_same_verify.test @@ -0,0 +1,16 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.1.0-incompatible-same +release=v1.0.1 # not actually valid, but gorelease can't tell +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Bad: changed from func() int to func() string +Broken: changed from func() invalid type to func() int + +# summary +v1.0.1 is a valid semantic version for this release. +Errors were found in the base version. Some API changes may be omitted. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/patch_suggest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/patch_suggest.test new file mode 100644 index 0000000..20360d6 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/patch_suggest.test @@ -0,0 +1,15 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.0.1-patch +success=false +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# summary +Cannot suggest a release version. +Errors were found. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/patch_verify.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/patch_verify.test new file mode 100644 index 0000000..50b55be --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/fix/patch_verify.test @@ -0,0 +1,15 @@ +mod=example.com/fix +base=v1.0.0 +version=v1.0.1-patch +release=v1.0.1 +-- want -- +# example.com/fix/bad +## errors in base version: +bad/bad.go:3:15: undeclared name: NOTYPE + +## incompatible changes +Broken: changed from func() invalid type to func() int + +# summary +v1.0.1 is a valid semantic version for this release. +Errors were found in the base version. Some API changes may be omitted. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/changed_param.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/changed_param.test new file mode 100644 index 0000000..8415e48 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/changed_param.test @@ -0,0 +1,25 @@ +mod=example.com/generics +base=v0.0.1 +-- want -- +# example.com/generics/a +## incompatible changes +Foo: changed from Foo[V any] to Foo[V Number] +## compatible changes +Number: added + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/generics + +go 1.18 +-- a/a.go -- +package a + +type Number interface { + int64 | float64 +} + +type Foo[V Number] interface { + Value() any +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/changed_return.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/changed_return.test new file mode 100644 index 0000000..1592d64 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/changed_return.test @@ -0,0 +1,19 @@ +mod=example.com/generics +base=v0.0.1 +-- want -- +# example.com/generics/a +## incompatible changes +Foo[V any].Value: changed from func() V to func() int + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/generics + +go 1.18 +-- a/a.go -- +package a + +type Foo[V any] interface { + Value() int +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/unchanged.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/unchanged.test new file mode 100644 index 0000000..6cf0d05 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/generics/unchanged.test @@ -0,0 +1,15 @@ +mod=example.com/generics +base=v0.0.1 +-- want -- +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/generics + +go 1.18 +-- a/a.go -- +package a + +type Foo[V any] interface { + Value() V +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/internalcompat/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/internalcompat/README.txt new file mode 100644 index 0000000..e3de7e5 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/internalcompat/README.txt @@ -0,0 +1,20 @@ +Modules example.com/internalcompat/{a,b} are copies. One could be a fork +of the other. An external package p exposes a type from a package q +within the same module. + +gorelease should not report differences between these packages. The types +are distinct, but they correspond (in apidiff terminology), which is the +important property when considering differences between modules. + +There are three use cases to consider: + +1. One module substitutes for the other via a `replace` directive. + Only the replacement module is used, and the package paths are effectively + identical, so the types are not distinct. +2. One module subsititutes for the other by rewriting `import` statements + globally. All references to the original type become references to the + new type, so there is no conflict. +3. One module substitutes for the other by rewriting some `import` statements + but not others (for example, those within a specific consumer package). + In this case, the types are distinct, and even if there are no changes, + the types are not compatible. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/internalcompat/internalcompat.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/internalcompat/internalcompat.test new file mode 100644 index 0000000..9bf59a3 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/internalcompat/internalcompat.test @@ -0,0 +1,5 @@ +mod=example.com/internalcompat/b +version=v1.0.0 +release=v1.0.1 +base=example.com/internalcompat/a@v1.0.0 +-- want -- diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/README.txt new file mode 100644 index 0000000..a8d8104 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/README.txt @@ -0,0 +1,3 @@ +Module example.com/main is used to test changes in main packages. +Main packages aren't importable, so changes to exported functions should not +be reported. But we should still report when packages are added or deleted. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/add.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/add.test new file mode 100644 index 0000000..26089ad --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/add.test @@ -0,0 +1,21 @@ +mod=example.com/main +base=v0.0.1 +-- want -- +# example.com/main/b +## compatible changes +package added + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/main + +go 1.14 +-- a/a.go -- +package main + +func main() {} +-- b/b.go -- +package main + +func main() {} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/change.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/change.test new file mode 100644 index 0000000..6960373 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/change.test @@ -0,0 +1,15 @@ +mod=example.com/main +base=v0.0.1 +-- want -- +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/main + +go 1.14 +-- a/a.go -- +package main + +func Foo() {} + +func main() { Foo() } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/remove.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/remove.test new file mode 100644 index 0000000..702e1d1 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/main/remove.test @@ -0,0 +1,13 @@ +mod=example.com/main +base=v0.0.1 +-- want -- +# example.com/main/a +## incompatible changes +package removed + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/main + +go 1.14 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.0.1.txt new file mode 100644 index 0000000..e5352bf --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.0.1.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.0.txt new file mode 100644 index 0000000..bb39290 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.0.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.1-pre.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.1-pre.txt new file mode 100644 index 0000000..743517b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.1-pre.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.1.txt new file mode 100644 index 0000000..743517b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.1.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.2.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.2.txt new file mode 100644 index 0000000..4055eaa --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v0.1.2.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.0.1.txt new file mode 100644 index 0000000..e5352bf --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.0.1.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.0.txt new file mode 100644 index 0000000..bb39290 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.0.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.1-pre.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.1-pre.txt new file mode 100644 index 0000000..743517b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.1-pre.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.1.txt new file mode 100644 index 0000000..743517b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.1.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.2.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.2.txt new file mode 100644 index 0000000..4055eaa --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v1.1.2.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/basic + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.0.1.txt new file mode 100644 index 0000000..97ea69f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.0.1.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/basic/v2 + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.0.txt new file mode 100644 index 0000000..e3593b9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.0.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic/v2 + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 0 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.1-pre.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.1-pre.txt new file mode 100644 index 0000000..aaa86be --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.1-pre.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic/v2 + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.1.txt new file mode 100644 index 0000000..aaa86be --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.1.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basic/v2 + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A2() int { return 2 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.2.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.2.txt new file mode 100644 index 0000000..0d950c1 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v2_v2.1.2.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/basic/v2 + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v3_v3.0.0-ignore.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v3_v3.0.0-ignore.txt new file mode 100644 index 0000000..8e3cecf --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_v3_v3.0.0-ignore.txt @@ -0,0 +1,6 @@ +-- .info -- +{"Version":"v3.0.0-ignore"} +-- go.mod -- +module example.com/basic/v3 + +go 1.13 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_version-1.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_version-1.0.1.txt new file mode 100644 index 0000000..34e769e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basic_version-1.0.1.txt @@ -0,0 +1,2 @@ +-- .info -- +{"Version":"v1.0.1"} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basicfork_v1.1.2.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basicfork_v1.1.2.txt new file mode 100644 index 0000000..63cb887 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_basicfork_v1.1.2.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/basicfork + +go 1.12 +-- a/a.go -- +package a + +func A() int { return 1 } +func A3() int { return 4 } +-- b/b.go -- +package b + +func B() int { return 3 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v1.0.0.txt new file mode 100644 index 0000000..8f073b0 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v1.0.0.txt @@ -0,0 +1,15 @@ +-- go.sum -- +example.com/cycle v1.5.0 h1:OkE6KLRVRM5XqIH9MMFIvoYCVjxMh8kqsxUzx5481s4= +example.com/cycle v1.5.0/go.mod h1://AqZbyNHeLOKZB3J/UPPXaBvk3nCqvqVRbPkffDx60= +example.com/cycledep v1.0.0 h1:5UDqvIlbZsKzzbZCOaHkxV+X0H6Fi4othxBS57NtjSs= +example.com/cycledep v1.0.0/go.mod h1:Gc4hO1S1BMZaxOcGHwCRmdVcQP8+jAu/PyEgLdGe0xU= +-- go.mod -- +module example.com/cycle + +go 1.12 + +require example.com/cycledep v1.0.0 +-- main.go -- +package main + +import _ "example.com/cycledep"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v1.5.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v1.5.0.txt new file mode 100644 index 0000000..98e8fe8 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v1.5.0.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/cycle + +go 1.12 +-- a.go -- +package a
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v2_v2.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v2_v2.0.0.txt new file mode 100644 index 0000000..95ae8d4 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycle_v2_v2.0.0.txt @@ -0,0 +1,19 @@ +# Note: "go get -d ." will add another example.com/cycle/v2 line. That line is +# non-deterministic, since the module is generate by prepareLoadDir each time. +# However, gorelease should ignore new go.sum entries for the module it's +# testing, since the requirement on that module is fake (a simulation: the user +# isn't actually relying on their own module). +-- go.sum -- +example.com/cycle/v2 v2.0.0/go.mod h1:lkmoN54Yqku+pnE3i6U+PjV87yiHyv3Rbei+phlzGGU= +example.com/cycledep/v2 v2.0.0 h1:B8tgq8pxH4IbvvozFpGx7k+HUeLoAPcmCixOXPZiuTE= +example.com/cycledep/v2 v2.0.0/go.mod h1:wBHRfgrlyovU4csu71ja8ySemxEOKOr8PpAiMU82nLw= +-- go.mod -- +module example.com/cycle/v2 + +go 1.12 + +require example.com/cycledep/v2 v2.0.0 +-- a.go -- +package a + +import _ "example.com/cycledep/v2"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycledep_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycledep_v1.0.0.txt new file mode 100644 index 0000000..83f7e34 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycledep_v1.0.0.txt @@ -0,0 +1,10 @@ +-- go.mod -- +module example.com/cycledep + +go 1.12 + +require example.com/cycle v1.5.0 +-- a.go -- +package a + +import _ "example.com/cycle" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycledep_v2_v2.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycledep_v2_v2.0.0.txt new file mode 100644 index 0000000..7496524 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_cycledep_v2_v2.0.0.txt @@ -0,0 +1,12 @@ +-- go.mod -- +module example.com/cycledep/v2 + +go 1.12 + +require example.com/cycle/v2 v2.0.0 +-- b.go -- +package b +-- c/c.go -- +package c + +import _ "example.com/cycle/v2" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_empty_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_empty_v0.0.1.txt new file mode 100644 index 0000000..8e7df04 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_empty_v0.0.1.txt @@ -0,0 +1,4 @@ +-- go.mod -- +module example.com/empty + +go 1.14 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_empty_v0.0.2.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_empty_v0.0.2.txt new file mode 100644 index 0000000..8e7df04 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_empty_v0.0.2.txt @@ -0,0 +1,4 @@ +-- go.mod -- +module example.com/empty + +go 1.14 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_errors_v0.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_errors_v0.1.0.txt new file mode 100644 index 0000000..3ba57c4 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_errors_v0.1.0.txt @@ -0,0 +1,26 @@ +Module example.com/errors is used to compare modules with errors across +two versions. + +* Package "fixed" has type errors in v0.1.0, fixed in v0.2.0. +* Package "deleted" has type errors in v0.1.0, deleted in v0.2.0. +* Package "broken" is correct in v0.1.0, has type errors in v0.2.0. +* Package "added" doesn't exist in v0.1.0, has type errors in v0.2.0. + +-- go.mod -- +module example.com/errors + +go 1.12 +-- fixed/fixed.go -- +package fixed + +const X int = Missing + +-- deleted/deleted.go -- +package deleted + +const X int = Missing + +-- broken/broken.go -- +package broken + +const X int = 12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_errors_v0.2.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_errors_v0.2.0.txt new file mode 100644 index 0000000..668d59b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_errors_v0.2.0.txt @@ -0,0 +1,18 @@ +-- go.mod -- +module example.com/errors + +go 1.12 +-- fixed/fixed.go -- +package fixed + +const X int = 12 + +-- broken/broken.go -- +package broken + +const X int = Missing + +-- added/added.go -- +package added + +const X int = Missing diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.0.0.txt new file mode 100644 index 0000000..21daf65 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.0.0.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/fix + +go 1.13 +-- bad/bad.go -- +package bad + +func Broken() NOTYPE { return 0 } +func Bad() int { return 1 } +-- good/good.go -- +package good + +func Good() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.0.1-patch.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.0.1-patch.txt new file mode 100644 index 0000000..56c1c66 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.0.1-patch.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/fix + +go 1.13 +-- bad/bad.go -- +package bad + +func Broken() int { return 0 } +func Bad() int { return 1 } +-- good/good.go -- +package good + +func Good() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-compatible-other.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-compatible-other.txt new file mode 100644 index 0000000..068ed8f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-compatible-other.txt @@ -0,0 +1,14 @@ +-- go.mod -- +module example.com/fix + +go 1.13 +-- bad/bad.go -- +package bad + +func Broken() int { return 0 } +func Bad() int { return 1 } +-- good/good.go -- +package good + +func Good() int { return 1 } +func Better() int { return 2 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-compatible-same.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-compatible-same.txt new file mode 100644 index 0000000..6ff9299 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-compatible-same.txt @@ -0,0 +1,14 @@ +-- go.mod -- +module example.com/fix + +go 1.13 +-- bad/bad.go -- +package bad + +func Broken() int { return 0 } +func Bad() int { return 1 } +func Worse() int { return -1 } +-- good/good.go -- +package good + +func Good() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-incompatible-other.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-incompatible-other.txt new file mode 100644 index 0000000..a7013b8 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-incompatible-other.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/fix + +go 1.13 +-- bad/bad.go -- +package bad + +func Broken() int { return 0 } +func Bad() int { return 1 } +-- good/good.go -- +package good + +func Good() string { return "1" } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-incompatible-same.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-incompatible-same.txt new file mode 100644 index 0000000..1fb4891 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_fix_v1.1.0-incompatible-same.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/fix + +go 1.13 +-- bad/bad.go -- +package bad + +func Broken() int { return 0 } +func Bad() string { return "1" } +-- good/good.go -- +package good + +func Good() int { return 1 } diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_generics_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_generics_v0.0.1.txt new file mode 100644 index 0000000..f706512 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_generics_v0.0.1.txt @@ -0,0 +1,10 @@ +-- go.mod -- +module example.com/generics + +go 1.18 +-- a/a.go -- +package a + +type Foo[V any] interface { + Value() V +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_internalcompat_a_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_internalcompat_a_v1.0.0.txt new file mode 100644 index 0000000..5f15418 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_internalcompat_a_v1.0.0.txt @@ -0,0 +1,16 @@ +-- go.mod -- +module example.com/internalcompat/a + +go 1.15 + +-- p/p.go -- +package p + +import "example.com/internalcompat/a/q" + +var V q.Q + +-- q/q.go -- +package q + +type Q struct{} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_internalcompat_b_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_internalcompat_b_v1.0.0.txt new file mode 100644 index 0000000..318db36 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_internalcompat_b_v1.0.0.txt @@ -0,0 +1,16 @@ +-- go.mod -- +module example.com/internalcompat/b + +go 1.15 + +-- p/p.go -- +package p + +import "example.com/internalcompat/b/q" + +var V q.Q + +-- q/q.go -- +package q + +type Q struct{} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_issue37756_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_issue37756_v1.0.0.txt new file mode 100644 index 0000000..b576df8 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_issue37756_v1.0.0.txt @@ -0,0 +1,18 @@ +-- go.mod -- +module example.com/issue37756 + +go 1.14 +-- a/a.go -- +package a + +import _ "example.com/issue37756/b" + +func A1() {} +-- b/b.go -- +package b + +func B1() {} +-- c/c.go -- +package c + +func C1() {} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_issue37756_v1.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_issue37756_v1.1.0.txt new file mode 100644 index 0000000..e35bc51 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_issue37756_v1.1.0.txt @@ -0,0 +1,21 @@ +-- go.mod -- +module example.com/issue37756 + +go 1.14 +-- a/a.go -- +package a + +import _ "example.com/issue37756/c" + +func A1() {} +func A2() {} +-- b/b.go -- +package b + +func B1() {} +func B2() {} +-- c/c.go -- +package c + +func C1() {} +func C2() {} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_main_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_main_v0.0.1.txt new file mode 100644 index 0000000..a76b5b2 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_main_v0.0.1.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/main + +go 1.14 +-- a/a.go -- +package main + +func main() {} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_nomod_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_nomod_v0.0.1.txt new file mode 100644 index 0000000..760a8e8 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_nomod_v0.0.1.txt @@ -0,0 +1,6 @@ +-- .mod -- +module example.com/nomod +-- p/p.go -- +package p // import "example.com/something/different" + +// The import comment above is ignored by gorelease and by modules. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_nomod_v0.0.2.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_nomod_v0.0.2.txt new file mode 100644 index 0000000..06e2024 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_nomod_v0.0.2.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/nomod + +go 1.12 +-- p/p.go -- +package p diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_prerelease_v0.0.0-20300101000000-000000000000.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_prerelease_v0.0.0-20300101000000-000000000000.txt new file mode 100644 index 0000000..e165690 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_prerelease_v0.0.0-20300101000000-000000000000.txt @@ -0,0 +1,4 @@ +-- go.mod -- +module example.com/prerelease + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.0.txt new file mode 100644 index 0000000..ca71c99 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.0.txt @@ -0,0 +1,17 @@ +-- go.mod -- +module example.com/private + +go 1.12 +-- p/p.go -- +package p + +import "example.com/private/internal/i" + +type P i.I + +-- internal/i/i.go -- +package i + +type I interface{} + +func Delete() {} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.1.txt new file mode 100644 index 0000000..1fe445c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.1.txt @@ -0,0 +1,15 @@ +-- go.mod -- +module example.com/private + +go 1.12 +-- p/p.go -- +package p + +import "example.com/private/internal/i" + +type P i.I + +-- internal/i/i.go -- +package i + +type I interface{} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.2-break.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.2-break.txt new file mode 100644 index 0000000..84e3616 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_private_v1.0.2-break.txt @@ -0,0 +1,17 @@ +-- go.mod -- +module example.com/private + +go 1.12 +-- p/p.go -- +package p + +import "example.com/private/internal/i" + +type P i.I + +-- internal/i/i.go -- +package i + +type I interface{ + Foo() +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.0.1.txt new file mode 100644 index 0000000..bc7200f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.0.1.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/require + +go 1.12 +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.1.0.txt new file mode 100644 index 0000000..8f858bf --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.1.0.txt @@ -0,0 +1,14 @@ +-- go.mod -- +module example.com/require + +go 1.12 + +require example.com/basic v1.0.1 +-- go.sum -- +example.com/basic v1.0.1/go.mod h1:pv9xTX7lhV6R1XNYo1EcI/DQqKxDyhNTN+K1DjHW2Oo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +-- require.go -- +package require + diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.1.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.1.1.txt new file mode 100644 index 0000000..620bf66 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_require_v0.1.1.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/require + +go 1.12 + +require example.com/basic v1.1.0 +-- go.sum -- +example.com/basic v1.1.0/go.mod h1:pv9xTX7lhV6R1XNYo1EcI/DQqKxDyhNTN+K1DjHW2Oo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retract_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retract_v0.0.1.txt new file mode 100644 index 0000000..b1466d0 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retract_v0.0.1.txt @@ -0,0 +1,13 @@ +-- go.mod -- +module example.com/retract + +go 1.12 + +require example.com/retractdep v1.0.0 +-- go.sum -- +example.com/retractdep v1.0.0 h1:SOVn6jA2ygQY+v8/5aAwxVUJ9teuLrdH/UmbUtp2C44= +example.com/retractdep v1.0.0/go.mod h1:UjjWSH/ulfbAGgQQwm7pAZ988MFRngUSkJnzcuPsYDI= +-- a.go -- +package a + +import _ "example.com/retractdep" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v1.0.0.txt new file mode 100644 index 0000000..36aa3d9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v1.0.0.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/retractdep + +go 1.12 +-- a.go -- +package a + +const A = "a"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v1.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v1.0.1.txt new file mode 100644 index 0000000..7548ed2 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v1.0.1.txt @@ -0,0 +1,11 @@ +-- go.mod -- +module example.com/retractdep + +go 1.12 + +// Remote-triggered crash in package foo. See CVE-2021-01234. +retract v1.0.0 +-- a.go -- +package a + +const A = "a"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v2_v2.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v2_v2.0.0.txt new file mode 100644 index 0000000..77619e3 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v2_v2.0.0.txt @@ -0,0 +1,12 @@ +# Identical to v1.0.0: just need a new version so that we can test different +# error messages based on the vX.0.1 retraction comments. We can't test them in +# the same major version because go mod will always use the latest version's +# error message. +-- go.mod -- +module example.com/retractdep/v2 + +go 1.12 +-- a.go -- +package a + +const A = "a"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v2_v2.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v2_v2.0.1.txt new file mode 100644 index 0000000..5682baa --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v2_v2.0.1.txt @@ -0,0 +1,10 @@ +-- go.mod -- +module example.com/retractdep/v2 + +go 1.12 + +retract v2.0.0 +-- a.go -- +package a + +const A = "a"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v3_v3.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v3_v3.0.0.txt new file mode 100644 index 0000000..1d526a9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v3_v3.0.0.txt @@ -0,0 +1,12 @@ +# Identical to v1.0.0: just need a new version so that we can test different +# error messages based on the vX.0.1 retraction comments. We can't test them in +# the same major version because go mod will always use the latest version's +# error message. +-- go.mod -- +module example.com/retractdep/v3 + +go 1.12 +-- a.go -- +package a + +const A = "a"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v3_v3.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v3_v3.0.1.txt new file mode 100644 index 0000000..ed39efb --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retractdep_v3_v3.0.1.txt @@ -0,0 +1,11 @@ +-- go.mod -- +module example.com/retractdep/v3 + +go 1.12 + +// This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. This is a very long message. +retract v3.0.0 +-- a.go -- +package a + +const A = "a"
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retracttransitive_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retracttransitive_v0.0.1.txt new file mode 100644 index 0000000..885906f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_retracttransitive_v0.0.1.txt @@ -0,0 +1,15 @@ +-- go.mod -- +module example.com/retracttransitive + +go 1.12 + +require example.com/retract v0.0.1 +-- go.sum -- +example.com/retract v0.0.1 h1:Afj8efoHilltHZNLlEARzpc1Vkc5d6ugWKIE/YDmXuQ= +example.com/retract v0.0.1/go.mod h1:DUqXjcGF3aJhkjxsUjQ0DG65b51DDBvFrEbcr9kkyto= +example.com/retractdep v1.0.0 h1:SOVn6jA2ygQY+v8/5aAwxVUJ9teuLrdH/UmbUtp2C44= +example.com/retractdep v1.0.0/go.mod h1:UjjWSH/ulfbAGgQQwm7pAZ988MFRngUSkJnzcuPsYDI= +-- a.go -- +package a + +import _ "example.com/retract" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_nest_v1.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_nest_v1.0.0.txt new file mode 100644 index 0000000..36f5b33 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_nest_v1.0.0.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/sub/nest + +go 1.12 +-- nest.go -- +package nest diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_nest_v2_v2.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_nest_v2_v2.0.0.txt new file mode 100644 index 0000000..b7dc8a7 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_nest_v2_v2.0.0.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/sub/nest/v2 + +go 1.12 +-- nest.go -- +package nest diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_v2_v2.0.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_v2_v2.0.0.txt new file mode 100644 index 0000000..488f2dc --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_sub_v2_v2.0.0.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/sub/v2 + +go 1.12 +-- sub.go -- +package sub diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_a_v0.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_a_v0.1.0.txt new file mode 100644 index 0000000..d9c71aa --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_a_v0.1.0.txt @@ -0,0 +1,10 @@ +-- go.mod -- +module example.com/tidy/a + +go 1.12 + +require example.com/tidy/b v0.2.0 +-- p.go -- +package a + +import _ "example.com/tidy/b" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_b_v0.1.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_b_v0.1.0.txt new file mode 100644 index 0000000..d169972 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_b_v0.1.0.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/tidy/b + +go 1.12 +-- p.go -- +package b diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_b_v0.2.0.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_b_v0.2.0.txt new file mode 100644 index 0000000..470b743 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_b_v0.2.0.txt @@ -0,0 +1,8 @@ +-- go.mod -- +module example.com/tidy/b + +go 1.12 +-- p.go -- +package b + +func B() {} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_v0.0.1.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_v0.0.1.txt new file mode 100644 index 0000000..f6e7fff --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/mod/example.com_tidy_v0.0.1.txt @@ -0,0 +1,6 @@ +-- go.mod -- +module example.com/tidy + +go 1.12 +-- tidy.go -- +package tidy diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/nomod/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/nomod/README.txt new file mode 100644 index 0000000..ed50bb0 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/nomod/README.txt @@ -0,0 +1,2 @@ +Module example.com/nomod is used to test situations where no go.mod file +is present. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/nomod/nomod.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/nomod/nomod.test new file mode 100644 index 0000000..c307d13 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/nomod/nomod.test @@ -0,0 +1,8 @@ +mod=example.com/nomod +version=v0.0.2 +base=v0.0.1 +release=v0.0.2 +proxyVersions=example.com/nomod@v0.0.1 +-- want -- +# summary +v0.0.2 is a valid semantic version for this release. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/README.txt new file mode 100644 index 0000000..82f95f1 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/README.txt @@ -0,0 +1 @@ +Module example.com/patherrors tests errors related to paths.
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/abspath.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/abspath.test new file mode 100644 index 0000000..317364e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/abspath.test @@ -0,0 +1,8 @@ +mod=example.com/patherrors +base=none +error=true +-- want -- +module path "/home/gopher/go/src/mymod" must not be an absolute path. +It must be an address where your module may be found. +-- go.mod -- +module /home/gopher/go/src/mymod diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/badmajor.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/badmajor.test new file mode 100644 index 0000000..4f5d027 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/badmajor.test @@ -0,0 +1,10 @@ +mod=example.com/patherrors +base=none +error=true +-- want -- +module path "example.com/patherrors/v0" has major version suffix "v0". +A major version suffix is only allowed for v2 or later. +-- go.mod -- +module example.com/patherrors/v0 + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_branch.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_branch.test new file mode 100644 index 0000000..66f79bb --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_branch.test @@ -0,0 +1,20 @@ +dir=dup +base=none +success=false +vcs=git +-- dup/go.mod -- +module example.com/dup/v2 + +go 1.13 +-- dup/v2/go.mod -- +module example.com/dup/v2 + +go 1.13 +-- want -- +# diagnostics +module is defined in two locations: + dup/go.mod + dup/v2/go.mod + +# summary +Suggested version: v2.0.0 (with tag dup/v2.0.0) diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_dir.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_dir.test new file mode 100644 index 0000000..3898da4 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_dir.test @@ -0,0 +1,20 @@ +dir=dup/v2 +base=none +success=false +vcs=git +-- dup/go.mod -- +module example.com/dup/v2 + +go 1.13 +-- dup/v2/go.mod -- +module example.com/dup/v2 + +go 1.13 +-- want -- +# diagnostics +module is defined in two locations: + dup/v2/go.mod + dup/go.mod + +# summary +Suggested version: v2.0.0 (with tag dup/v2.0.0) diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_ok.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_ok.test new file mode 100644 index 0000000..afd157c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/dup_roots_ok.test @@ -0,0 +1,14 @@ +dir=dup/v2 +base=none +vcs=git +-- dup/go.mod -- +module example.com/dup + +go 1.13 +-- dup/v2/go.mod -- +module example.com/dup/v2 + +go 1.13 +-- want -- +# summary +Suggested version: v2.0.0 (with tag dup/v2.0.0) diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/gopkginsub.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/gopkginsub.test new file mode 100644 index 0000000..2c2fb7c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/gopkginsub.test @@ -0,0 +1,16 @@ +mod=example.com/patherrors +base=none +dir=yaml +success=false +vcs=git +-- want -- +# diagnostics +go.mod: go directive is missing +gopkg.in/yaml.v2: module path starts with gopkg.in and must be declared in the root directory of the repository + +# summary +Suggested version: v2.0.0 +-- .mod -- +module example.com/patherrors +-- yaml/go.mod -- +module gopkg.in/yaml.v2 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/pathsub.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/pathsub.test new file mode 100644 index 0000000..000c02a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/pathsub.test @@ -0,0 +1,17 @@ +mod=example.com/patherrors +dir=x +base=none +success=false +vcs=git +-- want -- +# diagnostics +example.com/y: module path must end with "x", since it is in subdirectory "x" + +# summary +Suggested version: v0.1.0 +-- .mod -- +module example.com/patherrors +-- x/go.mod -- +module example.com/y + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/pathsubv2.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/pathsubv2.test new file mode 100644 index 0000000..8ab2c80 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/patherrors/pathsubv2.test @@ -0,0 +1,17 @@ +mod=example.com/patherrors +base=none +dir=x +success=false +vcs=git +-- want -- +# diagnostics +example.com/y/v2: module path must end with "x" or "x/v2", since it is in subdirectory "x" + +# summary +Suggested version: v2.0.0 +-- .mod -- +module example.com/patherrors +-- x/go.mod -- +module example.com/y/v2 + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/README.txt new file mode 100644 index 0000000..64a4c96 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/README.txt @@ -0,0 +1 @@ +This directory contains tests for pre-release versions.
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_2.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_2.test new file mode 100644 index 0000000..0597098 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_2.test @@ -0,0 +1,16 @@ +mod=example.com/prerelease +release=v0.0.0-2 +success=false +-- want -- +# diagnostics +Version v0.0.0-2 is lower than most pseudo-versions. Consider releasing v0.1.0-0 instead. + +# summary +Inferred base version: none +v0.0.0-2 is a valid semantic version for this release. +Note: v0.0.0-2 sorts lower in MVS than pseudo-versions, which may be +unexpected for users. So, it may be better to choose a different suffix. +-- go.mod -- +module example.com/prerelease + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_3.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_3.test new file mode 100644 index 0000000..7f6b26f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_3.test @@ -0,0 +1,16 @@ +mod=example.com/prerelease +release=v0.0.0-3 +success=false +-- want -- +# diagnostics +Version v0.0.0-3 is lower than most pseudo-versions. Consider releasing v0.1.0-0 instead. + +# summary +Inferred base version: none +v0.0.0-3 is a valid semantic version for this release. +Note: v0.0.0-3 sorts lower in MVS than pseudo-versions, which may be +unexpected for users. So, it may be better to choose a different suffix. +-- go.mod -- +module example.com/prerelease + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_beta2.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_beta2.test new file mode 100644 index 0000000..b265a86 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_beta2.test @@ -0,0 +1,10 @@ +mod=example.com/prerelease +release=v0.0.0-beta2 +-- want -- +# summary +Inferred base version: none +v0.0.0-beta2 is a valid semantic version for this release. +-- go.mod -- +module example.com/prerelease + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_build_metadata.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_build_metadata.test new file mode 100644 index 0000000..4d3be83 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_build_metadata.test @@ -0,0 +1,11 @@ +mod=example.com/prerelease +release=v1.0.0-alpha+001 +error=true +-- want -- +usage: gorelease [-base=version] [-version=version] +release version "v1.0.0-alpha+001" is not a canonical semantic version: build metadata is not supported +For more information, run go doc golang.org/x/exp/cmd/gorelease +-- go.mod -- +module example.com/prerelease + +go 1.12
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_wordsonly.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_wordsonly.test new file mode 100644 index 0000000..a59aa40 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/prerelease/prerelease_wordsonly.test @@ -0,0 +1,10 @@ +mod=example.com/prerelease +release=v0.0.0-some-words-only-suffix +-- want -- +# summary +Inferred base version: none +v0.0.0-some-words-only-suffix is a valid semantic version for this release. +-- go.mod -- +module example.com/prerelease + +go 1.12 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/README.txt new file mode 100644 index 0000000..226b06d --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/README.txt @@ -0,0 +1,3 @@ +Module example.com/private is used to test that changes to +internal packages are not reported unless they affect the exported +API of non-internal packages. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/break.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/break.test new file mode 100644 index 0000000..3e4ec87 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/break.test @@ -0,0 +1,12 @@ +mod=example.com/private +version=v1.0.2-break +base=v1.0.1 +success=false +-- want -- +# example.com/private/p +## incompatible changes +I.Foo: added + +# summary +Cannot suggest a release version. +Incompatible changes were detected. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/unreported.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/unreported.test new file mode 100644 index 0000000..20567b6 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/private/unreported.test @@ -0,0 +1,7 @@ +mod=example.com/private +version=v1.0.1 +base=v1.0.0 +proxyVersions=example.com/private@v1.0.0 +-- want -- +# summary +Suggested version: v1.0.1 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/regress/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/regress/README.txt new file mode 100644 index 0000000..ee55a78 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/regress/README.txt @@ -0,0 +1 @@ +This directory contains unrelated tests, used to verify issues are fixed.
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/regress/issue37756.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/regress/issue37756.test new file mode 100644 index 0000000..07b6017 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/regress/issue37756.test @@ -0,0 +1,21 @@ +# Verifies golang.org/issue/37756. +# Packages should be compared in lexical order by package path. +mod=example.com/issue37756 +version=v1.1.0 +base=v1.0.0 +proxyVersions=example.com/issue37756@v1.0.0 +-- want -- +# example.com/issue37756/a +## compatible changes +A2: added + +# example.com/issue37756/b +## compatible changes +B2: added + +# example.com/issue37756/c +## compatible changes +C2: added + +# summary +Suggested version: v1.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/README.txt new file mode 100644 index 0000000..f905232 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/README.txt @@ -0,0 +1,2 @@ +This directory contain tests that assert gorelease behavior when module +requirements (and require statements in the go.mod) have changed.
\ No newline at end of file diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/add_requirement.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/add_requirement.test new file mode 100644 index 0000000..59ef3db --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/add_requirement.test @@ -0,0 +1,19 @@ +mod=example.com/require +base=v0.0.1 +proxyVersions=example.com/require@v0.0.1,example.com/basic@v1.0.1 +-- want -- +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/require + +go 1.12 + +require example.com/basic v1.0.1 +-- go.sum -- +example.com/basic v1.0.1/go.mod h1:pv9xTX7lhV6R1XNYo1EcI/DQqKxDyhNTN+K1DjHW2Oo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/decrement_go_version.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/decrement_go_version.test new file mode 100644 index 0000000..ce461d5 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/decrement_go_version.test @@ -0,0 +1,13 @@ +mod=example.com/require +base=v0.0.1 +proxyVersions=example.com/require@v0.0.1 +-- want -- +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/require + +go 1.11 +-- go.sum -- +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/decrement_requirement_minor.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/decrement_requirement_minor.test new file mode 100644 index 0000000..f64e3e3 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/decrement_requirement_minor.test @@ -0,0 +1,18 @@ +mod=example.com/require +base=v0.1.1 +-- want -- +# summary +Suggested version: v0.1.2 +-- go.mod -- +module example.com/require + +go 1.12 + +require example.com/basic v0.0.1 +-- go.sum -- +example.com/basic v0.0.1/go.mod h1:pv9xTX7lhV6R1XNYo1EcI/DQqKxDyhNTN+K1DjHW2Oo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_go_version.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_go_version.test new file mode 100644 index 0000000..802ac6e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_go_version.test @@ -0,0 +1,13 @@ +mod=example.com/require +base=v0.0.1 +proxyVersions=example.com/require@v0.0.1 +-- want -- +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/require + +go 1.13 +-- go.sum -- +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_requirement_minor.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_requirement_minor.test new file mode 100644 index 0000000..821ff2a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_requirement_minor.test @@ -0,0 +1,19 @@ +mod=example.com/require +base=v0.1.0 +proxyVersions=example.com/require@v0.1.0,example.com/basic@v1.1.0,example.com/basic@v1.0.1 +-- want -- +# summary +Suggested version: v0.2.0 +-- go.mod -- +module example.com/require + +go 1.12 + +require example.com/basic v1.1.0 +-- go.sum -- +example.com/basic v1.1.0/go.mod h1:pv9xTX7lhV6R1XNYo1EcI/DQqKxDyhNTN+K1DjHW2Oo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_requirement_patch.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_requirement_patch.test new file mode 100644 index 0000000..d183300 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/increment_requirement_patch.test @@ -0,0 +1,19 @@ +mod=example.com/require +base=v0.1.1 +proxyVersions=example.com/require@v0.1.1,example.com/basic@v1.1.1,example.com/basic@v1.1.0 +-- want -- +# summary +Suggested version: v0.1.2 +-- go.mod -- +module example.com/require + +go 1.12 + +require example.com/basic v1.1.1 +-- go.sum -- +example.com/basic v1.1.1/go.mod h1:pv9xTX7lhV6R1XNYo1EcI/DQqKxDyhNTN+K1DjHW2Oo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/remove_requirements.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/remove_requirements.test new file mode 100644 index 0000000..91a8837 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/require/remove_requirements.test @@ -0,0 +1,13 @@ +mod=example.com/require +base=v0.0.1 +proxyVersions=example.com/require@v0.0.1 +-- want -- +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/require + +go 1.12 +-- go.sum -- +-- require.go -- +package require diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_direct_dep.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_direct_dep.test new file mode 100644 index 0000000..7777dff --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_direct_dep.test @@ -0,0 +1,10 @@ +mod=example.com/retract +version=v0.0.1 +success=false +-- want -- +# diagnostics +required module example.com/retractdep@v1.0.0 retracted by module author: Remote-triggered crash in package foo. See CVE-2021-01234. + +# summary +Inferred base version: v0.0.1 +Suggested version: v0.0.2 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_long_msg.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_long_msg.test new file mode 100644 index 0000000..1f2776f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_long_msg.test @@ -0,0 +1,22 @@ +mod=example.com/retract +success=false +-- want -- +# diagnostics +required module example.com/retractdep/v3@v3.0.0 retracted by module author + +# summary +Inferred base version: v0.0.1 +Suggested version: v0.1.0 +-- go.mod -- +module example.com/retract + +go 1.12 + +require example.com/retractdep/v3 v3.0.0 +-- go.sum -- +example.com/retractdep/v3 v3.0.0 h1:LEaqsEpt7J4Er+qSPqL7bENpIkRdZdaOE6KaUaiNB5I= +example.com/retractdep/v3 v3.0.0/go.mod h1:B2rEwAWayv3FJ2jyeiq9O3UBbxSvdDqZUtxmKsLyg6k= +-- a.go -- +package a + +import _ "example.com/retractdep/v3" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_no_msg.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_no_msg.test new file mode 100644 index 0000000..7a748f7 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_no_msg.test @@ -0,0 +1,22 @@ +mod=example.com/retract +success=false +-- want -- +# diagnostics +required module example.com/retractdep/v2@v2.0.0 retracted by module author + +# summary +Inferred base version: v0.0.1 +Suggested version: v0.1.0 +-- go.mod -- +module example.com/retract + +go 1.12 + +require example.com/retractdep/v2 v2.0.0 +-- go.sum -- +example.com/retractdep/v2 v2.0.0 h1:ehV4yfX3A3jNlRnBmHPxq1TyVs1EhmCYI5miEva6Gv8= +example.com/retractdep/v2 v2.0.0/go.mod h1:rV+p/Yqwnupg15GPVGFRq+un/MYczBZcF1IZ8ubecag= +-- a.go -- +package a + +import _ "example.com/retractdep/v2" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_transitive_dep.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_transitive_dep.test new file mode 100644 index 0000000..681702a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/retract/retract_verify_transitive_dep.test @@ -0,0 +1,12 @@ +# When a retracted version is transitively depended upon, it should still +# result in a retraction error. +mod=example.com/retracttransitive +version=v0.0.1 +success=false +-- want -- +# diagnostics +required module example.com/retractdep@v1.0.0 retracted by module author: Remote-triggered crash in package foo. See CVE-2021-01234. + +# summary +Inferred base version: v0.0.1 +Suggested version: v0.0.2 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/README.txt new file mode 100644 index 0000000..54ff480 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/README.txt @@ -0,0 +1,10 @@ +This directory contains tests for modules that aren't at the root +of the repository, which is marked with a .git directory. +We're comparing against an earlier published version with a +trivial package. Nothing has changed except the location of the +module within the repository. + + example.com/sub - corresponds to the root directory. Not a module. + example.com/sub/v2 - may be in v2 subdirectory. + example.com/sub/nest - nested module in subdirectory + example.com/sub/nest/v2 - may be in nest or nest/v2. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest.test new file mode 100644 index 0000000..c2a6436 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest.test @@ -0,0 +1,13 @@ +mod=example.com/sub/nest +dir=nest +base=v1.0.0 +vcs=git +-- want -- +# summary +Suggested version: v1.0.1 (with tag nest/v1.0.1) +-- nest/go.mod -- +module example.com/sub/nest + +go 1.12 +-- nest/nest.go -- +package nest diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest_v2.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest_v2.test new file mode 100644 index 0000000..6d8bf0c --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest_v2.test @@ -0,0 +1,13 @@ +mod=example.com/sub/nest/v2 +dir=nest +base=v2.0.0 +vcs=git +-- want -- +# summary +Suggested version: v2.0.1 (with tag nest/v2.0.1) +-- nest/go.mod -- +module example.com/sub/nest/v2 + +go 1.12 +-- nest/nest.go -- +package nest diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest_v2_dir.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest_v2_dir.test new file mode 100644 index 0000000..7e99c1e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/nest_v2_dir.test @@ -0,0 +1,13 @@ +mod=example.com/sub/nest/v2 +dir=nest/v2 +base=v2.0.0 +vcs=git +-- want -- +# summary +Suggested version: v2.0.1 (with tag nest/v2.0.1) +-- nest/v2/go.mod -- +module example.com/sub/nest/v2 + +go 1.12 +-- nest/v2/nest.go -- +package nest diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/v2_dir.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/v2_dir.test new file mode 100644 index 0000000..ed07eb9 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/v2_dir.test @@ -0,0 +1,13 @@ +mod=example.com/sub/v2 +dir=v2 +base=v2.0.0 +vcs=git +-- want -- +# summary +Suggested version: v2.0.1 +-- v2/go.mod -- +module example.com/sub/v2 + +go 1.12 +-- v2/sub.go -- +package sub diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/v2_root.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/v2_root.test new file mode 100644 index 0000000..1a34c67 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/sub/v2_root.test @@ -0,0 +1,12 @@ +mod=example.com/sub/v2 +base=v2.0.0 +vcs=git +-- want -- +# summary +Suggested version: v2.0.1 +-- go.mod -- +module example.com/sub/v2 + +go 1.12 +-- sub.go -- +package sub diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/README.txt b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/README.txt new file mode 100644 index 0000000..0ca2fb4 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/README.txt @@ -0,0 +1,5 @@ +Module example.com/tidy tests versions that do not have tidy +go.mod or go.sum files. + +v0.0.1 has a trivial package with no imports. It has no requirements +and no go.sum, so it is tidy. Tests make changes on top of this. diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/empty_sum.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/empty_sum.test new file mode 100644 index 0000000..69a51fb --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/empty_sum.test @@ -0,0 +1,20 @@ +mod=example.com/tidy +base=v0.0.1 +success=false +-- want -- +# diagnostics +go.sum: one or more sums are missing. Run 'go mod tidy' to add missing sums. + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/tidy + +go 1.12 + +require example.com/basic v1.0.1 +-- go.sum -- +-- tidy.go -- +package tidy + +import _ "example.com/basic/a" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/misleading_req.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/misleading_req.test new file mode 100644 index 0000000..b4b2954 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/misleading_req.test @@ -0,0 +1,31 @@ +mod=example.com/tidy +base=none +success=false +-- go.mod -- +module example.com/tidy + +go 1.12 + +require ( + example.com/tidy/a v0.1.0 // actually transitively requires v0.2.0 + example.com/tidy/b v0.1.0 +) +-- go.sum -- +example.com/tidy/a v0.1.0 h1:hxFAdyLfJ6TV25ffYI2oA+g3ffLp+XJgo6lrVkT8ufU= +example.com/tidy/a v0.1.0/go.mod h1:/KTGkbP1cnyJLO5kGL/QSCswh5I8R66epCmEAxgAK+I= +example.com/tidy/b v0.1.0/go.mod h1:92saqyRYqaI4eqrr6LGMnPfBDXc2yofWznwSxsvqfEw= +example.com/tidy/b v0.2.0 h1:dSh97fZcMRg87GDb1Gqwy8/mebsrmE4kX3S7d+KeSZU= +example.com/tidy/b v0.2.0/go.mod h1:92saqyRYqaI4eqrr6LGMnPfBDXc2yofWznwSxsvqfEw= +-- tidy.go -- +package tidy + +import _ "example.com/tidy/a" +import _ "example.com/tidy/b" +-- want -- +# diagnostics +go.mod: the following requirements are needed + example.com/tidy/b@v0.2.0 +Run 'go mod tidy' to add missing requirements. + +# summary +Suggested version: v0.1.0 diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_go.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_go.test new file mode 100644 index 0000000..99ca05a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_go.test @@ -0,0 +1,13 @@ +mod=example.com/tidy +base=v0.0.1 +success=0 +-- want -- +# diagnostics +go.mod: go directive is missing + +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/tidy +-- tidy.go -- +package tidy diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_basic.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_basic.test new file mode 100644 index 0000000..97a95a3 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_basic.test @@ -0,0 +1,19 @@ +mod=example.com/tidy +base=v0.0.1 +success=false +-- want -- +# diagnostics +go.mod: the following requirements are needed + example.com/basic@v1.1.2 +Run 'go mod tidy' to add missing requirements. + +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/tidy + +go 1.12 +-- tidy.go -- +package tidy + +import _ "example.com/basic/a" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_nested.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_nested.test new file mode 100644 index 0000000..1533d6a --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_nested.test @@ -0,0 +1,25 @@ +mod=example.com/tidy +base=v0.0.1 +success=false +-- want -- +# example.com/tidy/subdir +## compatible changes +package added + +# diagnostics +go.mod: the following requirements are needed + example.com/basic@v1.1.2 +Run 'go mod tidy' to add missing requirements. + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/tidy + +go 1.12 +-- tidy.go -- +package tidy +-- subdir/tidy.go -- +package subpkg + +import _ "example.com/basic/a" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_submodule.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_submodule.test new file mode 100644 index 0000000..e210c2d --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_submodule.test @@ -0,0 +1,20 @@ +mod=example.com/tidy +base=v0.0.1 +success=true +-- want -- +# summary +Suggested version: v0.0.2 +-- go.mod -- +module example.com/tidy + +go 1.12 +-- foo/go.mod -- +module example.com/tidy/foo + +go 1.12 +-- tidy.go -- +package tidy +-- foo/tidy.go -- +package subpkg + +import _ "example.com/basic/a" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test new file mode 100644 index 0000000..c06f465 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test @@ -0,0 +1,25 @@ +mod=example.com/tidy +base=v0.0.1 +success=false +-- want -- +# example.com/tidy/subdir/subsubdir +## compatible changes +package added + +# diagnostics +go.mod: the following requirements are needed + example.com/basic@v1.1.2 +Run 'go mod tidy' to add missing requirements. + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/tidy + +go 1.12 +-- tidy.go -- +package tidy +-- subdir/subsubdir/tidy.go -- +package subpkg + +import _ "example.com/basic/a" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/no_sum.test b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/no_sum.test new file mode 100644 index 0000000..f4ff48b --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/gorelease/testdata/tidy/no_sum.test @@ -0,0 +1,19 @@ +mod=example.com/tidy +base=v0.0.1 +success=false +-- want -- +# diagnostics +go.sum: one or more sums are missing. Run 'go mod tidy' to add missing sums. + +# summary +Suggested version: v0.1.0 +-- go.mod -- +module example.com/tidy + +go 1.12 + +require example.com/basic v1.1.2 +-- tidy.go -- +package tidy + +import _ "example.com/basic/a" diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/main.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/main.go new file mode 100644 index 0000000..db2bfe6 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/main.go @@ -0,0 +1,122 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build darwin +// +build darwin + +// Command macOS-roots-test runs crypto/x509.TestSystemRoots as a +// stand-alone binary for crowdsourced testing. +package main + +import ( + "crypto/x509" + "fmt" + "log" + "os" + "os/exec" + "time" + "unsafe" +) + +type CertPool struct { + bySubjectKeyId map[string][]int + byName map[string][]int + certs []*x509.Certificate +} + +func (s *CertPool) contains(cert *x509.Certificate) bool { + if s == nil { + return false + } + + candidates := s.byName[string(cert.RawSubject)] + for _, c := range candidates { + if s.certs[c].Equal(cert) { + return true + } + } + + return false +} + +func main() { + var failed bool + + t0 := time.Now() + sysRootsExt, err := loadSystemRoots() // actual system roots + sysRootsDuration := time.Since(t0) + + if err != nil { + log.Fatalf("failed to read system roots (cgo): %v", err) + } + sysRoots := (*CertPool)(unsafe.Pointer(sysRootsExt)) + + t1 := time.Now() + execRootsExt, err := execSecurityRoots() // non-cgo roots + execSysRootsDuration := time.Since(t1) + + if err != nil { + log.Fatalf("failed to read system roots (nocgo): %v", err) + } + execRoots := (*CertPool)(unsafe.Pointer(execRootsExt)) + + fmt.Printf(" cgo sys roots: %v\n", sysRootsDuration) + fmt.Printf("non-cgo sys roots: %v\n", execSysRootsDuration) + + // On Mavericks, there are 212 bundled certs, at least there was at + // one point in time on one machine. (Maybe it was a corp laptop + // with extra certs?) Other OS X users report 135, 142, 145... + // Let's try requiring at least 100, since this is just a sanity + // check. + if want, have := 100, len(sysRoots.certs); have < want { + failed = true + fmt.Printf("want at least %d system roots, have %d\n", want, have) + } + + // Check that the two cert pools are the same. + sysPool := make(map[string]*x509.Certificate, len(sysRoots.certs)) + for _, c := range sysRoots.certs { + sysPool[string(c.Raw)] = c + } + for _, c := range execRoots.certs { + if _, ok := sysPool[string(c.Raw)]; ok { + delete(sysPool, string(c.Raw)) + } else { + // verify-cert lets in certificates that are not trusted roots, but are + // signed by trusted roots. This should not be a problem, so confirm that's + // the case and skip them. + if _, err := c.Verify(x509.VerifyOptions{ + Roots: sysRootsExt, + Intermediates: execRootsExt, // the intermediates for EAP certs are stored in the keychain + KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageAny}, + }); err != nil { + failed = true + fmt.Printf("certificate only present in non-cgo pool: %v (verify error: %v)\n", c.Subject, err) + } else { + fmt.Printf("signed certificate only present in non-cgo pool (acceptable): %v\n", c.Subject) + } + } + } + for _, c := range sysPool { + failed = true + fmt.Printf("certificate only present in cgo pool: %v\n", c.Subject) + } + + if failed && debugDarwinRoots { + cmd := exec.Command("security", "dump-trust-settings") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Run() + cmd = exec.Command("security", "dump-trust-settings", "-d") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Run() + } + + if failed { + fmt.Printf("\n\n!!! The test failed!\n\nPlease report *the whole output* at https://github.com/golang/go/issues/24652 wrapping it in ``` a code block ```\nThank you!\n") + } else { + fmt.Printf("\n\nThe test passed, no need to report the output. Thank you.\n") + } +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_cgo_darwin.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_cgo_darwin.go new file mode 100644 index 0000000..591098f --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_cgo_darwin.go @@ -0,0 +1,290 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +/* +#cgo CFLAGS: -mmacosx-version-min=10.10 -D__MAC_OS_X_VERSION_MAX_ALLOWED=101300 +#cgo LDFLAGS: -framework CoreFoundation -framework Security + +#include <errno.h> +#include <sys/sysctl.h> + +#include <CoreFoundation/CoreFoundation.h> +#include <Security/Security.h> + +void CFReleaseIfNotNULL(CFTypeRef cf) { + if (cf != NULL) CFRelease(cf); +} + +static bool isSSLPolicy(SecPolicyRef policyRef) { + if (!policyRef) { + return false; + } + CFDictionaryRef properties = SecPolicyCopyProperties(policyRef); + if (properties == NULL) { + return false; + } + CFTypeRef value = NULL; + if (CFDictionaryGetValueIfPresent(properties, kSecPolicyOid, (const void **)&value)) { + CFRelease(properties); + return CFEqual(value, kSecPolicyAppleSSL); + } + CFRelease(properties); + return false; +} + +// sslTrustSettingsResult obtains the final kSecTrustSettingsResult value +// for a certificate in the user or admin domain, combining usage constraints +// for the SSL SecTrustSettingsPolicy, ignoring SecTrustSettingsKeyUsage, +// kSecTrustSettingsAllowedError and kSecTrustSettingsPolicyString. +// https://developer.apple.com/documentation/security/1400261-sectrustsettingscopytrustsetting +static SInt32 sslTrustSettingsResult(SecCertificateRef cert) { + CFArrayRef trustSettings = NULL; + OSStatus err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainUser, &trustSettings); + + // According to Apple's SecTrustServer.c, "user trust settings overrule admin trust settings", + // but the rules of the override are unclear. Let's assume admin trust settings are applicable + // if and only if user trust settings fail to load or are NULL. + if (err != errSecSuccess || trustSettings == NULL) { + CFReleaseIfNotNULL(trustSettings); + err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainAdmin, &trustSettings); + } + + // > no trust settings [...] means "this certificate must be verified to a known trusted certificate” + if (err != errSecSuccess || trustSettings == NULL) { + CFReleaseIfNotNULL(trustSettings); + return kSecTrustSettingsResultUnspecified; + } + + // > An empty trust settings array means "always trust this certificate” with an + // > overall trust setting for the certificate of kSecTrustSettingsResultTrustRoot. + if (CFArrayGetCount(trustSettings) == 0) { + CFReleaseIfNotNULL(trustSettings); + return kSecTrustSettingsResultTrustRoot; + } + + // kSecTrustSettingsResult is defined as CFSTR("kSecTrustSettingsResult"), + // but the Go linker's internal linking mode can't handle CFSTR relocations. + // Create our own dynamic string instead and release it below. + CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString( + NULL, "kSecTrustSettingsResult", kCFStringEncodingUTF8); + CFStringRef _kSecTrustSettingsPolicy = CFStringCreateWithCString( + NULL, "kSecTrustSettingsPolicy", kCFStringEncodingUTF8); + + CFIndex m; SInt32 result = 0; + for (m = 0; m < CFArrayGetCount(trustSettings); m++) { + CFDictionaryRef tSetting = (CFDictionaryRef)CFArrayGetValueAtIndex(trustSettings, m); + + // First, check if this trust setting applies to our policy. We assume + // only one will. The docs suggest that there might be multiple applying + // but don't explain how to combine them. + SecPolicyRef policyRef; + if (CFDictionaryGetValueIfPresent(tSetting, _kSecTrustSettingsPolicy, (const void**)&policyRef)) { + if (!isSSLPolicy(policyRef)) { + continue; + } + } else { + continue; + } + + CFNumberRef cfNum; + if (CFDictionaryGetValueIfPresent(tSetting, _kSecTrustSettingsResult, (const void**)&cfNum)) { + CFNumberGetValue(cfNum, kCFNumberSInt32Type, &result); + } else { + // > If the value of the kSecTrustSettingsResult component is not + // > kSecTrustSettingsResultUnspecified for a usage constraints dictionary that has + // > no constraints, the default value kSecTrustSettingsResultTrustRoot is assumed. + result = kSecTrustSettingsResultTrustRoot; + } + + break; + } + + // If trust settings are present, but none of them match the policy... + // the docs don't tell us what to do. + // + // "Trust settings for a given use apply if any of the dictionaries in the + // certificate’s trust settings array satisfies the specified use." suggests + // that it's as if there were no trust settings at all, so we should probably + // fallback to the admin trust settings. TODO. + if (result == 0) { + result = kSecTrustSettingsResultUnspecified; + } + + CFRelease(_kSecTrustSettingsResult); + CFRelease(trustSettings); + + return result; +} + +// FetchPEMRoots fetches the system's list of trusted X.509 root certificates +// for the kSecTrustSettingsPolicy SSL. +// +// On success it returns 0 and fills pemRoots with a CFDataRef that contains the extracted root +// certificates of the system. On failure, the function returns -1. +// Additionally, it fills untrustedPemRoots with certs that must be removed from pemRoots. +// +// Note: The CFDataRef returned in pemRoots and untrustedPemRoots must +// be released (using CFRelease) after we've consumed its content. +int _FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots, bool debugDarwinRoots) { + int i; + + if (debugDarwinRoots) { + printf("crypto/x509: kSecTrustSettingsResultInvalid = %d\n", kSecTrustSettingsResultInvalid); + printf("crypto/x509: kSecTrustSettingsResultTrustRoot = %d\n", kSecTrustSettingsResultTrustRoot); + printf("crypto/x509: kSecTrustSettingsResultTrustAsRoot = %d\n", kSecTrustSettingsResultTrustAsRoot); + printf("crypto/x509: kSecTrustSettingsResultDeny = %d\n", kSecTrustSettingsResultDeny); + printf("crypto/x509: kSecTrustSettingsResultUnspecified = %d\n", kSecTrustSettingsResultUnspecified); + } + + // Get certificates from all domains, not just System, this lets + // the user add CAs to their "login" keychain, and Admins to add + // to the "System" keychain + SecTrustSettingsDomain domains[] = { kSecTrustSettingsDomainSystem, + kSecTrustSettingsDomainAdmin, + kSecTrustSettingsDomainUser }; + + int numDomains = sizeof(domains)/sizeof(SecTrustSettingsDomain); + if (pemRoots == NULL) { + return -1; + } + + CFMutableDataRef combinedData = CFDataCreateMutable(kCFAllocatorDefault, 0); + CFMutableDataRef combinedUntrustedData = CFDataCreateMutable(kCFAllocatorDefault, 0); + for (i = 0; i < numDomains; i++) { + int j; + CFArrayRef certs = NULL; + OSStatus err = SecTrustSettingsCopyCertificates(domains[i], &certs); + if (err != noErr) { + continue; + } + + CFIndex numCerts = CFArrayGetCount(certs); + for (j = 0; j < numCerts; j++) { + CFDataRef data = NULL; + CFArrayRef trustSettings = NULL; + SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs, j); + if (cert == NULL) { + continue; + } + + SInt32 result; + if (domains[i] == kSecTrustSettingsDomainSystem) { + // Certs found in the system domain are always trusted. If the user + // configures "Never Trust" on such a cert, it will also be found in the + // admin or user domain, causing it to be added to untrustedPemRoots. The + // Go code will then clean this up. + result = kSecTrustSettingsResultTrustAsRoot; + } else { + result = sslTrustSettingsResult(cert); + if (debugDarwinRoots) { + CFErrorRef errRef = NULL; + CFStringRef summary = SecCertificateCopyShortDescription(NULL, cert, &errRef); + if (errRef != NULL) { + printf("crypto/x509: SecCertificateCopyShortDescription failed\n"); + CFRelease(errRef); + continue; + } + + CFIndex length = CFStringGetLength(summary); + CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; + char *buffer = malloc(maxSize); + if (CFStringGetCString(summary, buffer, maxSize, kCFStringEncodingUTF8)) { + printf("crypto/x509: %s returned %d\n", buffer, result); + } + free(buffer); + CFRelease(summary); + } + } + + CFMutableDataRef appendTo; + if (result == kSecTrustSettingsResultTrustRoot) { + // "can only be applied to root (self-signed) certificates", so + // make sure Subject and Issuer Name match. + CFErrorRef errRef = NULL; + CFDataRef subjectName = SecCertificateCopyNormalizedSubjectContent(cert, &errRef); + if (errRef != NULL) { + CFRelease(errRef); + continue; + } + CFDataRef issuerName = SecCertificateCopyNormalizedIssuerContent(cert, &errRef); + if (errRef != NULL) { + CFRelease(subjectName); + CFRelease(errRef); + continue; + } + Boolean equal = CFEqual(subjectName, issuerName); + CFRelease(subjectName); + CFRelease(issuerName); + if (!equal) { + continue; + } + + appendTo = combinedData; + } else if (result == kSecTrustSettingsResultTrustAsRoot) { + // In theory "can only be applied to non-root certificates", but ignore + // this for now, also because it's the state we assume for the system domain. + appendTo = combinedData; + } else if (result == kSecTrustSettingsResultDeny) { + appendTo = combinedUntrustedData; + } else if (result == kSecTrustSettingsResultUnspecified) { + continue; + } else { + continue; + } + + err = SecItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data); + if (err != noErr) { + continue; + } + if (data != NULL) { + CFDataAppendBytes(appendTo, CFDataGetBytePtr(data), CFDataGetLength(data)); + CFRelease(data); + } + } + CFRelease(certs); + } + *pemRoots = combinedData; + *untrustedPemRoots = combinedUntrustedData; + return 0; +} +*/ +import "C" +import ( + "crypto/x509" + "errors" + "unsafe" +) + +func loadSystemRoots() (*x509.CertPool, error) { + roots := x509.NewCertPool() + + var data C.CFDataRef = 0 + var untrustedData C.CFDataRef = 0 + err := C._FetchPEMRoots(&data, &untrustedData, C.bool(debugDarwinRoots)) + if err == -1 { + // TODO: better error message + return nil, errors.New("crypto/x509: failed to load darwin system roots with cgo") + } + + defer C.CFRelease(C.CFTypeRef(data)) + buf := C.GoBytes(unsafe.Pointer(C.CFDataGetBytePtr(data)), C.int(C.CFDataGetLength(data))) + roots.AppendCertsFromPEM(buf) + if untrustedData == 0 { + return roots, nil + } + defer C.CFRelease(C.CFTypeRef(untrustedData)) + buf = C.GoBytes(unsafe.Pointer(C.CFDataGetBytePtr(untrustedData)), C.int(C.CFDataGetLength(untrustedData))) + untrustedRoots := x509.NewCertPool() + untrustedRoots.AppendCertsFromPEM(buf) + + trustedRoots := x509.NewCertPool() + for _, c := range (*CertPool)(unsafe.Pointer(roots)).certs { + if !(*CertPool)(unsafe.Pointer(untrustedRoots)).contains(c) { + trustedRoots.AddCert(c) + } + } + return trustedRoots, nil +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_darwin.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_darwin.go new file mode 100644 index 0000000..b5bf0f7 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_darwin.go @@ -0,0 +1,174 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "crypto/x509" + "encoding/pem" + "fmt" + "io/ioutil" + "os" + "os/exec" + "os/user" + "path/filepath" + "sync" +) + +var debugDarwinRoots = true + +// This code is only used when compiling without cgo. +// It is here, instead of root_nocgo_darwin.go, so that tests can check it +// even if the tests are run with cgo enabled. +// The linker will not include these unused functions in binaries built with cgo enabled. + +// execSecurityRoots finds the macOS list of trusted root certificates +// using only command-line tools. This is our fallback path when cgo isn't available. +// +// The strategy is as follows: +// +// 1. Run "security find-certificate" to dump the list of system root +// CAs in PEM format. +// +// 2. For each dumped cert, conditionally verify it with "security +// verify-cert" if that cert was not in the SystemRootCertificates +// keychain, which can't have custom trust policies. +// +// We need to run "verify-cert" for all certificates not in SystemRootCertificates +// because there might be certificates in the keychains without a corresponding +// trust entry, in which case the logic is complicated (see root_cgo_darwin.go). +// +// TODO: actually parse the "trust-settings-export" output and apply the full +// logic. See Issue 26830. +func execSecurityRoots() (*x509.CertPool, error) { + keychains := []string{"/Library/Keychains/System.keychain"} + + // Note that this results in trusting roots from $HOME/... (the environment + // variable), which might not be expected. + u, err := user.Current() + if err != nil { + if debugDarwinRoots { + fmt.Printf("crypto/x509: get current user: %v\n", err) + } + } else { + keychains = append(keychains, + filepath.Join(u.HomeDir, "/Library/Keychains/login.keychain"), + + // Fresh installs of Sierra use a slightly different path for the login keychain + filepath.Join(u.HomeDir, "/Library/Keychains/login.keychain-db"), + ) + } + + var ( + mu sync.Mutex + roots = x509.NewCertPool() + numVerified int // number of execs of 'security verify-cert', for debug stats + wg sync.WaitGroup + verifyCh = make(chan *x509.Certificate) + ) + + // Using 4 goroutines to pipe into verify-cert seems to be + // about the best we can do. The verify-cert binary seems to + // just RPC to another server with coarse locking anyway, so + // running 16 at a time for instance doesn't help at all. + for i := 0; i < 4; i++ { + wg.Add(1) + go func() { + defer wg.Done() + for cert := range verifyCh { + valid := verifyCertWithSystem(cert) + + mu.Lock() + numVerified++ + if valid { + roots.AddCert(cert) + } + mu.Unlock() + } + }() + } + err = forEachCertInKeychains(keychains, func(cert *x509.Certificate) { + verifyCh <- cert + }) + if err != nil { + return nil, err + } + close(verifyCh) + wg.Wait() + + if debugDarwinRoots { + fmt.Printf("crypto/x509: ran security verify-cert %d times\n", numVerified) + } + + err = forEachCertInKeychains([]string{ + "/System/Library/Keychains/SystemRootCertificates.keychain", + }, roots.AddCert) + if err != nil { + return nil, err + } + + return roots, nil +} + +func forEachCertInKeychains(paths []string, f func(*x509.Certificate)) error { + args := append([]string{"find-certificate", "-a", "-p"}, paths...) + cmd := exec.Command("/usr/bin/security", args...) + data, err := cmd.Output() + if err != nil { + return err + } + for len(data) > 0 { + var block *pem.Block + block, data = pem.Decode(data) + if block == nil { + break + } + if block.Type != "CERTIFICATE" || len(block.Headers) != 0 { + continue + } + cert, err := x509.ParseCertificate(block.Bytes) + if err != nil { + continue + } + f(cert) + } + return nil +} + +func verifyCertWithSystem(cert *x509.Certificate) bool { + data := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE", Bytes: cert.Raw, + }) + + f, err := ioutil.TempFile("", "cert") + if err != nil { + fmt.Fprintf(os.Stderr, "can't create temporary file for cert: %v", err) + return false + } + defer os.Remove(f.Name()) + if _, err := f.Write(data); err != nil { + fmt.Fprintf(os.Stderr, "can't write temporary file for cert: %v", err) + return false + } + if err := f.Close(); err != nil { + fmt.Fprintf(os.Stderr, "can't write temporary file for cert: %v", err) + return false + } + cmd := exec.Command("/usr/bin/security", "verify-cert", "-p", "ssl", "-c", f.Name(), "-l", "-L") + var stderr bytes.Buffer + if debugDarwinRoots { + cmd.Stderr = &stderr + } + if err := cmd.Run(); err != nil { + if debugDarwinRoots { + fmt.Printf("crypto/x509: verify-cert rejected %s: %q\n", cert.Subject, bytes.TrimSpace(stderr.Bytes())) + } + return false + } + if debugDarwinRoots { + fmt.Printf("crypto/x509: verify-cert approved %s\n", cert.Subject) + } + return true +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_nocgo_darwin.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_nocgo_darwin.go new file mode 100644 index 0000000..cdf44d4 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/macos-roots-test/root_nocgo_darwin.go @@ -0,0 +1,17 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cgo +// +build !cgo + +package main + +import ( + "crypto/x509" + "errors" +) + +func loadSystemRoots() (*x509.CertPool, error) { + return nil, errors.New("can't load system roots: cgo not enabled") +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/modgraphviz/main.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/modgraphviz/main.go new file mode 100644 index 0000000..a0351dc --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/modgraphviz/main.go @@ -0,0 +1,166 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Modgraphviz converts “go mod graph” output into Graphviz's DOT language, +// for use with Graphviz visualization and analysis tools like dot, dotty, and sccmap. +// +// Usage: +// +// go mod graph | modgraphviz > graph.dot +// go mod graph | modgraphviz | dot -Tpng -o graph.png +// +// Modgraphviz takes no options or arguments; it reads a graph in the format +// generated by “go mod graph” on standard input and writes DOT language +// on standard output. +// +// For each module, the node representing the greatest version (i.e., the +// version chosen by Go's minimal version selection algorithm) is colored green. +// Other nodes, which aren't in the final build list, are colored grey. +// +// See http://www.graphviz.org/doc/info/lang.html for details of the DOT language +// and http://www.graphviz.org/about/ for Graphviz itself. +// +// See also golang.org/x/tools/cmd/digraph for general queries and analysis +// of “go mod graph” output. +package main + +import ( + "bufio" + "bytes" + "flag" + "fmt" + "io" + "log" + "os" + "sort" + "strings" + + "golang.org/x/mod/semver" +) + +func usage() { + fmt.Fprintf(os.Stderr, `Usage: go mod graph | modgraphviz | dot -Tpng -o graph.png + +For each module, the node representing the greatest version (i.e., the +version chosen by Go's minimal version selection algorithm) is colored green. +Other nodes, which aren't in the final build list, are colored grey. +`) + os.Exit(2) +} + +func main() { + log.SetFlags(0) + log.SetPrefix("modgraphviz: ") + + flag.Usage = usage + flag.Parse() + if flag.NArg() != 0 { + usage() + } + + if err := modgraphviz(os.Stdin, os.Stdout); err != nil { + log.Fatal(err) + } +} + +func modgraphviz(in io.Reader, out io.Writer) error { + graph, err := convert(in) + if err != nil { + return err + } + + fmt.Fprintf(out, "digraph gomodgraph {\n") + fmt.Fprintf(out, "\tnode [ shape=rectangle fontsize=12 ]\n") + out.Write(graph.edgesAsDOT()) + for _, n := range graph.mvsPicked { + fmt.Fprintf(out, "\t%q [style = filled, fillcolor = green]\n", n) + } + for _, n := range graph.mvsUnpicked { + fmt.Fprintf(out, "\t%q [style = filled, fillcolor = gray]\n", n) + } + fmt.Fprintf(out, "}\n") + + return nil +} + +type edge struct{ from, to string } +type graph struct { + edges []edge + mvsPicked []string + mvsUnpicked []string +} + +// convert reads “go mod graph” output from r and returns a graph, recording +// MVS picked and unpicked nodes along the way. +func convert(r io.Reader) (*graph, error) { + scanner := bufio.NewScanner(r) + var g graph + seen := map[string]bool{} + mvsPicked := map[string]string{} // module name -> module version + + for scanner.Scan() { + l := scanner.Text() + if l == "" { + continue + } + parts := strings.Fields(l) + if len(parts) != 2 { + return nil, fmt.Errorf("expected 2 words in line, but got %d: %s", len(parts), l) + } + from := parts[0] + to := parts[1] + g.edges = append(g.edges, edge{from: from, to: to}) + + for _, node := range []string{from, to} { + if _, ok := seen[node]; ok { + // Skip over nodes we've already seen. + continue + } + seen[node] = true + + var m, v string + if i := strings.IndexByte(node, '@'); i >= 0 { + m, v = node[:i], node[i+1:] + } else { + // Root node doesn't have a version. + continue + } + + if maxV, ok := mvsPicked[m]; ok { + if semver.Compare(maxV, v) < 0 { + // This version is higher - replace it and consign the old + // max to the unpicked list. + g.mvsUnpicked = append(g.mvsUnpicked, m+"@"+maxV) + mvsPicked[m] = v + } else { + // Other version is higher - stick this version in the + // unpicked list. + g.mvsUnpicked = append(g.mvsUnpicked, node) + } + } else { + mvsPicked[m] = v + } + } + } + if err := scanner.Err(); err != nil { + return nil, err + } + + for m, v := range mvsPicked { + g.mvsPicked = append(g.mvsPicked, m+"@"+v) + } + + // Make this function deterministic. + sort.Strings(g.mvsPicked) + return &g, nil +} + +// edgesAsDOT returns the edges in DOT notation. +func (g *graph) edgesAsDOT() []byte { + var buf bytes.Buffer + for _, e := range g.edges { + fmt.Fprintf(&buf, "\t%q -> %q\n", e.from, e.to) + } + return buf.Bytes() +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/modgraphviz/main_test.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/modgraphviz/main_test.go new file mode 100644 index 0000000..bec88cf --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/modgraphviz/main_test.go @@ -0,0 +1,116 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "fmt" + "reflect" + "testing" +) + +func TestRun(t *testing.T) { + out := &bytes.Buffer{} + in := bytes.NewBuffer([]byte(` +test.com/A@v1.0.0 test.com/B@v1.2.3 +test.com/B@v1.0.0 test.com/C@v4.5.6 +`)) + if err := modgraphviz(in, out); err != nil { + t.Fatal(err) + } + + gotGraph := string(out.Bytes()) + wantGraph := `digraph gomodgraph { + node [ shape=rectangle fontsize=12 ] + "test.com/A@v1.0.0" -> "test.com/B@v1.2.3" + "test.com/B@v1.0.0" -> "test.com/C@v4.5.6" + "test.com/A@v1.0.0" [style = filled, fillcolor = green] + "test.com/B@v1.2.3" [style = filled, fillcolor = green] + "test.com/C@v4.5.6" [style = filled, fillcolor = green] + "test.com/B@v1.0.0" [style = filled, fillcolor = gray] +} +` + if gotGraph != wantGraph { + t.Fatalf("\ngot: %s\nwant: %s", gotGraph, wantGraph) + } +} + +func TestMVSPicking(t *testing.T) { + for _, tc := range []struct { + name string + in []string + wantPicked []string + wantUnpicked []string + }{ + { + name: "single node", + in: []string{"foo@v0.0.1"}, + wantPicked: []string{"foo@v0.0.1"}, + wantUnpicked: nil, + }, + { + name: "duplicate same node", + in: []string{"foo@v0.0.1", "foo@v0.0.1"}, + wantPicked: []string{"foo@v0.0.1"}, + wantUnpicked: nil, + }, + { + name: "multiple semver - same major", + in: []string{"foo@v1.0.0", "foo@v1.3.7", "foo@v1.2.0", "foo@v1.0.1"}, + wantPicked: []string{"foo@v1.3.7"}, + wantUnpicked: []string{"foo@v1.0.0", "foo@v1.2.0", "foo@v1.0.1"}, + }, + { + name: "multiple semver - multiple major", + in: []string{"foo@v1.0.0", "foo@v1.3.7", "foo/v2@v2.2.0", "foo/v2@v2.0.1", "foo@v1.1.1"}, + wantPicked: []string{"foo/v2@v2.2.0", "foo@v1.3.7"}, + wantUnpicked: []string{"foo@v1.0.0", "foo/v2@v2.0.1", "foo@v1.1.1"}, + }, + { + name: "semver and pseudo version", + in: []string{"foo@v1.0.0", "foo@v1.3.7", "foo/v2@v2.2.0", "foo/v2@v2.0.1", "foo@v1.1.1", "foo@v0.0.0-20190311183353-d8887717615a"}, + wantPicked: []string{"foo/v2@v2.2.0", "foo@v1.3.7"}, + wantUnpicked: []string{"foo@v1.0.0", "foo/v2@v2.0.1", "foo@v1.1.1", "foo@v0.0.0-20190311183353-d8887717615a"}, + }, + { + name: "multiple pseudo version", + in: []string{ + "foo@v0.0.0-20190311183353-d8887717615a", + "foo@v0.0.0-20190227222117-0694c2d4d067", + "foo@v0.0.0-20190312151545-0bb0c0a6e846", + }, + wantPicked: []string{"foo@v0.0.0-20190312151545-0bb0c0a6e846"}, + wantUnpicked: []string{ + "foo@v0.0.0-20190227222117-0694c2d4d067", + "foo@v0.0.0-20190311183353-d8887717615a", + }, + }, + { + name: "semver and suffix", + in: []string{"foo@v1.0.0", "foo@v1.3.8-rc1", "foo@v1.3.7"}, + wantPicked: []string{"foo@v1.3.8-rc1"}, + wantUnpicked: []string{"foo@v1.0.0", "foo@v1.3.7"}, + }, + } { + t.Run(tc.name, func(t *testing.T) { + buf := bytes.Buffer{} + for _, node := range tc.in { + fmt.Fprintf(&buf, "A %s\n", node) + } + + g, err := convert(&buf) + if err != nil { + t.Fatal(err) + } + + if !reflect.DeepEqual(g.mvsPicked, tc.wantPicked) { + t.Fatalf("picked: got %v, want %v", g.mvsPicked, tc.wantPicked) + } + if !reflect.DeepEqual(g.mvsUnpicked, tc.wantUnpicked) { + t.Fatalf("unpicked: got %v, want %v", g.mvsUnpicked, tc.wantUnpicked) + } + }) + } +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/txtar/txtar.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/txtar/txtar.go new file mode 100644 index 0000000..9beb163 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/txtar/txtar.go @@ -0,0 +1,196 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The txtar command writes or extracts a text-based file archive in the format +// provided by the golang.org/x/tools/txtar package. +// +// The default behavior is to read a comment from stdin and write the archive +// file containing the recursive contents of the named files and directories, +// including hidden files, to stdout. Any non-flag arguments to the command name +// the files and/or directories to include, with the contents of directories +// included recursively. An empty argument list is equivalent to ".". +// +// The --extract (or -x) flag instructs txtar to instead read the archive file +// from stdin and extract all of its files to corresponding locations relative +// to the current, writing the archive's comment to stdout. +// +// Archive files are by default extracted only to the current directory or its +// subdirectories. To allow extracting outside the current directory, use the +// --unsafe flag. +// +// Shell variables in paths are expanded (using os.Expand) if the corresponding +// variable is set in the process environment. When writing an archive, the +// variables (before expansion) are preserved in the archived paths. +// +// Example usage: +// +// txtar *.go <README >testdata/example.txt +// +// txtar --extract <playground_example.txt >main.go +package main + +import ( + "bytes" + "flag" + "fmt" + "io/ioutil" + "os" + "path" + "path/filepath" + "regexp" + "strings" + "time" + + "golang.org/x/tools/txtar" +) + +var ( + extractFlag = flag.Bool("extract", false, "if true, extract files from the archive instead of writing to it") + unsafeFlag = flag.Bool("unsafe", false, "allow extraction of files outside the current directory") +) + +func init() { + flag.BoolVar(extractFlag, "x", *extractFlag, "short alias for --extract") +} + +func main() { + flag.Parse() + + var err error + if *extractFlag { + if len(flag.Args()) > 0 { + fmt.Fprintln(os.Stderr, "Usage: txtar --extract <archive.txt") + os.Exit(2) + } + err = extract() + } else { + paths := flag.Args() + if len(paths) == 0 { + paths = []string{"."} + } + err = archive(paths) + } + + if err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } +} + +func extract() (err error) { + b, err := ioutil.ReadAll(os.Stdin) + if err != nil { + return err + } + + ar := txtar.Parse(b) + + if !*unsafeFlag { + // Check that no files are extracted outside the current directory + wd, err := os.Getwd() + if err != nil { + return err + } + // Add trailing separator to terminate wd. + // This prevents extracting to outside paths which prefix wd, + // e.g. extracting to /home/foobar when wd is /home/foo + if !strings.HasSuffix(wd, string(filepath.Separator)) { + wd += string(filepath.Separator) + } + + for _, f := range ar.Files { + fileName := filepath.Clean(expand(f.Name)) + + if strings.HasPrefix(fileName, "..") || + (filepath.IsAbs(fileName) && !strings.HasPrefix(fileName, wd)) { + return fmt.Errorf("file path '%s' is outside the current directory", f.Name) + } + } + } + + for _, f := range ar.Files { + fileName := filepath.FromSlash(path.Clean(expand(f.Name))) + if err := os.MkdirAll(filepath.Dir(fileName), 0777); err != nil { + return err + } + if err := ioutil.WriteFile(fileName, f.Data, 0666); err != nil { + return err + } + } + + if len(ar.Comment) > 0 { + os.Stdout.Write(ar.Comment) + } + return nil +} + +func archive(paths []string) (err error) { + txtarHeader := regexp.MustCompile(`(?m)^-- .* --$`) + + ar := new(txtar.Archive) + for _, p := range paths { + root := filepath.Clean(expand(p)) + prefix := root + string(filepath.Separator) + err := filepath.Walk(root, func(fileName string, info os.FileInfo, err error) error { + if err != nil || info.IsDir() { + return err + } + + suffix := "" + if fileName != root { + suffix = strings.TrimPrefix(fileName, prefix) + } + name := filepath.ToSlash(filepath.Join(p, suffix)) + + data, err := ioutil.ReadFile(fileName) + if err != nil { + return err + } + if txtarHeader.Match(data) { + return fmt.Errorf("cannot archive %s: file contains a txtar header", name) + } + + ar.Files = append(ar.Files, txtar.File{Name: name, Data: data}) + return nil + }) + if err != nil { + return err + } + } + + // After we have read all of the source files, read the comment from stdin. + // + // Wait until the read has been blocked for a while before prompting the user + // to enter it: if they are piping the comment in from some other file, the + // read should complete very quickly and there is no need for a prompt. + // (200ms is typically long enough to read a reasonable comment from the local + // machine, but short enough that humans don't notice it.) + // + // Don't prompt until we have successfully read the other files: + // if we encountered an error, we don't need to ask for a comment. + timer := time.AfterFunc(200*time.Millisecond, func() { + fmt.Fprintln(os.Stderr, "Enter comment:") + }) + comment, err := ioutil.ReadAll(os.Stdin) + timer.Stop() + if err != nil { + return fmt.Errorf("reading comment from %s: %v", os.Stdin.Name(), err) + } + ar.Comment = bytes.TrimSpace(comment) + + _, err = os.Stdout.Write(txtar.Format(ar)) + return err +} + +// expand is like os.ExpandEnv, but preserves unescaped variables (instead +// of escaping them to the empty string) if the variable is not set. +func expand(p string) string { + return os.Expand(p, func(key string) string { + v, ok := os.LookupEnv(key) + if !ok { + return "$" + key + } + return v + }) +} diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/txtar/txtar_test.go b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/txtar/txtar_test.go new file mode 100644 index 0000000..ea9f2bf --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/cmd/txtar/txtar_test.go @@ -0,0 +1,178 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main_test + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "sync" + "testing" +) + +const comment = "This is a txtar archive.\n" + +const testdata = `This is a txtar archive. +-- one.txt -- +one +-- dir/two.txt -- +two +-- $SPECIAL_LOCATION/three.txt -- +three +` + +func TestMain(m *testing.M) { + code := m.Run() + txtarBin.once.Do(func() {}) + if txtarBin.name != "" { + os.Remove(txtarBin.name) + } + os.Exit(code) +} + +func TestRoundTrip(t *testing.T) { + os.Setenv("SPECIAL_LOCATION", "special") + defer os.Unsetenv("SPECIAL_LOCATION") + + // Expand the testdata archive into a temporary directory. + parentDir, err := ioutil.TempDir("", "txtar") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(parentDir) + dir := filepath.Join(parentDir, "dir") + if err := os.Mkdir(dir, 0755); err != nil { + t.Fatal(err) + } + if out, err := txtar(t, dir, testdata, "--extract"); err != nil { + t.Fatal(err) + } else if out != comment { + t.Fatalf("txtar --extract: stdout:\n%s\nwant:\n%s", out, comment) + } + + // Now, re-archive its contents explicitly and ensure that the result matches + // the original. + args := []string{"one.txt", "dir", "$SPECIAL_LOCATION"} + if out, err := txtar(t, dir, comment, args...); err != nil { + t.Fatal(err) + } else if out != testdata { + t.Fatalf("txtar %s: archive:\n%s\n\nwant:\n%s", strings.Join(args, " "), out, testdata) + } +} + +func TestUnsafePaths(t *testing.T) { + // Set up temporary directories for test archives. + parentDir, err := ioutil.TempDir("", "txtar") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(parentDir) + dir := filepath.Join(parentDir, "dir") + if err := os.Mkdir(dir, 0755); err != nil { + t.Fatal(err) + } + + // Test --unsafe option for both absolute and relative paths + testcases := []struct{ name, path string }{ + {"Absolute", filepath.Join(parentDir, "dirSpecial")}, + {"Relative", "../special"}, + } + + for _, tc := range testcases { + t.Run(tc.name, func(t *testing.T) { + // Set SPECIAL_LOCATION outside the current directory + t.Setenv("SPECIAL_LOCATION", tc.path) + + // Expand the testdata archive into a temporary directory. + + // Should fail without the --unsafe flag + if _, err := txtar(t, dir, testdata, "--extract"); err == nil { + t.Fatalf("txtar --extract: extracts to unsafe paths") + } + + // Should allow paths outside the current dir with the --unsafe flags + out, err := txtar(t, dir, testdata, "--extract", "--unsafe") + if err != nil { + t.Fatal(err) + } + if out != comment { + t.Fatalf("txtar --extract --unsafe: stdout:\n%s\nwant:\n%s", out, comment) + } + + // Now, re-archive its contents explicitly and ensure that the result matches + // the original. + args := []string{"one.txt", "dir", "$SPECIAL_LOCATION"} + out, err = txtar(t, dir, comment, args...) + if err != nil { + t.Fatal(err) + } + if out != testdata { + t.Fatalf("txtar %s: archive:\n%s\n\nwant:\n%s", strings.Join(args, " "), out, testdata) + } + }) + } +} + +// txtar runs the txtar command in the given directory with the given input and +// arguments. +func txtar(t *testing.T, dir, input string, args ...string) (string, error) { + t.Helper() + cmd := exec.Command(txtarName(t), args...) + cmd.Dir = dir + cmd.Env = append(os.Environ(), "PWD="+dir) + cmd.Stdin = strings.NewReader(input) + stderr := new(strings.Builder) + cmd.Stderr = stderr + out, err := cmd.Output() + if err != nil { + return "", fmt.Errorf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, stderr) + } + if stderr.String() != "" { + t.Logf("OK: %s\n%s", strings.Join(cmd.Args, " "), stderr) + } + return string(out), nil +} + +var txtarBin struct { + once sync.Once + name string + err error +} + +// txtarName returns the name of the txtar executable, building it if needed. +func txtarName(t *testing.T) string { + t.Helper() + if _, err := exec.LookPath("go"); err != nil { + t.Skipf("cannot build txtar binary: %v", err) + } + + txtarBin.once.Do(func() { + exe, err := ioutil.TempFile("", "txtar-*.exe") + if err != nil { + txtarBin.err = err + return + } + exe.Close() + txtarBin.name = exe.Name() + + cmd := exec.Command("go", "build", "-o", txtarBin.name, ".") + out, err := cmd.CombinedOutput() + if err != nil { + txtarBin.err = fmt.Errorf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, out) + } + }) + + if txtarBin.err != nil { + if runtime.GOOS == "android" { + t.Skipf("skipping test after failing to build txtar binary: go_android_exec may have failed to copy needed dependencies (see https://golang.org/issue/37088)") + } + t.Fatal(txtarBin.err) + } + return txtarBin.name +} |