Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using .git directory instead of gitdir redirect in submodules. #653

Merged
merged 6 commits into from Aug 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Microsoft.Build.Tasks.Git/GitDataReader/GitRepository.cs
Expand Up @@ -209,6 +209,15 @@ public static GitRepository OpenRepository(GitRepositoryLocation location, GitEn
/// <returns>Null if the HEAD tip reference can't be resolved.</returns>
internal string? ReadSubmoduleHeadCommitSha(string submoduleWorkingDirectoryFullPath)
{
// submodules don't usually have their own .git directories but can when Arcade uberclone
crummel marked this conversation as resolved.
Show resolved Hide resolved
// was used. Handle this case first since the other case throws.
crummel marked this conversation as resolved.
Show resolved Hide resolved
var dotGitPath = Path.Combine(submoduleWorkingDirectoryFullPath, GitDirName);
crummel marked this conversation as resolved.
Show resolved Hide resolved
if (IsGitDirectory(dotGitPath, out var directSubmoduleGitDirectory))
{
var submoduleGitDirResolver = new GitReferenceResolver(directSubmoduleGitDirectory, submoduleWorkingDirectoryFullPath);
return submoduleGitDirResolver.ResolveHeadReference();
}

var gitDirectory = ReadDotGitFile(Path.Combine(submoduleWorkingDirectoryFullPath, GitDirName));
if (!IsGitDirectory(gitDirectory, out var commonDirectory))
{
Expand Down