* revert: drop the journaled ownership handoff API from the release branch (#6281)
This reverts commit 74e25cba15, restoring the
release branch to the exact tree validated as v1.3.0-rc.2.
#6281 landed one commit past rc.2, so no release candidate ever exercised it.
Nothing imports `internal/ownershiphandoff` and no command registers it — the
package is unreachable from any `bd` entry point, so removing it cannot change
shipped behavior. It is superseded by a redesign that builds a fresh
`internal/ownershiphandoffv2` and deletes this package outright, and its
Hooks/Execute shape is the scaffolding of an architecture the owner rejected.
The commit never landed on main, so this is release-branch-only and nothing is
lost anywhere else. Reverting also returns
engdocs/design/ownership-handoff-contract.md to its prospective voice, which is
accurate again now that the implementation it described is gone.
* release: stamp 1.3.0 and date the changelog entry to the release day
`verify-version-consistency` in .github/workflows/release.yml compares the tag
name against the `Version = ` constant in cmd/bd/version.go and fails the job on
any mismatch, so a v1.3.0 tag against the 1.3.0-rc.2 stamp would abort the
pipeline before it built anything.
Bumped with ./scripts/update-versions.sh 1.3.0, which carries the stamp into all
seven version files, the two uv.lock entries, the ten githook managed-section
markers and the winres strings. The winres numeric file_version/product_version
and the manifest assemblyIdentity never carried the prerelease suffix and are
unchanged. ./scripts/check-versions.sh passes 24/24.
CHANGELOG.md's [1.3.0] heading carried 2026-08-28, the branch-cut date, which
predated both of its own release candidates. It and the matching
cmd/bd/info.go versionChanges entry now read 2026-09-15, the release date. The
section's reviewed content is untouched and [Unreleased] remains empty.
Dating the entry truthfully also forced its position. versionChanges is
reverse-chronological and getVersionsSince treats array index as recency, so
TestGetVersionsSinceOrder failed: the 1.3.0 entry still sat below its own rc.1
and rc.2, where the branch-cut date had made it look like the oldest of the
three. The entry moves to the head of the array, byte for byte unchanged. That
restores the strict date ordering and fixes the behavior it was hiding — an
rc.2 tester upgrading to the release now gets the [1.3.0] digest from
`bd upgrade review` instead of being told there is nothing new.
167 lines
3.8 KiB
Go
167 lines
3.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"runtime/debug"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/beads/internal/beads"
|
|
"github.com/steveyegge/beads/internal/metrics"
|
|
)
|
|
|
|
var (
|
|
// Version is the current version of bd (overridden by ldflags at build time)
|
|
Version = "1.3.0"
|
|
// Build can be set via ldflags at compile time
|
|
Build = "dev"
|
|
// Commit and branch the git revision the binary was built from (optional ldflag)
|
|
Commit = ""
|
|
Branch = ""
|
|
)
|
|
|
|
var versionCmd = &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print version information",
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
evt := metrics.NewCommandEvent("version")
|
|
defer func() {
|
|
if c := metrics.Global(); c != nil {
|
|
c.CloseEventAndAdd(evt)
|
|
}
|
|
}()
|
|
|
|
commit := resolveCommitHash()
|
|
branch := resolveBranch()
|
|
|
|
if jsonOutput {
|
|
result := map[string]interface{}{
|
|
"version": Version,
|
|
"build": Build,
|
|
}
|
|
if commit != "" {
|
|
result["commit"] = commit
|
|
}
|
|
if branch != "" {
|
|
result["branch"] = branch
|
|
}
|
|
if err := outputJSON(result); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if commit != "" && branch != "" {
|
|
fmt.Printf("bd version %s (%s: %s@%s)\n", Version, Build, branch, shortCommit(commit))
|
|
} else if commit != "" {
|
|
fmt.Printf("bd version %s (%s: %s)\n", Version, Build, shortCommit(commit))
|
|
} else {
|
|
fmt.Printf("bd version %s (%s)\n", Version, Build)
|
|
}
|
|
}
|
|
|
|
// Check for multiple bd binaries in PATH
|
|
if dups := findDuplicateBinaries(); len(dups) > 1 {
|
|
fmt.Fprintf(os.Stderr, "\nWarning: multiple 'bd' binaries found in PATH:\n")
|
|
for _, p := range dups {
|
|
fmt.Fprintf(os.Stderr, " %s\n", p)
|
|
}
|
|
fmt.Fprintf(os.Stderr, "The first one is being used. Remove duplicates to avoid confusion.\n")
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(versionCmd)
|
|
}
|
|
|
|
func resolveCommitHash() string {
|
|
if Commit != "" {
|
|
return Commit
|
|
}
|
|
|
|
if info, ok := debug.ReadBuildInfo(); ok {
|
|
for _, setting := range info.Settings {
|
|
if setting.Key == "vcs.revision" && setting.Value != "" {
|
|
return setting.Value
|
|
}
|
|
}
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
func shortCommit(hash string) string {
|
|
if len(hash) > 12 {
|
|
return hash[:12]
|
|
}
|
|
return hash
|
|
}
|
|
|
|
func resolveBranch() string {
|
|
if Branch != "" {
|
|
return Branch
|
|
}
|
|
|
|
// Try to get branch from build info (build-time VCS detection)
|
|
if info, ok := debug.ReadBuildInfo(); ok {
|
|
for _, setting := range info.Settings {
|
|
if setting.Key == "vcs.branch" && setting.Value != "" {
|
|
return setting.Value
|
|
}
|
|
}
|
|
}
|
|
|
|
// Fallback: try to get branch from git at runtime
|
|
// Use symbolic-ref to work in fresh repos without commits
|
|
// Uses CWD repo context since this shows user's current branch
|
|
if rc, err := beads.GetRepoContext(); err == nil {
|
|
cmd := rc.GitCmdCWD(context.Background(), "symbolic-ref", "--short", "HEAD")
|
|
if output, err := cmd.Output(); err == nil {
|
|
if branch := strings.TrimSpace(string(output)); branch != "" && branch != "HEAD" {
|
|
return branch
|
|
}
|
|
}
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
// findDuplicateBinaries searches PATH for all "bd" executables.
|
|
// Returns their full paths. If len > 1, there are duplicates.
|
|
func findDuplicateBinaries() []string {
|
|
name := "bd"
|
|
if runtime.GOOS == "windows" {
|
|
name = "bd.exe"
|
|
}
|
|
|
|
seen := make(map[string]bool)
|
|
var paths []string
|
|
|
|
for _, dir := range filepath.SplitList(os.Getenv("PATH")) {
|
|
candidate := filepath.Join(dir, name)
|
|
// Resolve symlinks so we don't double-count
|
|
resolved, err := filepath.EvalSymlinks(candidate)
|
|
if err != nil {
|
|
// Try the raw path (might be a valid binary without symlinks)
|
|
resolved = candidate
|
|
}
|
|
info, err := os.Stat(candidate)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
if info.IsDir() {
|
|
continue
|
|
}
|
|
if !seen[resolved] {
|
|
seen[resolved] = true
|
|
paths = append(paths, candidate)
|
|
}
|
|
}
|
|
return paths
|
|
}
|