Skip to content

Commit d254335

Browse files
nachiketclaude
andcommitted
fix(amend): default author falls back to USERNAME on Windows (TP-056)
The env fallback chain only checked $USER, which Windows does not set — docops amend without --by errored on any Windows box lacking git user.name. Unmasked by the Windows CI un-hang: TestLifecycle_EndToEnd. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4035796 commit d254335

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

internal/amender/amender.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func Run(opts Options) (Result, error) {
9898
by = defaultAuthor()
9999
}
100100
if by == "" {
101-
return Result{}, errors.New("amender: --by is required (no $DOCOPS_USER, git user.name, or $USER set)")
101+
return Result{}, errors.New("amender: --by is required (no $DOCOPS_USER, git user.name, $USER, or $USERNAME set)")
102102
}
103103

104104
date := opts.Date
@@ -427,7 +427,7 @@ func atomicWrite(path string, data []byte, mode os.FileMode) error {
427427
return nil
428428
}
429429

430-
// defaultAuthor consults DOCOPS_USER → git user.name → USER.
430+
// defaultAuthor consults DOCOPS_USER → git user.name → USER/USERNAME.
431431
// Returns "" when none is set; caller emits a clear error.
432432
func defaultAuthor() string {
433433
if v := os.Getenv("DOCOPS_USER"); v != "" {
@@ -439,6 +439,10 @@ func defaultAuthor() string {
439439
if v := os.Getenv("USER"); v != "" {
440440
return v
441441
}
442+
// Windows spells it USERNAME.
443+
if v := os.Getenv("USERNAME"); v != "" {
444+
return v
445+
}
442446
return ""
443447
}
444448

0 commit comments

Comments
 (0)