Skip to content

fix: unborn-first-commit — soporte para repos recién inicializados#207

Merged
blak0p merged 1 commit into
mainfrom
unborn-first-commit
Jul 1, 2026
Merged

fix: unborn-first-commit — soporte para repos recién inicializados#207
blak0p merged 1 commit into
mainfrom
unborn-first-commit

Conversation

@blak0p

@blak0p blak0p commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Closes #204

Summary

  • git-courer ahora funciona en repos recién inicializados (unborn branch, sin commits)
  • Status.Ahead/Behind pasan a *int con null en unborn (semánticamente correcto)
  • CommitTree omite -p cuando no hay parent (root commit)
  • session start y backup toleran unborn HEAD

Changes

File Change
internal/core/domain/git.go Status.Ahead/Behind: int*int, sin omitempty
internal/delivery/mcp/prreview/result.go BranchInfo.Ahead/Behind: int*int
internal/adapters/git/exec_write_commit.go CommitTree: args condicionales, omite -p si no hay parent
internal/delivery/mcp/core/commit_handler.go applyPlumbing: tolera Head() fallando
internal/adapters/git/exec_read_info.go Status: detecta unborn, skipea rev-list
internal/delivery/mcp/shared/helpers.go FormatStatusJSON: nil-safe *int
internal/delivery/mcp/prreview/handler.go nil-safe copy a BranchInfo
internal/delivery/mcp/session/session.go handleStart: emptyTreeHash fallback
internal/adapters/git/exec_backup.go collectReachabilityTips: tolera unborn
8 test files Tests nuevos para cada fix point

Test Plan

  • go test ./... -short — 40 packages, 0 regresiones
  • go vet ./... — clean
  • Tests nuevos: CommitTree con parent vacío, Status en unborn, FormatStatusJSON con nil, backup en unborn, session start en unborn

WHY
Operations on fresh repositories with zero commits caused crashes or errors because HEAD resolution failed. Additionally, using non-pointer integers for Ahead/Behind fields made it impossible to distinguish between a valid count of zero and missing data when no upstream was configured.

WHAT
* Guarded git commands against unborn state by making HEAD resolution best-effort and falling back to empty tree hash.
* Changed Ahead and Behind fields in GitStatus and BranchInfo structs from int to *int to support null values.
* Conditionally append parent flags only when a valid parent hash exists for root commits.
@blak0p

blak0p commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

/label type:bug

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@blak0p blak0p added the type:bug Bug fix label Jul 1, 2026
@blak0p blak0p merged commit 1deefbf into main Jul 1, 2026
6 checks passed
@blak0p blak0p deleted the unborn-first-commit branch July 1, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git-courer — unborn-first-commit: fix first commit in new repo

1 participant