Preserve build errors and available failure evidence
This commit is contained in:
@@ -99,16 +99,17 @@ func FromCommittedSelection(ctx context.Context, selection Selection, version, c
|
||||
// working tree. The selected module must contain its own go.mod.
|
||||
func FromWorkingTree(ctx context.Context, repositoryDir, moduleDir, version string) (Identity, error) {
|
||||
selection, err := ResolveSelection(repositoryDir, moduleDir)
|
||||
identity := Identity{Selection: selection, Version: version}
|
||||
if err != nil {
|
||||
return Identity{}, err
|
||||
return identity, err
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return Identity{}, fmt.Errorf("resolve working-tree release identity: %w", err)
|
||||
return identity, fmt.Errorf("resolve working-tree release identity: %w", err)
|
||||
}
|
||||
declarationPath := filepath.Join(selection.ModuleDir, "go.mod")
|
||||
declaration, err := os.ReadFile(declarationPath)
|
||||
if err != nil {
|
||||
return Identity{}, fmt.Errorf("read selected module declaration %q: %w", declarationPath, err)
|
||||
return identity, fmt.Errorf("read selected module declaration %q: %w", declarationPath, err)
|
||||
}
|
||||
return Derive(selection, declaration, version)
|
||||
}
|
||||
@@ -116,25 +117,27 @@ func FromWorkingTree(ctx context.Context, repositoryDir, moduleDir, version stri
|
||||
// Derive applies Go module path-major rules and derives the standard full tag
|
||||
// and module-local release-note path from a declaration and selection.
|
||||
func Derive(selection Selection, declaration []byte, version string) (Identity, error) {
|
||||
identity := Identity{Selection: selection, Version: version}
|
||||
if selection.RepositoryDir == "" || selection.ModuleDir == "" || selection.ModuleSubdir == "" {
|
||||
return Identity{}, fmt.Errorf("incomplete module selection")
|
||||
return identity, fmt.Errorf("incomplete module selection")
|
||||
}
|
||||
modulePath := modfile.ModulePath(declaration)
|
||||
if modulePath == "" {
|
||||
return Identity{}, fmt.Errorf("selected module declaration has no valid module directive")
|
||||
return identity, fmt.Errorf("selected module declaration has no valid module directive")
|
||||
}
|
||||
identity.ModulePath = modulePath
|
||||
if err := module.CheckPath(modulePath); err != nil {
|
||||
return Identity{}, fmt.Errorf("invalid module path %q: %w", modulePath, err)
|
||||
return identity, fmt.Errorf("invalid module path %q: %w", modulePath, err)
|
||||
}
|
||||
_, pathMajor, ok := module.SplitPathVersion(modulePath)
|
||||
if !ok {
|
||||
return Identity{}, fmt.Errorf("module path %q has an invalid major-version suffix", modulePath)
|
||||
return identity, fmt.Errorf("module path %q has an invalid major-version suffix", modulePath)
|
||||
}
|
||||
if !versioncontract.ValidStableVersion(version) {
|
||||
return Identity{}, fmt.Errorf("invalid stable release version %q", version)
|
||||
return identity, fmt.Errorf("invalid stable release version %q", version)
|
||||
}
|
||||
if err := module.CheckPathMajor(version, pathMajor); err != nil {
|
||||
return Identity{}, fmt.Errorf("version %q is incompatible with module path %q: %w", version, modulePath, err)
|
||||
return identity, fmt.Errorf("version %q is incompatible with module path %q: %w", version, modulePath, err)
|
||||
}
|
||||
|
||||
tagPrefix := selection.ModuleSubdir
|
||||
|
||||
Reference in New Issue
Block a user