From 55c2681235d0240472472c7667c5e800ba02fcb1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 28 Mar 2021 18:44:17 -0600 Subject: [PATCH] Produce absolute path per api doc when reading version file Fixes #573 --- src/NerdBank.GitVersioning/LibGit2/LibGit2VersionFile.cs | 6 ++++-- src/NerdBank.GitVersioning/Managed/ManagedVersionFile.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NerdBank.GitVersioning/LibGit2/LibGit2VersionFile.cs b/src/NerdBank.GitVersioning/LibGit2/LibGit2VersionFile.cs index f68295305..ae077ec34 100644 --- a/src/NerdBank.GitVersioning/LibGit2/LibGit2VersionFile.cs +++ b/src/NerdBank.GitVersioning/LibGit2/LibGit2VersionFile.cs @@ -59,7 +59,8 @@ internal LibGit2VersionFile(LibGit2Context context) if (result is object) { - actualDirectory = searchDirectory; + IBelongToARepository commitAsRepoMember = commit; + actualDirectory = Path.Combine(commitAsRepoMember.Repository.Info.WorkingDirectory, searchDirectory); return result; } } @@ -125,7 +126,8 @@ internal LibGit2VersionFile(LibGit2Context context) } else if (result is object) { - actualDirectory = searchDirectory; + IBelongToARepository commitAsRepoMember = commit; + actualDirectory = Path.Combine(commitAsRepoMember.Repository.Info.WorkingDirectory, searchDirectory); return result; } } diff --git a/src/NerdBank.GitVersioning/Managed/ManagedVersionFile.cs b/src/NerdBank.GitVersioning/Managed/ManagedVersionFile.cs index 8db7c3319..06e9e8ee2 100644 --- a/src/NerdBank.GitVersioning/Managed/ManagedVersionFile.cs +++ b/src/NerdBank.GitVersioning/Managed/ManagedVersionFile.cs @@ -85,7 +85,7 @@ public ManagedVersionFile(GitContext context) if (result is object) { finalResult = result; - actualDirectory = searchDirectory; + actualDirectory = Path.Combine(this.Context.WorkingTreePath, searchDirectory); } } @@ -158,7 +158,7 @@ public ManagedVersionFile(GitContext context) if (result is object) { - actualDirectory = searchDirectory; + actualDirectory = Path.Combine(this.Context.WorkingTreePath, searchDirectory); finalResult = result; } }