Skip to content

Make feature branch prefix configurable#6

Closed
eslerm wants to merge 2 commits intomgreau:mainfrom
eslerm:pr/configurable-branch-prefix
Closed

Make feature branch prefix configurable#6
eslerm wants to merge 2 commits intomgreau:mainfrom
eslerm:pr/configurable-branch-prefix

Conversation

@eslerm
Copy link
Copy Markdown
Contributor

@eslerm eslerm commented Mar 20, 2026

  • Replace hardcoded branch prefix with branch_prefix config field
  • Falls back to git config user.name, then no prefix

eslerm and others added 2 commits March 16, 2026 11:49
Prevent indefinite hangs when GitHub is slow or unreachable by setting
a 30s timeout on the OAuth2 HTTP client and all exec.CommandContext calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded "mgreau/" branch prefix with branch_prefix config
field. Falls back to git config user.name, then no prefix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eslerm eslerm force-pushed the pr/configurable-branch-prefix branch from 642cab3 to 8f16aaa Compare March 20, 2026 01:59
Copy link
Copy Markdown
Owner

@mgreau mgreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two related issues on the git config user.name fallback in GetBranchPrefix.

Comment thread internal/config/config.go
Comment on lines +138 to +141
// Try git config
out, err := exec.Command("git", "config", "user.name").Output()
if err == nil {
name := strings.TrimSpace(string(out))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues here:

  1. exec.Command has no timeout. Every other subprocess in this codebase now uses withTimeout / exec.CommandContext. This call can hang indefinitely if git is slow or the working directory is unusual.

  2. user.name can contain spaces (e.g. "John Doe"), producing branch names like John Doe/feature that break many tools and CLIs.

Suggestion fixes both — wraps the call in a 5s context and replaces spaces with hyphens. Also needs "context" added to the import block.

Suggested change
// Try git config
out, err := exec.Command("git", "config", "user.name").Output()
if err == nil {
name := strings.TrimSpace(string(out))
// Try git config user.name; replace spaces so the prefix is branch-safe.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
out, err := exec.CommandContext(ctx, "git", "config", "user.name").Output()
if err == nil {
name := strings.ReplaceAll(strings.TrimSpace(string(out)), " ", "-")

@mgreau
Copy link
Copy Markdown
Owner

mgreau commented Apr 16, 2026

Superseded by #7, which incorporates the review feedback (5s timeout on git config call, spaces→hyphens in user.name).

@mgreau mgreau closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants