Skip to content

Commit

Permalink
dnGrep#1076 - gitignore: add the .git directory to the set of directo…
Browse files Browse the repository at this point in the history
…ries to ignore and .gitignore to the set of files to ignore
  • Loading branch information
doug24 committed Mar 15, 2024
1 parent 9c914eb commit eb19d4f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dnGREP.Common/GitUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ public Gitignore()

public Gitignore(string path, List<string> list)
{
// add .git to the directories to ignore
string git = Path.Combine(path, ".git");
if (Directory.Exists(git))
{
directories.Add(git);
}
// add .gitignore to the files to ignore
string gitignore = Path.Combine(path, ".gitignore");
if (File.Exists(gitignore))
{
files.Add(gitignore);
}

foreach (var item in list.Where(s => !s.StartsWith("..", StringComparison.OrdinalIgnoreCase) &&
s.EndsWith(gitSeparator, StringComparison.CurrentCulture))
.Select(s => Path.Combine(path, s.Replace(gitSeparatorChar, Path.DirectorySeparatorChar)
Expand Down

0 comments on commit eb19d4f

Please sign in to comment.