From c988b171e8c4b24f00d725d14d8f6234365f7e3a Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sat, 20 Dec 2025 03:36:41 -0800 Subject: [PATCH] feat(config): add git.author and git.no-gpg-sign options (fixes #600) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds configuration options for beads git commits: - git.author: Override commit author (e.g., "beads-bot ") - git.no-gpg-sign: Disable GPG signing for beads commits This is useful for users with Touch ID commit signing (like Secretive) who get prompted for every beads auto-commit. Config example: ```yaml git: author: "beads-bot " no-gpg-sign: true ``` Environment variables: BD_GIT_AUTHOR, BD_GIT_NO_GPG_SIGN Closes #600 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cmd/bd/doctor/fix/untracked.go | 17 ++++++++++++++- cmd/bd/sync.go | 38 +++++++++++++++++++++++++++++----- docs/CONFIG.md | 8 +++++++ internal/config/config.go | 4 ++++ 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/cmd/bd/doctor/fix/untracked.go b/cmd/bd/doctor/fix/untracked.go index 34e7f9d9..34a68002 100644 --- a/cmd/bd/doctor/fix/untracked.go +++ b/cmd/bd/doctor/fix/untracked.go @@ -6,6 +6,8 @@ import ( "os/exec" "path/filepath" "strings" + + "github.com/steveyegge/beads/internal/config" ) // UntrackedJSONL stages and commits untracked .beads/*.jsonl files. @@ -69,8 +71,21 @@ func UntrackedJSONL(path string) error { } // Commit only the JSONL files we staged (using --only to preserve other staged changes) + // Use config-based author and signing options (GH#600) commitMsg := "chore(beads): commit untracked JSONL files\n\nAuto-committed by bd doctor --fix (bd-pbj)" - commitArgs := []string{"commit", "--only", "-m", commitMsg} + commitArgs := []string{"commit", "--only"} + + // Add --author if configured + if author := config.GetString("git.author"); author != "" { + commitArgs = append(commitArgs, "--author", author) + } + + // Add --no-gpg-sign if configured + if config.GetBool("git.no-gpg-sign") { + commitArgs = append(commitArgs, "--no-gpg-sign") + } + + commitArgs = append(commitArgs, "-m", commitMsg) commitArgs = append(commitArgs, untrackedFiles...) commitCmd := exec.Command("git", commitArgs...) // #nosec G204 -- untrackedFiles validated above commitCmd.Dir = path diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index 665ee4b5..792f56ed 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -893,6 +893,30 @@ func gitHasBeadsChanges(ctx context.Context) (bool, error) { return len(strings.TrimSpace(string(statusOutput))) > 0, nil } +// buildGitCommitArgs returns git commit args with config-based author and signing options (GH#600) +// This allows users to configure a separate author and disable GPG signing for beads commits. +func buildGitCommitArgs(repoRoot, message string, extraArgs ...string) []string { + args := []string{"-C", repoRoot, "commit"} + + // Add --author if configured + if author := config.GetString("git.author"); author != "" { + args = append(args, "--author", author) + } + + // Add --no-gpg-sign if configured + if config.GetBool("git.no-gpg-sign") { + args = append(args, "--no-gpg-sign") + } + + // Add message + args = append(args, "-m", message) + + // Add any extra args (like -- pathspec) + args = append(args, extraArgs...) + + return args +} + // gitCommit commits the specified file (worktree-aware) func gitCommit(ctx context.Context, filePath string, message string) error { // Get the repository root (handles worktrees properly) @@ -918,8 +942,9 @@ func gitCommit(ctx context.Context, filePath string, message string) error { message = fmt.Sprintf("bd sync: %s", time.Now().Format("2006-01-02 15:04:05")) } - // Commit from repo root context - commitCmd := exec.CommandContext(ctx, "git", "-C", repoRoot, "commit", "-m", message) + // Commit from repo root context with config-based author and signing options + commitArgs := buildGitCommitArgs(repoRoot, message) + commitCmd := exec.CommandContext(ctx, "git", commitArgs...) output, err := commitCmd.CombinedOutput() if err != nil { return fmt.Errorf("git commit failed: %w\n%s", err, output) @@ -993,7 +1018,9 @@ func gitCommitBeadsDir(ctx context.Context, message string) error { relBeadsDir = beadsDir // Fall back to absolute path if relative fails } - commitCmd := exec.CommandContext(ctx, "git", "-C", repoRoot, "commit", "-m", message, "--", relBeadsDir) + // Use config-based author and signing options with pathspec + commitArgs := buildGitCommitArgs(repoRoot, message, "--", relBeadsDir) + commitCmd := exec.CommandContext(ctx, "git", commitArgs...) output, err := commitCmd.CombinedOutput() if err != nil { return fmt.Errorf("git commit failed: %w\n%s", err, output) @@ -1748,11 +1775,12 @@ func commitToExternalBeadsRepo(ctx context.Context, beadsDir, message string, pu return false, nil // No changes to commit } - // Commit + // Commit with config-based author and signing options if message == "" { message = fmt.Sprintf("bd sync: %s", time.Now().Format("2006-01-02 15:04:05")) } - commitCmd := exec.CommandContext(ctx, "git", "-C", repoRoot, "commit", "-m", message) + commitArgs := buildGitCommitArgs(repoRoot, message) + commitCmd := exec.CommandContext(ctx, "git", commitArgs...) if output, err := commitCmd.CombinedOutput(); err != nil { return false, fmt.Errorf("git commit failed: %w\n%s", err, output) } diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 5ade25c5..ce111f19 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -36,6 +36,8 @@ Tool-level settings you can configure: | `no-auto-import` | `--no-auto-import` | `BD_NO_AUTO_IMPORT` | `false` | Disable auto JSONL import | | `no-push` | `--no-push` | `BD_NO_PUSH` | `false` | Skip pushing to remote in bd sync | | `create.require-description` | - | `BD_CREATE_REQUIRE_DESCRIPTION` | `false` | Require description when creating issues | +| `git.author` | - | `BD_GIT_AUTHOR` | (none) | Override commit author for beads commits | +| `git.no-gpg-sign` | - | `BD_GIT_NO_GPG_SIGN` | `false` | Disable GPG signing for beads commits | | `db` | `--db` | `BD_DB` | (auto-discover) | Database path | | `actor` | `--actor` | `BD_ACTOR` | `$USER` | Actor name for audit trail | | `flush-debounce` | - | `BEADS_FLUSH_DEBOUNCE` | `5s` | Debounce time for auto-flush | @@ -76,6 +78,12 @@ flush-debounce: 15s # Require descriptions on all issues (enforces context for future work) create: require-description: true + +# Git commit signing options (GH#600) +# Useful when you have Touch ID commit signing that prompts for each commit +git: + author: "beads-bot " # Override commit author + no-gpg-sign: true # Disable GPG signing ``` ### Why Two Systems? diff --git a/internal/config/config.go b/internal/config/config.go index 47a9f177..08b803b3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -112,6 +112,10 @@ func Initialize() error { // Create command defaults v.SetDefault("create.require-description", false) + // Git configuration defaults (GH#600) + v.SetDefault("git.author", "") // Override commit author (e.g., "beads-bot ") + v.SetDefault("git.no-gpg-sign", false) // Disable GPG signing for beads commits + // Read config file if it was found if configFileSet { if err := v.ReadInConfig(); err != nil {