Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDavison committed Jan 31, 2024
1 parent 4fae7f6 commit 075fd8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,17 @@ fn get_dirs_from_config() -> Result<(Vec<PathBuf>, Vec<PathBuf>)> {
return Err(anyhow!("No ~/.repoutilrc, or passed dirs"));
}

let contents = std::fs::read_to_string(p)?;
let (inc, exc): (Vec<_>, Vec<_>) = contents.lines().partition(|p| !p.starts_with('!'));
Ok((
inc.iter()
.map(|x| PathBuf::from(tilde(x).to_string()))
.collect(),
exc.iter()
.map(|x| PathBuf::from(tilde(&x[1..]).to_string()))
.collect(),
))
let mut includes = Vec::new();
let mut excludes = Vec::new();
for line in std::fs::read_to_string(p)?.lines() {
if line.starts_with('!') {
// Strip 'exclusion-marking' ! from start of path, and add to excludes list
excludes.push(PathBuf::from(tilde(&line[1..]).to_string()));
} else {
includes.push(PathBuf::from(tilde(&line).to_string()));
}
}
Ok((includes, excludes))
}

// Get every repo from subdirs of `dir`
Expand Down

0 comments on commit 075fd8f

Please sign in to comment.