aboutsummaryrefslogtreecommitdiff
path: root/bin/src/config.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-05-01 16:12:12 +0100
committerAkshay <[email protected]>2022-05-01 16:12:12 +0100
commit53b454cd6acba89fe6b5bb39df431afa28a6ee13 (patch)
treecd70026307c98a33c6ce25b0849d9e297e5bf842 /bin/src/config.rs
parent448e6f2096b855bee1464c514dfb73477fb39774 (diff)
add `ignore` to statix.tomlv0.5.5
Diffstat (limited to 'bin/src/config.rs')
-rw-r--r--bin/src/config.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/bin/src/config.rs b/bin/src/config.rs
index 07b3f17..d3c3e91 100644
--- a/bin/src/config.rs
+++ b/bin/src/config.rs
@@ -65,7 +65,7 @@ pub struct Check {
65} 65}
66 66
67impl Check { 67impl Check {
68 pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { 68 pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> {
69 if self.streaming { 69 if self.streaming {
70 use std::io::{self, BufRead}; 70 use std::io::{self, BufRead};
71 let src = io::stdin() 71 let src = io::stdin()
@@ -76,7 +76,8 @@ impl Check {
76 .join("\n"); 76 .join("\n");
77 Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) 77 Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes()))
78 } else { 78 } else {
79 let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; 79 let all_ignores = dbg!([self.ignore.as_slice(), extra_ignores].concat());
80 let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?;
80 let files = dirs::walk_nix_files(ignore, &self.target)?; 81 let files = dirs::walk_nix_files(ignore, &self.target)?;
81 vfs(files.collect::<Vec<_>>()) 82 vfs(files.collect::<Vec<_>>())
82 } 83 }
@@ -117,7 +118,7 @@ pub enum FixOut {
117} 118}
118 119
119impl Fix { 120impl Fix {
120 pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { 121 pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> {
121 if self.streaming { 122 if self.streaming {
122 use std::io::{self, BufRead}; 123 use std::io::{self, BufRead};
123 let src = io::stdin() 124 let src = io::stdin()
@@ -128,7 +129,8 @@ impl Fix {
128 .join("\n"); 129 .join("\n");
129 Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) 130 Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes()))
130 } else { 131 } else {
131 let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; 132 let all_ignores = [self.ignore.as_slice(), extra_ignores].concat();
133 let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?;
132 let files = dirs::walk_nix_files(ignore, &self.target)?; 134 let files = dirs::walk_nix_files(ignore, &self.target)?;
133 vfs(files.collect::<Vec<_>>()) 135 vfs(files.collect::<Vec<_>>())
134 } 136 }
@@ -260,16 +262,22 @@ impl FromStr for OutFormat {
260pub struct ConfFile { 262pub struct ConfFile {
261 #[serde(default = "Vec::new")] 263 #[serde(default = "Vec::new")]
262 disabled: Vec<String>, 264 disabled: Vec<String>,
265
263 nix_version: Option<String>, 266 nix_version: Option<String>,
267
268 #[serde(default = "Vec::new")]
269 pub ignore: Vec<String>,
264} 270}
265 271
266impl Default for ConfFile { 272impl Default for ConfFile {
267 fn default() -> Self { 273 fn default() -> Self {
268 let disabled = vec![]; 274 let disabled = Default::default();
269 let nix_version = None; 275 let ignore = Default::default();
276 let nix_version = Default::default();
270 Self { 277 Self {
271 disabled, 278 disabled,
272 nix_version, 279 nix_version,
280 ignore,
273 } 281 }
274 } 282 }
275} 283}
@@ -298,9 +306,11 @@ impl ConfFile {
298 let ideal_config = { 306 let ideal_config = {
299 let disabled = vec![]; 307 let disabled = vec![];
300 let nix_version = Some(utils::default_nix_version()); 308 let nix_version = Some(utils::default_nix_version());
309 let ignore = vec![".direnv".into()];
301 Self { 310 Self {
302 disabled, 311 disabled,
303 nix_version, 312 nix_version,
313 ignore,
304 } 314 }
305 }; 315 };
306 toml::ser::to_string_pretty(&ideal_config).unwrap() 316 toml::ser::to_string_pretty(&ideal_config).unwrap()