Skip to content

Commit 892cb2a

Browse files
committed
♻️ Simplify .gitignore directory keying in add_path
Refactored the add_path method to directly use the provided path as the key for .gitignore ownership, removing unnecessary parent directory lookup.
1 parent b52446c commit 892cb2a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cli/src/command/commons.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ impl Ignore {
162162

163163
#[inline]
164164
pub(crate) fn add_path(&mut self, path: impl AsRef<Path>) {
165-
let gitignore_path = path.as_ref().join(".gitignore");
165+
let path = path.as_ref();
166+
debug_assert!(path.is_dir());
167+
let gitignore_path = path.join(".gitignore");
166168
if gitignore_path.exists() {
167169
let (ig, _) = ignore::gitignore::Gitignore::new(&gitignore_path);
168170
// Key by the directory that owns this .gitignore
169-
if let Some(dir) = gitignore_path.parent() {
170-
self.by_dir.insert(dir.to_path_buf(), ig);
171-
}
171+
self.by_dir.insert(path.to_path_buf(), ig);
172172
}
173173
}
174174
}

0 commit comments

Comments
 (0)