Merge pull request #437 from MarcoRossignoli/fixsourcelinkbug

[Bug fix]Fix "/p:UseSourceLink=true" bug
This commit is contained in:
Toni Solarin-Sodara
2019-05-28 16:03:17 +01:00
committed by GitHub
+11 -3
View File
@@ -339,10 +339,18 @@ namespace Coverlet.Core
string key = sourceLinkDocument.Key;
if (Path.GetFileName(key) != "*") continue;
if (!Path.GetDirectoryName(document).StartsWith(Path.GetDirectoryName(key) + Path.DirectorySeparatorChar))
continue;
string directoryDocument = Path.GetDirectoryName(document);
string sourceLinkRoot = Path.GetDirectoryName(key);
string relativePath = "";
var relativePath = Path.GetDirectoryName(document).Substring(Path.GetDirectoryName(key).Length + 1);
// if document is on repo root we skip relative path calculation
if (directoryDocument != sourceLinkRoot)
{
if (!directoryDocument.StartsWith(sourceLinkRoot + Path.DirectorySeparatorChar))
continue;
relativePath = directoryDocument.Substring(sourceLinkRoot.Length + 1);
}
if (relativePathOfBestMatch.Length == 0)
{