settings: Remove auxiliary Content types where possible (#16744)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-10 22:59:10 -04:00 committed by GitHub
parent 8f28445612
commit ccf6f27b8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 843 additions and 696 deletions

View file

@ -25,7 +25,8 @@ impl WorktreeSettings {
}
}
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct WorktreeSettingsContent {
/// Completely ignore files matching globs from `file_scan_exclusions`
///
@ -39,12 +40,42 @@ pub struct WorktreeSettingsContent {
/// "**/.classpath",
/// "**/.settings"
/// ]
#[serde(default)]
pub file_scan_exclusions: Option<Vec<String>>,
pub file_scan_exclusions: Vec<String>,
/// Treat the files matching these globs as `.env` files.
/// Default: [ "**/.env*" ]
pub private_files: Option<Vec<String>>,
pub private_files: Vec<String>,
}
impl Default for WorktreeSettingsContent {
fn default() -> Self {
Self {
private_files: [
"**/.env*",
"**/*.pem",
"**/*.key",
"**/*.cert",
"**/*.crt",
"**/secrets.yml",
]
.into_iter()
.map(str::to_owned)
.collect(),
file_scan_exclusions: [
"**/.git",
"**/.svn",
"**/.hg",
"**/CVS",
"**/.DS_Store",
"**/Thumbs.db",
"**/.classpath",
"**/.settings",
]
.into_iter()
.map(str::to_owned)
.collect(),
}
}
}
impl Settings for WorktreeSettings {
@ -57,8 +88,8 @@ impl Settings for WorktreeSettings {
_: &mut AppContext,
) -> anyhow::Result<Self> {
let result: WorktreeSettingsContent = sources.json_merge()?;
let mut file_scan_exclusions = result.file_scan_exclusions.unwrap_or_default();
let mut private_files = result.private_files.unwrap_or_default();
let mut file_scan_exclusions = result.file_scan_exclusions;
let mut private_files = result.private_files;
file_scan_exclusions.sort();
private_files.sort();
Ok(Self {

View file

@ -673,7 +673,7 @@ async fn test_rescan_with_gitignore(cx: &mut TestAppContext) {
cx.update(|cx| {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |project_settings| {
project_settings.file_scan_exclusions = Some(Vec::new());
project_settings.file_scan_exclusions = Vec::new();
});
});
});
@ -910,7 +910,7 @@ async fn test_file_scan_exclusions(cx: &mut TestAppContext) {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |project_settings| {
project_settings.file_scan_exclusions =
Some(vec!["**/foo/**".to_string(), "**/.DS_Store".to_string()]);
vec!["**/foo/**".to_string(), "**/.DS_Store".to_string()];
});
});
});
@ -945,8 +945,7 @@ async fn test_file_scan_exclusions(cx: &mut TestAppContext) {
cx.update(|cx| {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |project_settings| {
project_settings.file_scan_exclusions =
Some(vec!["**/node_modules/**".to_string()]);
project_settings.file_scan_exclusions = vec!["**/node_modules/**".to_string()];
});
});
});
@ -1009,11 +1008,11 @@ async fn test_fs_events_in_exclusions(cx: &mut TestAppContext) {
cx.update(|cx| {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |project_settings| {
project_settings.file_scan_exclusions = Some(vec![
project_settings.file_scan_exclusions = vec![
"**/.git".to_string(),
"node_modules/".to_string(),
"build_output".to_string(),
]);
];
});
});
});