Normalize source and publication selection

This commit is contained in:
2026-12-05 20:47:58 +00:00
parent 8f3b59b5f2
commit b0fce88a51
20 changed files with 677 additions and 50 deletions

View File

@@ -33,6 +33,7 @@ type Candidate struct {
type Request struct {
RepositoryDir string
ModuleDir string
Source *releaseidentity.SourceSpec
Product string
Version string
Validation validation.Settings
@@ -91,7 +92,7 @@ func Capture(ctx context.Context, request Request) (Candidate, error) {
return captured, fmt.Errorf("release candidate worktree and index must be clean:\n%s", state.status)
}
identity, err := releaseidentity.FromCommitted(ctx, repositoryDir, request.ModuleDir, request.Version, state.commit)
identity, err := releaseidentity.FromCommittedSource(ctx, repositoryDir, request.ModuleDir, request.Version, state.commit, request.Source)
captured.ModuleDir = identity.ModuleDir
captured.ModulePath = identity.ModulePath
captured.Tag = identity.Tag

View File

@@ -14,6 +14,7 @@ import (
"testing"
"go.maximumdirect.net/releasekit/internal/gotool"
"go.maximumdirect.net/releasekit/internal/releaseidentity"
"go.maximumdirect.net/releasekit/internal/validation"
)
@@ -47,6 +48,27 @@ func TestValidStableVersion(t *testing.T) {
}
}
func TestCaptureUsesExplicitModuleSelection(t *testing.T) {
repository := newRepository(t, "# Example Product v1.2.3\n\nRoot release.\n")
moduleDir := "components/tool"
writeTestFile(t, repository, moduleDir+"/go.mod", "module example.com/tool\n")
writeTestFile(t, repository, moduleDir+"/docs/releases/v1.2.3.md", "# Example Product v1.2.3\n\nNested release.\n")
gitRun(t, repository, "add", moduleDir)
gitRun(t, repository, "commit", "-m", "add nested module")
captured, err := Capture(context.Background(), Request{
RepositoryDir: repository,
Source: &releaseidentity.SourceSpec{Dir: moduleDir, GoEnabled: true, Publication: "go-module"},
Product: "Example Product", Version: testVersion,
})
if err != nil {
t.Fatal(err)
}
if captured.ModuleDir != filepath.Join(repository, moduleDir) || captured.ModulePath != "example.com/tool" || captured.Tag != moduleDir+"/"+testVersion {
t.Fatalf("captured candidate = %+v", captured)
}
}
func TestCheckCapturesCandidateAndCallsAdditionalChecksOnce(t *testing.T) {
repository := newRepository(t, "# Example Product v1.2.3\n\nRelease note.\n")
writeTestFile(t, repository, "guide.md", "# Guide\n[section](#guide)\n")

View File

@@ -33,6 +33,7 @@ const (
type Request struct {
RepositoryDir string
ModuleDir string
Source *releaseidentity.SourceSpec
Product string
Version string
ExpectedTag string
@@ -85,7 +86,7 @@ func deliver(ctx context.Context, request Request, remove func(string) error) (r
return result, err
}
result.CandidateCommit = commit
identity, err := releaseidentity.FromCommitted(ctx, repositoryDir, request.ModuleDir, request.Version, commit)
identity, err := releaseidentity.FromCommittedSource(ctx, repositoryDir, request.ModuleDir, request.Version, commit, request.Source)
result.ModuleDir = identity.ModuleDir
result.ModulePath = identity.ModulePath
result.Tag = identity.Tag

View File

@@ -11,6 +11,7 @@ import (
"go.maximumdirect.net/releasekit/internal/candidate"
"go.maximumdirect.net/releasekit/internal/git"
"go.maximumdirect.net/releasekit/internal/gotool"
"go.maximumdirect.net/releasekit/internal/releaseidentity"
"go.maximumdirect.net/releasekit/internal/validation"
)
@@ -44,6 +45,7 @@ var ErrUnexpectedPushURL = errors.New("unexpected publication push URL")
type Request struct {
RepositoryDir string
ModuleDir string
Source *releaseidentity.SourceSpec
Product string
Version string
Remote string
@@ -101,6 +103,7 @@ func Publish(ctx context.Context, request Request) (result Result, resultErr err
checks := candidate.Request{
RepositoryDir: request.RepositoryDir,
ModuleDir: request.ModuleDir,
Source: request.Source,
Product: request.Product,
Version: request.Version,
Validation: request.Validation,

View File

@@ -5,7 +5,6 @@ package releaseidentity
import (
"context"
"fmt"
"os"
"path"
"path/filepath"
"strings"
@@ -73,15 +72,14 @@ func ResolveSelection(repositoryDir, moduleDir string) (Selection, error) {
// FromCommitted derives identity from the selected module declaration at a
// captured commit. The selected module must contain its own go.mod.
func FromCommitted(ctx context.Context, repositoryDir, moduleDir, version, commit string) (Identity, error) {
resolver, err := committedPaths(repositoryDir, commit)
if err != nil {
return Identity{Version: version}, err
}
selection, err := selectCommittedDirectory(ctx, resolver, moduleDir)
if err != nil {
return Identity{Selection: selection, Version: version}, err
}
return fromCommittedSelection(ctx, selection, version, commit, resolver)
return FromCommittedSource(ctx, repositoryDir, moduleDir, version, commit, nil)
}
// FromCommittedSource resolves source selection and the declaration captured at
// commit before deriving the currently supported module publication identity.
func FromCommittedSource(ctx context.Context, repositoryDir, moduleDir, version, commit string, source *SourceSpec) (Identity, error) {
selection, err := LoadCommittedSource(ctx, repositoryDir, moduleDir, commit, source)
return deriveSelectedModule(selection, version, err)
}
// ResolveCommittedSelection resolves directory selection without reading the
@@ -126,46 +124,63 @@ func selectCommittedDirectory(ctx context.Context, resolver git.PathResolver, mo
return selection, nil
}
func fromCommittedSelection(ctx context.Context, selection Selection, version, commit string, resolver git.PathResolver) (Identity, error) {
identity := Identity{Selection: selection, Version: version}
func readCommittedDeclaration(ctx context.Context, selection Selection, commit string, resolver git.PathResolver) ([]byte, error) {
if err := ctx.Err(); err != nil {
return identity, fmt.Errorf("resolve committed release identity: %w", err)
return nil, fmt.Errorf("resolve committed release identity: %w", err)
}
declarationPath, err := resolver.ResolveDestination(ctx, "go.mod", moduleFilePath(selection.ModuleSubdir))
if err != nil {
return identity, fmt.Errorf("resolve selected module declaration at %s: %w", commit, err)
return nil, fmt.Errorf("resolve selected module declaration at %s: %w", commit, err)
}
if declarationPath.Kind != git.DestinationEntry {
return identity, fmt.Errorf("selected module declaration resolves to %s at %q", declarationPath.Kind, declarationPath.Path)
return nil, fmt.Errorf("selected module declaration resolves to %s at %q", declarationPath.Kind, declarationPath.Path)
}
entry, _, err := resolver.Lookup(ctx, declarationPath.Path)
if err != nil {
return identity, err
return nil, err
}
declaration, err := git.ReadBlob(ctx, selection.RepositoryDir, entry.ObjectID)
if err != nil {
return identity, fmt.Errorf("read selected module declaration at %s: %w", commit, err)
return nil, fmt.Errorf("read selected module declaration at %s: %w", commit, err)
}
return Derive(selection, declaration, version)
return declaration, nil
}
// FromWorkingTree derives identity from the selected module declaration in the
// 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}
return FromWorkingSource(ctx, repositoryDir, moduleDir, version, nil)
}
// FromWorkingSource resolves source selection and a working declaration before
// deriving the currently supported module publication identity.
func FromWorkingSource(ctx context.Context, repositoryDir, moduleDir, version string, source *SourceSpec) (Identity, error) {
selection, err := LoadWorkingSource(ctx, repositoryDir, moduleDir, source)
return deriveSelectedModule(selection, version, err)
}
func deriveSelectedModule(source ResolvedSource, version string, err error) (Identity, error) {
identity := Identity{Selection: source.Selection, ModulePath: source.ModulePath, Version: version}
if err != nil {
return identity, err
}
if err := ctx.Err(); err != nil {
return identity, fmt.Errorf("resolve working-tree release identity: %w", err)
if source.Publication != "go-module" {
return identity, fmt.Errorf("general source release identity is not yet supported")
}
declarationPath := filepath.Join(selection.ModuleDir, "go.mod")
declaration, err := os.ReadFile(declarationPath)
if source.VersionFormat != "semver" || source.VersionPrefix != "v" {
return identity, fmt.Errorf("Go module publication requires prefixed semantic versions and the module-derived tag")
}
identity, err = deriveModule(source.Selection, source.ModulePath, version)
if err != nil {
return identity, fmt.Errorf("read selected module declaration %q: %w", declarationPath, err)
return identity, err
}
return Derive(selection, declaration, version)
if source.TagPrefix != nil {
prefix := strings.TrimSuffix(strings.TrimSuffix(identity.Tag, version), "/")
if *source.TagPrefix != prefix {
return identity, fmt.Errorf("source tag prefix %q conflicts with Go module tag prefix %q", *source.TagPrefix, prefix)
}
}
return identity, nil
}
// Derive applies Go module path-major rules and derives the standard full tag
@@ -175,14 +190,16 @@ func Derive(selection Selection, declaration []byte, version string) (Identity,
if selection.RepositoryDir == "" || selection.ModuleDir == "" || selection.ModuleSubdir == "" {
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")
}
modulePath, err := modulePathFromDeclaration(declaration)
identity.ModulePath = modulePath
if err := module.CheckImportPath(modulePath); err != nil {
return identity, fmt.Errorf("invalid module path %q: %w", modulePath, err)
if err != nil {
return identity, err
}
return deriveModule(selection, modulePath, version)
}
func deriveModule(selection Selection, modulePath, version string) (Identity, error) {
identity := Identity{Selection: selection, ModulePath: modulePath, Version: version}
_, pathMajor, ok := module.SplitPathVersion(modulePath)
if !ok {
return identity, fmt.Errorf("module path %q has an invalid major-version suffix", modulePath)
@@ -212,6 +229,20 @@ func Derive(selection Selection, declaration []byte, version string) (Identity,
}, nil
}
func modulePathFromDeclaration(declaration []byte) (string, error) {
modulePath := modfile.ModulePath(declaration)
if modulePath == "" {
return "", fmt.Errorf("selected module declaration has no valid module directive")
}
if err := module.CheckImportPath(modulePath); err != nil {
return modulePath, fmt.Errorf("invalid module path %q: %w", modulePath, err)
}
if _, _, ok := module.SplitPathVersion(modulePath); !ok {
return modulePath, fmt.Errorf("module path %q has an invalid major-version suffix", modulePath)
}
return modulePath, nil
}
func moduleFilePath(moduleSubdir string) string {
if moduleSubdir == "." {
return "go.mod"

View File

@@ -0,0 +1,210 @@
package releaseidentity
import (
"context"
"fmt"
"os"
"path/filepath"
"go.maximumdirect.net/releasekit/internal/git"
)
// SourceSpec describes explicit source, Go, publication, and version choices.
// Nil SourceSpec selects the historical Go-module shorthand.
type SourceSpec struct {
Dir string
GoEnabled bool
Publication string
VersionFormat string
VersionPrefix *string
TagPrefix *string
}
// SourceSelection contains the normalized configuration, independent of the
// working or committed module declaration.
type SourceSelection struct {
Dir string
GoEnabled bool
Publication string
VersionFormat string
VersionPrefix string
TagPrefix *string
}
// ResolvedSource joins the configuration selection with its physical scope.
type ResolvedSource struct {
SourceSelection
Selection
ModulePath string
}
// ResolveWorkingSource resolves the selected working-tree directory without
// requiring a module declaration.
func ResolveWorkingSource(repositoryDir, moduleDir string, source *SourceSpec) (ResolvedSource, error) {
config, err := NormalizeSource(moduleDir, source)
if err != nil {
return ResolvedSource{}, err
}
directory, err := ResolveSelection(repositoryDir, sourceDirectory(moduleDir, source))
if err != nil {
return ResolvedSource{SourceSelection: config}, err
}
if source != nil && source.Dir != "" && moduleDir != "" {
module, err := ResolveSelection(repositoryDir, moduleDir)
if err != nil {
return ResolvedSource{SourceSelection: config, Selection: directory}, err
}
if module.ModuleDir != directory.ModuleDir {
return ResolvedSource{SourceSelection: config, Selection: directory}, selectionConflict(source.Dir, moduleDir)
}
}
info, err := os.Stat(directory.ModuleDir)
if err != nil {
return ResolvedSource{SourceSelection: config, Selection: directory}, fmt.Errorf("inspect source directory: %w", err)
}
if !info.IsDir() {
return ResolvedSource{SourceSelection: config, Selection: directory}, fmt.Errorf("selected source %q is not a directory", config.Dir)
}
config.Dir = directory.ModuleSubdir
return ResolvedSource{SourceSelection: config, Selection: directory}, nil
}
// ResolveCommittedSource resolves the selected directory in a captured commit
// without reading a module declaration or relying on the working tree.
func ResolveCommittedSource(ctx context.Context, repositoryDir, moduleDir, commit string, source *SourceSpec) (ResolvedSource, error) {
config, err := NormalizeSource(moduleDir, source)
if err != nil {
return ResolvedSource{}, err
}
resolver, err := committedPaths(repositoryDir, commit)
if err != nil {
return ResolvedSource{SourceSelection: config}, err
}
directory, err := resolveCommittedSourceDirectory(ctx, resolver, moduleDir, source)
if err == nil {
config.Dir = directory.ModuleSubdir
}
return ResolvedSource{SourceSelection: config, Selection: directory}, err
}
// LoadWorkingSource resolves the source scope and reads its module declaration
// only when Go capability is selected.
func LoadWorkingSource(ctx context.Context, repositoryDir, moduleDir string, source *SourceSpec) (ResolvedSource, error) {
if err := ctx.Err(); err != nil {
return ResolvedSource{}, err
}
resolved, err := ResolveWorkingSource(repositoryDir, moduleDir, source)
if err != nil || !resolved.GoEnabled {
return resolved, err
}
if err := ctx.Err(); err != nil {
return resolved, err
}
declarationPath := filepath.Join(resolved.ModuleDir, "go.mod")
declaration, err := os.ReadFile(declarationPath)
if err != nil {
return resolved, fmt.Errorf("read selected module declaration %q: %w", declarationPath, err)
}
resolved.ModulePath, err = modulePathFromDeclaration(declaration)
return resolved, err
}
// LoadCommittedSource reads the selected module declaration from the captured
// commit, without requiring that declaration in the working tree.
func LoadCommittedSource(ctx context.Context, repositoryDir, moduleDir, commit string, source *SourceSpec) (ResolvedSource, error) {
config, err := NormalizeSource(moduleDir, source)
if err != nil {
return ResolvedSource{}, err
}
resolver, err := committedPaths(repositoryDir, commit)
if err != nil {
return ResolvedSource{SourceSelection: config}, err
}
directory, err := resolveCommittedSourceDirectory(ctx, resolver, moduleDir, source)
resolved := ResolvedSource{SourceSelection: config, Selection: directory}
if err != nil {
return resolved, err
}
resolved.Dir = directory.ModuleSubdir
if !resolved.GoEnabled {
return resolved, nil
}
declaration, err := readCommittedDeclaration(ctx, directory, commit, resolver)
if err != nil {
return resolved, err
}
resolved.ModulePath, err = modulePathFromDeclaration(declaration)
return resolved, err
}
func resolveCommittedSourceDirectory(ctx context.Context, resolver git.PathResolver, moduleDir string, source *SourceSpec) (Selection, error) {
directory, err := selectCommittedDirectory(ctx, resolver, sourceDirectory(moduleDir, source))
if err != nil {
return directory, err
}
if source != nil && source.Dir != "" && moduleDir != "" {
module, err := selectCommittedDirectory(ctx, resolver, moduleDir)
if err != nil {
return directory, err
}
if module.ModuleSubdir != directory.ModuleSubdir {
return directory, selectionConflict(source.Dir, moduleDir)
}
}
return directory, nil
}
func selectionConflict(sourceDir, moduleDir string) error {
return fmt.Errorf("source.dir %q conflicts with module_dir %q", sourceDir, moduleDir)
}
func sourceDirectory(moduleDir string, source *SourceSpec) string {
if source != nil && source.Dir != "" {
return source.Dir
}
return moduleDir
}
// NormalizeSource applies explicit defaults and preserves the legacy shorthand.
func NormalizeSource(moduleDir string, source *SourceSpec) (SourceSelection, error) {
if source == nil {
source = &SourceSpec{GoEnabled: true, Publication: "go-module"}
}
dir := source.Dir
if dir == "" {
dir = moduleDir
}
if dir == "" {
dir = "."
}
if filepath.IsAbs(dir) {
return SourceSelection{}, fmt.Errorf("source directory must be repository-relative: %q", dir)
}
result := SourceSelection{Dir: filepath.ToSlash(filepath.Clean(dir)), GoEnabled: source.GoEnabled, Publication: source.Publication, VersionFormat: source.VersionFormat, TagPrefix: source.TagPrefix}
if result.Publication == "" {
result.Publication = "source"
}
if result.Publication != "source" && result.Publication != "go-module" {
return SourceSelection{}, fmt.Errorf("invalid publication mode %q", result.Publication)
}
if result.Publication == "go-module" && !result.GoEnabled {
return SourceSelection{}, fmt.Errorf("go-module publication requires Go capability")
}
if result.VersionFormat == "" {
result.VersionFormat = "semver"
}
switch result.VersionFormat {
case "semver":
result.VersionPrefix = "v"
case "date", "year-month":
default:
return SourceSelection{}, fmt.Errorf("invalid version format %q", result.VersionFormat)
}
if source.VersionPrefix != nil {
result.VersionPrefix = *source.VersionPrefix
}
if result.VersionPrefix != "" && result.VersionPrefix != "v" {
return SourceSelection{}, fmt.Errorf("version prefix must be \"v\" or empty")
}
return result, nil
}

View File

@@ -0,0 +1,141 @@
package releaseidentity
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
)
func TestNormalizeSource(t *testing.T) {
empty := ""
tests := []struct {
name string
module string
source *SourceSpec
want SourceSelection
invalid bool
}{
{name: "legacy", module: "nested", want: SourceSelection{Dir: "nested", GoEnabled: true, Publication: "go-module", VersionFormat: "semver", VersionPrefix: "v"}},
{name: "explicit root", source: &SourceSpec{}, want: SourceSelection{Dir: ".", Publication: "source", VersionFormat: "semver", VersionPrefix: "v"}},
{name: "Go application", module: "app", source: &SourceSpec{GoEnabled: true, VersionFormat: "date"}, want: SourceSelection{Dir: "app", GoEnabled: true, Publication: "source", VersionFormat: "date"}},
{name: "Go module", module: "app/.", source: &SourceSpec{Dir: "app", GoEnabled: true, Publication: "go-module", VersionPrefix: &empty}, want: SourceSelection{Dir: "app", GoEnabled: true, Publication: "go-module", VersionFormat: "semver"}},
{name: "missing Go", source: &SourceSpec{Publication: "go-module"}, invalid: true},
{name: "invalid format", source: &SourceSpec{VersionFormat: "other"}, invalid: true},
{name: "invalid prefix", source: &SourceSpec{VersionPrefix: strPtr("release-")}, invalid: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NormalizeSource(tt.module, tt.source)
if (err != nil) != tt.invalid {
t.Fatalf("NormalizeSource error = %v", err)
}
if !tt.invalid && got != tt.want {
t.Fatalf("NormalizeSource = %+v, want %+v", got, tt.want)
}
})
}
}
func TestLoadSourceUsesSelectedDeclaration(t *testing.T) {
repo := t.TempDir()
gitIdentityRun(t, repo, "init", "-q")
gitIdentityRun(t, repo, "config", "user.name", "ReleaseKit test")
gitIdentityRun(t, repo, "config", "user.email", "releasekit@example.invalid")
if err := os.Mkdir(filepath.Join(repo, "app"), 0755); err != nil {
t.Fatal(err)
}
mod := filepath.Join(repo, "app", "go.mod")
if err := os.WriteFile(mod, []byte("module example.com/committed\n"), 0644); err != nil {
t.Fatal(err)
}
if err := os.Symlink("app", filepath.Join(repo, "alias")); err != nil {
t.Fatal(err)
}
if err := os.Mkdir(filepath.Join(repo, "config"), 0755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(repo, "config", "settings.json"), []byte("{}"), 0644); err != nil {
t.Fatal(err)
}
gitIdentityRun(t, repo, "add", ".")
gitIdentityRun(t, repo, "commit", "-qm", "add module")
commit := strings.TrimSpace(gitIdentityOutput(t, repo, "rev-parse", "HEAD"))
if err := os.WriteFile(mod, []byte("module example.com/working\n"), 0644); err != nil {
t.Fatal(err)
}
spec := &SourceSpec{Dir: "app", GoEnabled: true}
working, err := LoadWorkingSource(context.Background(), repo, "", spec)
if err != nil || working.ModulePath != "example.com/working" || working.ModuleSubdir != "app" || working.Publication != "source" {
t.Fatalf("working source = %+v, error = %v", working, err)
}
committed, err := LoadCommittedSource(context.Background(), repo, "", commit, spec)
if err != nil || committed.ModulePath != "example.com/committed" || committed.ModuleSubdir != "app" {
t.Fatalf("committed source = %+v, error = %v", committed, err)
}
if _, err := LoadCommittedSource(context.Background(), repo, "alias", commit, spec); err != nil {
t.Fatalf("matching committed directories: %v", err)
}
if _, err := LoadCommittedSource(context.Background(), repo, ".", commit, spec); err == nil {
t.Fatal("expected conflicting committed directories to fail")
}
moduleSpec := &SourceSpec{Dir: "app", GoEnabled: true, Publication: "go-module"}
identity, err := FromCommittedSource(context.Background(), repo, "alias", "v1.2.3", commit, moduleSpec)
if err != nil || identity.ModulePath != "example.com/committed" || identity.Tag != "app/v1.2.3" {
t.Fatalf("explicit module identity = %+v, error = %v", identity, err)
}
matchingPrefix, conflictingPrefix := "app", "other"
moduleSpec.TagPrefix = &matchingPrefix
if _, err := FromCommittedSource(context.Background(), repo, "", "v1.2.3", commit, moduleSpec); err != nil {
t.Fatalf("matching module tag prefix: %v", err)
}
moduleSpec.TagPrefix = &conflictingPrefix
if _, err := FromCommittedSource(context.Background(), repo, "", "v1.2.3", commit, moduleSpec); err == nil {
t.Fatal("accepted conflicting module tag prefix")
}
config, err := LoadCommittedSource(context.Background(), repo, "", commit, &SourceSpec{Dir: "config"})
if err != nil || config.ModulePath != "" || config.ModuleSubdir != "config" {
t.Fatalf("committed source-only selection = %+v, error = %v", config, err)
}
if err := os.Remove(mod); err != nil {
t.Fatal(err)
}
if _, err := LoadWorkingSource(context.Background(), repo, "", spec); err == nil {
t.Fatal("Go selection accepted a missing module declaration")
}
if source, err := LoadWorkingSource(context.Background(), repo, "", &SourceSpec{Dir: "app"}); err != nil || source.ModulePath != "" {
t.Fatalf("source-only selection = %+v, error = %v", source, err)
}
}
func strPtr(s string) *string { return &s }
func TestResolveWorkingSourceWithoutModule(t *testing.T) {
repo := t.TempDir()
if err := os.Mkdir(filepath.Join(repo, "config"), 0755); err != nil {
t.Fatal(err)
}
got, err := ResolveWorkingSource(repo, "", &SourceSpec{Dir: "config"})
if err != nil {
t.Fatal(err)
}
if got.ModuleSubdir != "config" || got.GoEnabled || got.Publication != "source" {
t.Fatalf("selection = %+v", got)
}
if err := os.Symlink("config", filepath.Join(repo, "alias")); err != nil {
t.Fatal(err)
}
if _, err := ResolveWorkingSource(repo, "alias", &SourceSpec{Dir: "config"}); err != nil {
t.Fatalf("matching physical directories: %v", err)
}
if _, err := ResolveWorkingSource(repo, ".", &SourceSpec{Dir: "config"}); err == nil {
t.Fatal("expected conflicting directories to fail")
}
if err := os.WriteFile(filepath.Join(repo, "file"), nil, 0600); err != nil {
t.Fatal(err)
}
if _, err := ResolveWorkingSource(repo, "", &SourceSpec{Dir: "file"}); err == nil {
t.Fatal("expected a file selection to fail")
}
}