Skip to content

Worktrees incorrectly calculated #2165

@tpaxatb

Description

@tpaxatb

When running gitversion within a worktree, the version that is calculated is against the HEAD of the main repository rather than the HEAD of the worktree itself. This is caused by the fact that the Repository object that is created is using the return from the main git directory rather than the worktree path.

I don't know how to fix this, because if I change it to either GetWorkingDirectory or GetProjectDirectory (either will work), the tests:
GitVersionCore.Tests.DynamicRepositoryTests.FindsVersionInDynamicRepo
DynamicRepositoriesShouldNotErrorWithFailedToFindGitDirectory
fail.

Obviously, the GetDotGitDirectory needs to return the actual directory so that caching works, however when in a worktree, the repository object that is created needs to be based on the worktree.

See also #1063

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions