feat(config): add git.author and git.no-gpg-sign options (fixes #600)

Adds configuration options for beads git commits:
- git.author: Override commit author (e.g., "beads-bot <beads@example.com>")
- 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 <beads@example.com>"
  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 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-20 03:36:41 -08:00
parent 7b758271ed
commit c988b171e8
4 changed files with 61 additions and 6 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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 <beads@example.com>" # Override commit author
no-gpg-sign: true # Disable GPG signing
```
### Why Two Systems?

View File

@@ -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 <beads@example.com>")
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 {