Merge pull request #1470 from Tibsfox/fix/base-branch-config-1466
fix(git): add git.base_branch config to replace hardcoded main target
This commit is contained in:
@@ -242,6 +242,16 @@ describe('config-set command', () => {
|
||||
assert.strictEqual(config.workflow.use_worktrees, false);
|
||||
});
|
||||
|
||||
test('sets git.base_branch for non-main default branches', () => {
|
||||
writeConfig(tmpDir, {});
|
||||
|
||||
const result = runGsdTools('config-set git.base_branch master', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const config = readConfig(tmpDir);
|
||||
assert.strictEqual(config.git.base_branch, 'master');
|
||||
});
|
||||
|
||||
test('errors when no key path provided', () => {
|
||||
const result = runGsdTools('config-set', tmpDir);
|
||||
assert.strictEqual(result.success, false);
|
||||
@@ -329,6 +339,27 @@ describe('config-get command', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('gets git.base_branch after it is set', () => {
|
||||
runGsdTools('config-set git.base_branch master', tmpDir);
|
||||
const result = runGsdTools('config-get git.base_branch', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output, 'master');
|
||||
});
|
||||
|
||||
test('errors for git.base_branch when not explicitly set', () => {
|
||||
// Default config from config-ensure-section does not include git.base_branch,
|
||||
// so config-get should return "Key not found" — this triggers auto-detect
|
||||
// fallback in the workflow (origin/HEAD detection).
|
||||
const result = runGsdTools('config-get git.base_branch', tmpDir);
|
||||
assert.strictEqual(result.success, false);
|
||||
assert.ok(
|
||||
result.error.includes('Key not found'),
|
||||
`Expected "Key not found" in error: ${result.error}`
|
||||
);
|
||||
});
|
||||
|
||||
test('errors when no key path provided', () => {
|
||||
const result = runGsdTools('config-get', tmpDir);
|
||||
assert.strictEqual(result.success, false);
|
||||
|
||||
Reference in New Issue
Block a user