feat: log progress ignoring files listed in .gitignore, .ignore and .rgignore
All checks were successful
Test / test (push) Successful in 1m23s
All checks were successful
Test / test (push) Successful in 1m23s
This commit is contained in:
parent
708bcb0b91
commit
ed0b1c4535
2 changed files with 12 additions and 23 deletions
|
@ -8,3 +8,4 @@ anyhow = "1.0"
|
||||||
regex = "1.10"
|
regex = "1.10"
|
||||||
ureq = "2.10"
|
ureq = "2.10"
|
||||||
kxio = "1.2"
|
kxio = "1.2"
|
||||||
|
ignore = "0.4"
|
||||||
|
|
34
src/main.rs
34
src/main.rs
|
@ -25,12 +25,14 @@ fn main() -> Result<()> {
|
||||||
println!("Prefix: {}", config.prefix_pattern);
|
println!("Prefix: {}", config.prefix_pattern);
|
||||||
println!("Issues: {}", config.issue_pattern);
|
println!("Issues: {}", config.issue_pattern);
|
||||||
|
|
||||||
// TODO: scan files in workdir
|
|
||||||
// TODO: ignore files listed in .rgignore .ignore or .gitignore
|
|
||||||
|
|
||||||
let mut found_markers = FoundMarkers::default();
|
let mut found_markers = FoundMarkers::default();
|
||||||
|
|
||||||
scan_files(&config, &mut found_markers)?;
|
for file in ignore::Walk::new(config.fs.base()).flatten() {
|
||||||
|
let path = file.path();
|
||||||
|
if config.fs.path_is_file(path)? {
|
||||||
|
scan_file(path, &config, &mut found_markers)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
println!("{found_markers:?}");
|
println!("{found_markers:?}");
|
||||||
|
|
||||||
|
@ -82,30 +84,16 @@ impl FoundMarkers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan_files(config: &Config, found_markers: &mut FoundMarkers) -> Result<()> {
|
fn scan_file(file: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> {
|
||||||
scan_dir(config.fs.base(), config, found_markers)
|
println!("file: {}", file.to_string_lossy());
|
||||||
}
|
|
||||||
|
|
||||||
fn scan_dir(dir: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> {
|
|
||||||
let read_dir = config.fs.dir_read(dir)?;
|
|
||||||
for entry in read_dir {
|
|
||||||
match entry? {
|
|
||||||
DirItem::File(file) => scan_file(&file, config, found_markers),
|
|
||||||
DirItem::Dir(dir) => scan_dir(&dir, config, found_markers),
|
|
||||||
DirItem::SymLink(_) | DirItem::Fifo(_) | DirItem::Unsupported(_) => Ok(()),
|
|
||||||
}?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn scan_file(path: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> {
|
|
||||||
config
|
config
|
||||||
.fs
|
.fs
|
||||||
.file_read_to_string(path)?
|
.file_read_to_string(file)?
|
||||||
.lines()
|
.lines()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(n, line)| prefix_match(n, line, path, config))
|
.filter_map(|(n, line)| prefix_match(n, line, file, config))
|
||||||
.for_each(|marker| {
|
.for_each(|marker| {
|
||||||
|
println!("- {}", marker.line.value);
|
||||||
if let Some(issue) = config
|
if let Some(issue) = config
|
||||||
.issue_pattern
|
.issue_pattern
|
||||||
.find(&marker.line.value)
|
.find(&marker.line.value)
|
||||||
|
|
Loading…
Reference in a new issue