Skip to content

Commit 32c309c

Browse files
committed
support no git repo
1 parent b33e162 commit 32c309c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

MyAppsContext.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static string GetProjectStructure(string path, int indent = 0)
1818

1919
var entries = Directory.EnumerateFileSystemEntries(path)
2020
.OrderBy(e => e)
21-
.Where(e => !FileChecker.ShouldSkip(new FileInfo(e), GitRepoRoot))
21+
.Where(e => GitRepoRoot == null || !FileChecker.ShouldSkip(new FileInfo(e), GitRepoRoot))
2222
.ToList();
2323

2424
var sb = new StringBuilder();
@@ -61,10 +61,15 @@ public static string GetFileContents(string path)
6161
}));
6262
}
6363

64-
private static string FindGitRepoRoot(string path) =>
65-
Directory.Exists(Path.Combine(path, ".git"))
64+
private static string FindGitRepoRoot(string path)
65+
{
66+
if (string.IsNullOrEmpty(path) || !Directory.Exists(path))
67+
return null;
68+
69+
return Directory.Exists(Path.Combine(path, ".git"))
6670
? path
6771
: string.IsNullOrEmpty(path) ? null : FindGitRepoRoot(Path.GetDirectoryName(path));
72+
}
6873

6974
private static void WriteProgress(int current, int total)
7075
{

0 commit comments

Comments
 (0)