Skip to content

Commit

Permalink
Pass a path to directory to GitignoreBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed May 26, 2020
1 parent c995c46 commit 6b1063d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::path::Path;

use ignore::gitignore::{Gitignore, GitignoreBuilder};

use crate::config::{FileName, IgnoreList};
Expand All @@ -8,7 +10,11 @@ pub(crate) struct IgnorePathSet {

impl IgnorePathSet {
pub(crate) fn from_ignore_list(ignore_list: &IgnoreList) -> Result<Self, ignore::Error> {
let mut ignore_builder = GitignoreBuilder::new(ignore_list.rustfmt_toml_path());
let root = ignore_list
.rustfmt_toml_path()
.parent()
.unwrap_or(&Path::new(""));
let mut ignore_builder = GitignoreBuilder::new(root);

for ignore_path in ignore_list {
ignore_builder.add_line(None, &ignore_path.to_string_lossy())?;
Expand Down

0 comments on commit 6b1063d

Please sign in to comment.