예제 #1
0
    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);
    }
예제 #2
0
    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);
    }