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
ResolvedBaseandResolvedHeadfields to theRemotestruct - Updated
SetRemoteResolution()to use separate config keys:-
remote.<name>.glab-resolved-basefor base repository -
remote.<name>.glab-resolved-headfor head repository
-
- Updated
Remotes()to read from both new and legacy config keys - Updated
BaseRepo()andHeadRepo()to check new fields first, falling back to legacyResolvedfield - 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-resolvedcontinue to work via fallback logic - New configs use separate keys to prevent duplicates
- All existing tests pass without modification
Related Issues
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
ResolvedBasefield - 3 tests for
ResolvedHeadfield - 5 tests for
SetRemoteResolutionconfig key selection - 4 tests for edge cases (basement, baseball, header, heading)
- 3 tests for
- 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