Skip to content

Commit 52aeec2

Browse files
committed
Issue #2165 WorkingTree uses incorrect commit.
The repository opened for use to do versioning should be the Project Directory, not the DotGit directory. Also fixes it so the project directory used is based on the DynamicGitDirectory if it is a dynamic repo.
1 parent 3f5392e commit 52aeec2

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/GitVersionCore/Extensions/ArgumentExtensions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ public static string GetDotGitDirectory(this Arguments arguments)
2626

2727
public static string GetProjectRootDirectory(this Arguments arguments)
2828
{
29-
if (arguments.IsDynamicGitRepository())
30-
{
31-
return arguments.GetWorkingDirectory();
32-
}
33-
34-
var dotGitDirectory = Repository.Discover(arguments.GetWorkingDirectory());
29+
var dotGitDirectory = Repository.Discover(arguments.IsDynamicGitRepository() ? arguments.DynamicGitRepositoryPath : arguments.GetWorkingDirectory());
3530

3631
if (string.IsNullOrEmpty(dotGitDirectory))
3732
throw new DirectoryNotFoundException($"Can't find the .git directory in {dotGitDirectory}");

src/GitVersionCore/GitVersionCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private VersionVariables ExecuteInternal(Arguments arguments)
6161
{
6262
var configuration = configProvider.Provide(overrideConfig: arguments.OverrideConfig);
6363

64-
using var repo = new Repository(arguments.GetDotGitDirectory());
64+
using var repo = new Repository(arguments.GetProjectRootDirectory());
6565
var targetBranch = repo.GetTargetBranch(arguments.TargetBranch);
6666
var gitVersionContext = new GitVersionContext(repo, log, targetBranch, configuration, commitId: arguments.CommitId);
6767
var semanticVersion = nextVersionCalculator.FindVersion(gitVersionContext);

0 commit comments

Comments
 (0)