Skip to content

Commit b0e1b97

Browse files
committed
feat: ignore files globally
1 parent 73e8f67 commit b0e1b97

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ either be `all`, the wanted OS (`macos` | `linux`) or a custom command.
1515
Clink is configured in a `clink.yaml` file.
1616

1717
```yaml
18+
ignore: # ignore file or folder names, applies to all directories and subdirectories
19+
- .DS_Store
20+
1821
features:
1922
- slug: all
2023
enabled: all # all, macos, linux or custom command

clink.example.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
ignore: # optional
2+
- ".git" # only needed if you have a submodule in your tree
3+
- ".DS_Store"
4+
15
features:
26
- slug: all
37
target: ~/.config

src/link.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ impl LinkGroup {
2929
sources: Vec::new(),
3030
}
3131
}
32-
pub fn add_source(&mut self, source: &PathBuf) -> Result<(), Vec<PathBuf>> {
33-
let source_files = get_all_paths(source);
32+
pub fn add_source(&mut self, source: &PathBuf, ignore: &Vec<String>) -> Result<(), Vec<PathBuf>> {
33+
let source_files = get_all_paths(source, ignore);
3434

3535
let sources = source_files
3636
.iter()
@@ -139,9 +139,10 @@ impl LinkGroup {
139139
Ok(())
140140
}
141141
}
142-
pub fn get_all_paths(source: &Path) -> HashSet<PathBuf> {
142+
pub fn get_all_paths(source: &Path, ignore: &Vec<String>) -> HashSet<PathBuf> {
143143
walkdir::WalkDir::new(source)
144144
.into_iter()
145+
.filter_entry(|e| !ignore.contains(&e.file_name().to_string_lossy().to_string()))
145146
.filter_map(|e| e.ok())
146147
.filter(|e| e.file_type().is_file())
147148
.map(|e| e.path().to_path_buf())

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod link;
99

1010
#[derive(Debug, serde::Deserialize)]
1111
struct Config {
12+
ignore: Option<Vec<String>>,
1213
features: feature::FeatureList,
1314
}
1415

@@ -80,6 +81,8 @@ fn run(action: Action) {
8081
})
8182
.collect::<Vec<_>>();
8283

84+
let ignore = config.ignore.unwrap_or_default();
85+
8386
// create LinkGroup for each target
8487
let target_links =
8588
source_features
@@ -108,7 +111,7 @@ fn run(action: Action) {
108111
};
109112

110113
// add current directory to LinkGroup
111-
match entry.add_source(source) {
114+
match entry.add_source(source, &ignore) {
112115
Err(e) => panic!("conflicts in target {:?}: {:?}", target, e),
113116
Ok(_) => acc,
114117
}

0 commit comments

Comments
 (0)