Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Fix auto dectection of .git repo #199

Merged
merged 1 commit into from
Apr 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/GitLink/Linker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ public static class Linker
{
if (repositoryDirectory == null)
{
Log.Error($"Couldn't auto detect git repo from PDB: {pdbPath}. Please use -baseDir to manually set it.");
return false;
repositoryDirectory = GetRepositoryFromFiles(new[] { pdbPath });
if (repositoryDirectory == null)
{
Log.Error($"Couldn't auto detect git repo from PDB: {pdbPath}. Please use -baseDir to manually set it.");
return false;
}
}

if (_sourceFilesList == null)
Expand All @@ -87,11 +91,10 @@ public static class Linker

if (repositoryDirectory == null)
{
var sourceFile = _sourceFilesList.First();
repositoryDirectory = GitDirFinder.TreeWalkForGitDir(_sourceFilesList.First());
repositoryDirectory = GetRepositoryFromFiles(new[] { pdbPath }.Union(_sourceFilesList));
if (repositoryDirectory == null)
{
Log.Error($"Couldn't auto detect git repo from source file: {sourceFile}. Please use -baseDir to manually set it.");
Log.Error("Couldn't auto detect git repo. Please use -baseDir to manually set it.");
return false;
}
}
Expand Down Expand Up @@ -230,6 +233,21 @@ public static class Linker
return true;
}

private static string GetRepositoryFromFiles(IEnumerable<string> files)
{
foreach (var file in files)
{
var repositoryDirectory = GitDirFinder.TreeWalkForGitDir(Path.GetDirectoryName(file));
if (repositoryDirectory != null)
{
Log.Debug($"git repo detected: {repositoryDirectory}");
return repositoryDirectory;
}
}

return null;
}

private static List<string> GetSourceFilesFromPdb(string pdbPath, bool verifyFiles)
{
using (var pdb = new PdbFile(pdbPath))
Expand Down