feat: add git user.name to actor fallback chain (#994)
- Insert git config user.name in fallback chain before final $USER default - Consolidate duplicate actor resolution logic into single function - Add BEADS_ACTOR as env var alias for MCP compatibility - Add tests for actor resolution priority - Update CONFIG.md with Actor Identity Resolution section The new fallback order is: --actor flag > BD_ACTOR > BEADS_ACTOR > git user.name > $USER > "unknown" Co-authored-by: Ohffs <ohffsnotnow@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -802,30 +801,6 @@ func uniqueStrings(slice []string) []string {
|
||||
return result
|
||||
}
|
||||
|
||||
// getActorWithGit returns the actor for audit trail with git config fallback.
|
||||
// Priority: global actor var (from --actor flag or BD_ACTOR env) > git config user.name > $USER > "unknown"
|
||||
func getActorWithGit() string {
|
||||
// If actor is already set (from flag or env), use it
|
||||
if actor != "" && actor != "unknown" {
|
||||
return actor
|
||||
}
|
||||
|
||||
// Try git config user.name
|
||||
cmd := exec.Command("git", "config", "user.name")
|
||||
if output, err := cmd.Output(); err == nil {
|
||||
if gitUser := strings.TrimSpace(string(output)); gitUser != "" {
|
||||
return gitUser
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to USER env
|
||||
if user := os.Getenv("USER"); user != "" {
|
||||
return user
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func init() {
|
||||
deleteCmd.Flags().BoolP("force", "f", false, "Actually delete (without this flag, shows preview)")
|
||||
deleteCmd.Flags().String("from-file", "", "Read issue IDs from file (one per line)")
|
||||
|
||||
Reference in New Issue
Block a user