Skip to content

Commit 29f67ca

Browse files
committed
If the .git folder can't be found throw an informative DirectoryNotFoundException, instead of just sending it to Directory.GetParent(), because its exception is hard to debug.
1 parent d7c9d06 commit 29f67ca

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/GitVersionCore/GitPreparer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ public string GetDotGitDirectory()
9797
public string GetProjectRootDirectory()
9898
{
9999
if (IsDynamicGitRepository)
100-
return targetPath;
100+
return this.targetPath;
101101

102-
return Directory.GetParent(GitDirFinder.TreeWalkForDotGitDir(targetPath)).FullName;
102+
var gitDir = GitDirFinder.TreeWalkForDotGitDir(this.targetPath);
103+
104+
if (String.IsNullOrEmpty(gitDir))
105+
throw new DirectoryNotFoundException("Can't find the .git directory in " + targetPath);
106+
107+
return Directory.GetParent(gitDir).FullName;
103108
}
104109

105110
static string CreateDynamicRepository(string targetPath, Authentication authentication, string repositoryUrl, string targetBranch, bool noFetch)

0 commit comments

Comments
 (0)