fix packaging and windows install regressions
Fixes #3388 Fixes #3399 Fixes #3404 Fixes #3454 Co-authored-by: jasononeil <315158+jasononeil@users.noreply.github.com> Co-authored-by: seanmartinsmith <114885497+seanmartinsmith@users.noreply.github.com>
This commit is contained in:
parent
aed707a103
commit
ecd2f7268c
8 changed files with 45 additions and 26 deletions
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
|
|
@ -155,7 +155,7 @@ jobs:
|
|||
mkdir -p "$staging"
|
||||
cp "bd-darwin-${arch}" "$staging/bd"
|
||||
cp LICENSE README.md CHANGELOG.md "$staging/"
|
||||
tar -czf "${staging}.tar.gz" "$staging"
|
||||
tar -czf "${staging}.tar.gz" -C "$staging" .
|
||||
shasum -a 256 "${staging}.tar.gz" >> darwin-checksums.txt
|
||||
done
|
||||
|
||||
|
|
@ -323,4 +323,3 @@ jobs:
|
|||
npm publish --access public
|
||||
# Uses OIDC trusted publishing - no token needed
|
||||
# Provenance attestations are automatic with trusted publishing
|
||||
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -148,7 +148,7 @@ endif
|
|||
install install-force: build
|
||||
@mkdir -p $(INSTALL_DIR)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@rm -f $(INSTALL_DIR)/bd.exe
|
||||
@rm -f $(INSTALL_DIR)/bd $(INSTALL_DIR)/bd.exe
|
||||
@cp $(BUILD_DIR)/bd.exe $(INSTALL_DIR)/bd.exe
|
||||
@echo "Installed bd.exe to $(INSTALL_DIR)/bd.exe"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1175,12 +1175,11 @@ func exportJSONLForCommit() {
|
|||
// gitAddFile as the parent, which relies on the inherited GIT_DIR to
|
||||
// identify the hook's worktree and apply the cross-worktree staging
|
||||
// guard (GH#3311 part 2). Scrubbing here would disable that guard.
|
||||
// The theoretical downside is sync.Once-cached git.GetRepoRoot() in
|
||||
// the subprocess being computed against cwd=.beads/; no current
|
||||
// caller reads it on this path, so it is a latent hazard rather than
|
||||
// a live bug.
|
||||
// Run from the project root, not .beads/. Embedded Dolt discovery starts
|
||||
// from cwd, so cwd=.beads/ can make the export subprocess look for a
|
||||
// nested .beads/.beads workspace and warn on every commit (GH#3454).
|
||||
cmd := exec.Command("bd", "export", "-o", fullPath)
|
||||
cmd.Dir = beadsDir
|
||||
cmd.Dir = exportSubprocessDir(beadsDir)
|
||||
cmd.Env = filterEnv(os.Environ(), "BD_GIT_HOOK")
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
|
@ -1200,6 +1199,10 @@ func exportJSONLForCommit() {
|
|||
}
|
||||
}
|
||||
|
||||
func exportSubprocessDir(beadsDir string) string {
|
||||
return filepath.Dir(beadsDir)
|
||||
}
|
||||
|
||||
// filterEnv returns a copy of env with entries matching the given key removed.
|
||||
func filterEnv(env []string, key string) []string {
|
||||
prefix := key + "="
|
||||
|
|
|
|||
|
|
@ -7,6 +7,16 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestExportSubprocessDirUsesProjectRoot(t *testing.T) {
|
||||
repo := t.TempDir()
|
||||
beadsDir := filepath.Join(repo, ".beads")
|
||||
|
||||
got := exportSubprocessDir(beadsDir)
|
||||
if got != repo {
|
||||
t.Fatalf("exportSubprocessDir(%q) = %q, want project root %q", beadsDir, got, repo)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSanitizeHuskyHook_V8 verifies that husky v8's `_/husky.sh` source line
|
||||
// is stripped and replaced with a PATH export, so the hook runs standalone
|
||||
// without needing `.beads/hooks/_/husky.sh` to exist. (GH#3132)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package setup
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -40,24 +41,25 @@ func TestCheckMuxMissingFile(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMuxProjectAgentsPath(t *testing.T) {
|
||||
if got := muxProjectAgentsPath("AGENTS.md"); got != ".mux/AGENTS.md" {
|
||||
t.Fatalf("got %q, want .mux/AGENTS.md", got)
|
||||
if got, want := muxProjectAgentsPath("AGENTS.md"), filepath.Join(".mux", "AGENTS.md"); got != want {
|
||||
t.Fatalf("got %q, want %q", got, want)
|
||||
}
|
||||
if got := muxProjectAgentsPath("/tmp/work/AGENTS.md"); got != "/tmp/work/.mux/AGENTS.md" {
|
||||
t.Fatalf("got %q, want /tmp/work/.mux/AGENTS.md", got)
|
||||
agentsPath := filepath.Join(t.TempDir(), "AGENTS.md")
|
||||
if got, want := muxProjectAgentsPath(agentsPath), filepath.Join(filepath.Dir(agentsPath), ".mux", "AGENTS.md"); got != want {
|
||||
t.Fatalf("got %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMuxProjectHookPaths(t *testing.T) {
|
||||
initPath, toolPostPath, toolEnvPath := muxProjectHookPaths("AGENTS.md")
|
||||
if initPath != ".mux/init" {
|
||||
t.Fatalf("init path = %q, want .mux/init", initPath)
|
||||
if want := filepath.Join(".mux", "init"); initPath != want {
|
||||
t.Fatalf("init path = %q, want %q", initPath, want)
|
||||
}
|
||||
if toolPostPath != ".mux/tool_post" {
|
||||
t.Fatalf("tool_post path = %q, want .mux/tool_post", toolPostPath)
|
||||
if want := filepath.Join(".mux", "tool_post"); toolPostPath != want {
|
||||
t.Fatalf("tool_post path = %q, want %q", toolPostPath, want)
|
||||
}
|
||||
if toolEnvPath != ".mux/tool_env" {
|
||||
t.Fatalf("tool_env path = %q, want .mux/tool_env", toolEnvPath)
|
||||
if want := filepath.Join(".mux", "tool_env"); toolEnvPath != want {
|
||||
t.Fatalf("tool_env path = %q, want %q", toolEnvPath, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,16 +116,17 @@ func TestMuxGlobalAgentsPath(t *testing.T) {
|
|||
t.Cleanup(func() {
|
||||
muxUserHomeDir = os.UserHomeDir
|
||||
})
|
||||
home := t.TempDir()
|
||||
muxUserHomeDir = func() (string, error) {
|
||||
return "/tmp/test-home", nil
|
||||
return home, nil
|
||||
}
|
||||
|
||||
got, err := muxGlobalAgentsPath()
|
||||
if err != nil {
|
||||
t.Fatalf("muxGlobalAgentsPath returned error: %v", err)
|
||||
}
|
||||
if got != "/tmp/test-home/.mux/AGENTS.md" {
|
||||
t.Fatalf("got %q, want /tmp/test-home/.mux/AGENTS.md", got)
|
||||
if want := filepath.Join(home, ".mux", "AGENTS.md"); got != want {
|
||||
t.Fatalf("got %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ func TestCircuitBreakerDir_UsesSubdirectory(t *testing.T) {
|
|||
cb := newCircuitBreaker("127.0.0.1", 44444, "")
|
||||
t.Cleanup(func() { os.Remove(cb.filePath) })
|
||||
|
||||
if filepath.Dir(cb.filePath) != circuitBreakerDir {
|
||||
if filepath.Dir(cb.filePath) != filepath.Clean(circuitBreakerDir) {
|
||||
t.Errorf("circuit breaker file should be in %s, got dir %s",
|
||||
circuitBreakerDir, filepath.Dir(cb.filePath))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -170,7 +171,9 @@ func TestCredentialKeyFileGeneration(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("key file should exist after initCredentialKey: %v", err)
|
||||
}
|
||||
if perm := info.Mode().Perm(); perm != 0600 {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Log("skipping POSIX mode-bit check on Windows")
|
||||
} else if perm := info.Mode().Perm(); perm != 0600 {
|
||||
t.Errorf("key file permissions = %o, want 0600", perm)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ func TestCanonicalizePathCase(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCanonicalizeIfRelative(t *testing.T) {
|
||||
absInput := filepath.Join(t.TempDir(), "test", "path")
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
|
|
@ -270,10 +271,10 @@ func TestCanonicalizeIfRelative(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "absolute path returns unchanged",
|
||||
input: "/tmp/test/path",
|
||||
input: absInput,
|
||||
validate: func(t *testing.T, result string) {
|
||||
if result != "/tmp/test/path" {
|
||||
t.Errorf("expected /tmp/test/path, got %q", result)
|
||||
if result != absInput {
|
||||
t.Errorf("expected %q, got %q", absInput, result)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue