Skip to content

[gitalisk][repository] Add tracking branch detection in Gitalisk

Problem to Solve

The CoreGitaliskRepository needs the ability to detect which remote branch a local branch is tracking.

Proposal

  1. Add get_tracking_branch_name() method to CoreGitaliskRepository in Rust
  2. Implement tracking branch detection using git config commands to find upstream configuration
  3. Query branch.<name>.merge and branch.<name>.remote git config settings
  4. Handle cases where no tracking branch is configured (return None/undefined)
  5. Return properly formatted remote branch reference (e.g., "origin/main")
  6. Expose method through NAPI bindings to Node.js as getTrackingBranchName()
  7. Update TypeScript definitions with new method

Further Details

Acceptance Criteria:

  • Method returns tracking branch name when configured (e.g., "origin/main")
  • Returns None/undefined when no tracking branch is configured
  • Handles various remote configurations (origin, upstream, custom remotes)
  • Proper error handling for repositories without remotes or invalid configurations
  • Handles detached HEAD state appropriately
  • Test coverage for different tracking branch scenarios

Implementation Notes:

  • Use git config branch.<current-branch>.merge to get tracking branch reference
  • Use git config branch.<current-branch>.remote to get remote name
  • Combine remote name and branch reference for full tracking branch name
  • Handle edge cases like missing remote or malformed configuration

Links / References