private string GetProjectRootDirectory() { if (!DynamicGitRepositoryPath.IsNullOrWhiteSpace()) { return(gitVersionOptions.WorkingDirectory); } var gitDirectory = GitRepository.Discover(gitVersionOptions.WorkingDirectory); if (gitDirectory.IsNullOrEmpty()) { throw new DirectoryNotFoundException("Cannot find the .git directory"); } return(new GitRepository(gitDirectory).WorkingDirectory); }
private string?GetDotGitDirectory() { var gitDirectory = !DynamicGitRepositoryPath.IsNullOrWhiteSpace() ? DynamicGitRepositoryPath : GitRepository.Discover(gitVersionOptions.WorkingDirectory); gitDirectory = gitDirectory?.TrimEnd('/', '\\'); if (gitDirectory.IsNullOrEmpty()) { throw new DirectoryNotFoundException("Cannot find the .git directory"); } return(gitDirectory?.Contains(Path.Combine(".git", "worktrees")) == true ? Directory.GetParent(Directory.GetParent(gitDirectory).FullName).FullName : gitDirectory); }