Merge pull request #800 from patha454/patch-1

Exclude `.git` from search paths.
This commit is contained in:
Jan Jurzitza 2020-03-27 08:02:09 +01:00 committed by GitHub
commit f628524b9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -84,7 +84,8 @@ string[] expandArgs(string[] args)
{ {
import std.file : isFile, FileException, dirEntries, SpanMode; import std.file : isFile, FileException, dirEntries, SpanMode;
import std.algorithm.iteration : map; import std.algorithm.iteration : map;
import std.algorithm.searching : endsWith; import std.algorithm.searching : endsWith, canFind;
import std.path : dirSeparator;
// isFile can throw if it's a broken symlink. // isFile can throw if it's a broken symlink.
bool isFileSafe(T)(T a) bool isFileSafe(T)(T a)
@ -105,7 +106,7 @@ string[] expandArgs(string[] args)
else else
foreach (item; dirEntries(arg, SpanMode.breadth).map!(a => a.name)) foreach (item; dirEntries(arg, SpanMode.breadth).map!(a => a.name))
{ {
if (isFileSafe(item) && (item.endsWith(`.d`) || item.endsWith(`.di`))) if (isFileSafe(item) && (item.endsWith(`.d`) || item.endsWith(`.di`)) && !item.canFind(dirSeparator ~ '.'))
rVal ~= item; rVal ~= item;
else else
continue; continue;