mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-07 02:07:54 +02:00
fix: harden default co-author opt-out and correct the docs
Follow-up on the co-author default in this PR. - Remove the existsSync/writeFileSync race in the installer settings write (CodeQL js/file-system-race, high). A single guarded read now covers the fresh-install case, and unreadable or non-object settings are left untouched. - Respect `attribution` as an explicit user choice. It supersedes `includeCoAuthoredBy` in Claude Code 2.1.x, so a user who configured it would otherwise have had a dead key written into their settings. - Share one opt-out rule via scripts/lib/claude-commit-attribution.js instead of duplicating it across the installer and plugin setup. - Update the git-workflow rule and its nine mirrors and translations, which still told users ECC does not ship this setting. We keep writing the deprecated `includeCoAuthoredBy` key rather than `attribution`: unknown keys fail Claude Code settings validation, so writing `attribution` would break users on older versions.
This commit is contained in:
@@ -936,6 +936,33 @@ function runTests() {
|
||||
}
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('reinstall preserves an explicit attribution opt-in', () => {
|
||||
const homeDir = createTempDir('install-apply-home-');
|
||||
const projectDir = createTempDir('install-apply-project-');
|
||||
|
||||
try {
|
||||
const claudeRoot = path.join(homeDir, '.claude');
|
||||
fs.mkdirSync(claudeRoot, { recursive: true });
|
||||
const settingsPath = path.join(claudeRoot, 'settings.json');
|
||||
// `attribution` supersedes `includeCoAuthoredBy` in Claude Code, so writing
|
||||
// the deprecated key here would be dead config that loses to the user's choice.
|
||||
const customSettings = {
|
||||
attribution: { commit: 'Signed-off-by: Someone <someone@example.com>' },
|
||||
theme: 'dark',
|
||||
};
|
||||
fs.writeFileSync(settingsPath, JSON.stringify(customSettings, null, 2));
|
||||
|
||||
const install = run(['--profile', 'core'], { cwd: projectDir, homeDir });
|
||||
assert.strictEqual(install.code, 0, install.stderr);
|
||||
|
||||
const afterInstall = readJson(settingsPath);
|
||||
assert.deepStrictEqual(afterInstall, customSettings);
|
||||
} finally {
|
||||
cleanup(homeDir);
|
||||
cleanup(projectDir);
|
||||
}
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('ignores malformed existing settings.json during claude install', () => {
|
||||
const homeDir = createTempDir('install-apply-home-');
|
||||
const projectDir = createTempDir('install-apply-project-');
|
||||
|
||||
Reference in New Issue
Block a user