fix(daemon): apply git.author config to sync branch commits

The daemon's gitCommitInWorktree function was building git commit
commands directly without checking the git.author and git.no-gpg-sign
config options. This caused daemon sync commits to use the local git
user config instead of the configured beads-specific author.

Now gitCommitInWorktree applies the same config-based author and
signing options that buildCommitArgs uses for regular commits.

Fixes #1051
This commit is contained in:
elinor
2026-01-17 03:40:28 -08:00
committed by Steve Yegge
parent e60e8f1823
commit f06e742273

View File

@@ -9,6 +9,7 @@ import (
"strings"
"time"
"github.com/steveyegge/beads/internal/config"
"github.com/steveyegge/beads/internal/git"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/syncbranch"
@@ -165,9 +166,24 @@ func gitCommitInWorktree(ctx context.Context, worktreePath, filePath, message st
return fmt.Errorf("git add failed in worktree: %w", err)
}
// Commit with --no-verify to skip hooks (pre-commit hook would fail in worktree context)
// Build commit args with config-based author and signing options (GH#1051)
// Also use --no-verify to skip hooks (pre-commit hook would fail in worktree context)
// The worktree is internal to bd sync, so we don't need to run bd's pre-commit hook
commitCmd := exec.CommandContext(ctx, "git", "-C", worktreePath, "commit", "--no-verify", "-m", message)
args := []string{"-C", worktreePath, "commit", "--no-verify"}
// Add --author if configured (GH#1051: apply git.author config to daemon commits)
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")
}
args = append(args, "-m", message)
commitCmd := exec.CommandContext(ctx, "git", args...) // #nosec G204 - args built from trusted config values
output, err := commitCmd.CombinedOutput()
if err != nil {
return fmt.Errorf("git commit failed in worktree: %w\n%s", err, output)