mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
chore(cli): enable deprecated settings removal by default (#20682)
This commit is contained in:
@@ -2162,7 +2162,7 @@ describe('Settings Loading and Merging', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should prioritize new settings over deprecated ones and respect removeDeprecated flag', () => {
|
||||
it('should remove deprecated settings by default and prioritize new ones', () => {
|
||||
const userSettingsContent = {
|
||||
general: {
|
||||
disableAutoUpdate: true,
|
||||
@@ -2177,27 +2177,11 @@ describe('Settings Loading and Merging', () => {
|
||||
};
|
||||
|
||||
const loadedSettings = createMockSettings(userSettingsContent);
|
||||
|
||||
const setValueSpy = vi.spyOn(loadedSettings, 'setValue');
|
||||
|
||||
// 1. removeDeprecated = false (default)
|
||||
// Default is now removeDeprecated = true
|
||||
migrateDeprecatedSettings(loadedSettings);
|
||||
|
||||
// Should still have old settings
|
||||
expect(
|
||||
loadedSettings.forScope(SettingScope.User).settings.general,
|
||||
).toHaveProperty('disableAutoUpdate');
|
||||
expect(
|
||||
(
|
||||
loadedSettings.forScope(SettingScope.User).settings.context as {
|
||||
fileFiltering: { disableFuzzySearch: boolean };
|
||||
}
|
||||
).fileFiltering,
|
||||
).toHaveProperty('disableFuzzySearch');
|
||||
|
||||
// 2. removeDeprecated = true
|
||||
migrateDeprecatedSettings(loadedSettings, true);
|
||||
|
||||
// Should remove disableAutoUpdate and trust enableAutoUpdate: true
|
||||
expect(setValueSpy).toHaveBeenCalledWith(SettingScope.User, 'general', {
|
||||
enableAutoUpdate: true,
|
||||
@@ -2209,6 +2193,37 @@ describe('Settings Loading and Merging', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should preserve deprecated settings when removeDeprecated is explicitly false', () => {
|
||||
const userSettingsContent = {
|
||||
general: {
|
||||
disableAutoUpdate: true,
|
||||
enableAutoUpdate: true,
|
||||
},
|
||||
context: {
|
||||
fileFiltering: {
|
||||
disableFuzzySearch: false,
|
||||
enableFuzzySearch: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const loadedSettings = createMockSettings(userSettingsContent);
|
||||
|
||||
migrateDeprecatedSettings(loadedSettings, false);
|
||||
|
||||
// Should still have old settings since removeDeprecated = false
|
||||
expect(
|
||||
loadedSettings.forScope(SettingScope.User).settings.general,
|
||||
).toHaveProperty('disableAutoUpdate');
|
||||
expect(
|
||||
(
|
||||
loadedSettings.forScope(SettingScope.User).settings.context as {
|
||||
fileFiltering: { disableFuzzySearch: boolean };
|
||||
}
|
||||
).fileFiltering,
|
||||
).toHaveProperty('disableFuzzySearch');
|
||||
});
|
||||
|
||||
it('should trigger migration automatically during loadSettings', () => {
|
||||
mockFsExistsSync.mockImplementation(
|
||||
(p: fs.PathLike) => p === USER_SETTINGS_PATH,
|
||||
|
||||
@@ -796,14 +796,13 @@ export function loadSettings(
|
||||
/**
|
||||
* Migrates deprecated settings to their new counterparts.
|
||||
*
|
||||
* TODO: After a couple of weeks (around early Feb 2026), we should start removing
|
||||
* the deprecated settings from the settings files by default.
|
||||
* Deprecated settings are removed from settings files by default.
|
||||
*
|
||||
* @returns true if any changes were made and need to be saved.
|
||||
*/
|
||||
export function migrateDeprecatedSettings(
|
||||
loadedSettings: LoadedSettings,
|
||||
removeDeprecated = false,
|
||||
removeDeprecated = true,
|
||||
): boolean {
|
||||
let anyModified = false;
|
||||
const systemWarnings: Map<LoadableSettingScope, string[]> = new Map();
|
||||
|
||||
Reference in New Issue
Block a user