fix: use separate config keys for base and head repository resolutions

Description

This fixes a bug where users were repeatedly prompted to select their base repository on every glab command. The issue was caused by both base and head repository resolutions being stored under the same git config key (remote.<name>.glab-resolved), creating duplicate values that confused the resolution logic.

Changes

  • Added separate ResolvedBase and ResolvedHead fields to the Remote struct
  • Updated SetRemoteResolution() to use separate config keys:
    • remote.<name>.glab-resolved-base for base repository
    • remote.<name>.glab-resolved-head for head repository
  • Updated Remotes() to read from both new and legacy config keys
  • Updated BaseRepo() and HeadRepo() to check new fields first, falling back to legacy Resolved field
  • Added comprehensive test coverage (11 new tests)
  • Fixed prefix matching to prevent false matches (e.g., "basement" matching "base")

Backward Compatibility

The fix maintains full backward compatibility:

  • Existing configs using remote.<name>.glab-resolved continue to work via fallback logic
  • New configs use separate keys to prevent duplicates
  • All existing tests pass without modification

Resolves #8203

How has this been tested?

  • All existing tests pass (28 resolver tests, all git package tests)
  • Added 11 new tests specifically for this feature:
    • 3 tests for ResolvedBase field
    • 3 tests for ResolvedHead field
    • 5 tests for SetRemoteResolution config key selection
    • 4 tests for edge cases (basement, baseball, header, heading)
  • Test coverage increased:
    • glrepo: 89.0% → 91.7% (+2.7%)
    • git: 57.5% → 58.3% (+0.8%)
  • Manually tested MR creation workflow with the fix
Edited by Kai Armstrong

Merge request reports

Loading