Resolve source operations from the Git checkout root
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit"
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit/buildinfo"
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit/cmd/releasekit/internal/cli"
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit/internal/git"
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit/internal/releaseidentity"
|
||||
)
|
||||
|
||||
@@ -30,6 +31,13 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stderr, "%v\n%s\n", err, cli.Usage)
|
||||
return 2
|
||||
}
|
||||
if invocation.Command != cli.VersionCommand {
|
||||
invocation.Repository, err = git.RepositoryRoot(ctx, invocation.Repository)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "%v\n", err)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
switch invocation.Command {
|
||||
case cli.VersionCommand:
|
||||
|
||||
25
cmd/releasekit/repository_test.go
Normal file
25
cmd/releasekit/repository_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNativeCheckFromChildUsesRootProfileAndSuite(t *testing.T) {
|
||||
binary := buildWorkflowCLI(t, cliRepositoryRoot(t))
|
||||
repository := newCLIRepository(t)
|
||||
writeRepositoryFile(t, repository, "candidate_test.go", "package candidate\nimport \"testing\"\nfunc TestFixture(t *testing.T) { t.Fatal(\"root suite failure\") }\n")
|
||||
writeRepositoryFile(t, repository, "releasekit.json", `{"product":"Example Product"}`)
|
||||
writeRepositoryFile(t, repository, "apps/widget/go.mod", "module example.com/widget\n\ngo 1.26.0\n")
|
||||
writeRepositoryFile(t, repository, "apps/widget/widget_test.go", "package widget\nimport \"testing\"\nfunc TestWidget(t *testing.T) {}\n")
|
||||
cliGitRun(t, repository, "add", ".")
|
||||
cliGitRun(t, repository, "commit", "-m", "Add failing root and passing child")
|
||||
command := exec.Command(binary, "check", "v1.2.3")
|
||||
command.Dir = filepath.Join(repository, "apps", "widget")
|
||||
output, err := command.CombinedOutput()
|
||||
if exit, ok := err.(*exec.ExitError); !ok || exit.ExitCode() != 1 || !strings.Contains(string(output), "root suite failure") || !strings.Contains(string(output), "module=example.com/cli-candidate") {
|
||||
t.Fatalf("child invocation error = %v, output = %s", err, output)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user