Skip to content

[ISSUE]: Sometimes the gitversion uses the wrong commit without error messages #4622

@sebastiano-man

Description

@sebastiano-man

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.Tool

GitVersion version

6.1.0

Operating system

Linux

What are you seeing?

Im having this non deterministic issue in which gitversion sometimes takes the wrong commit to running against.
Im running in a Gitlab job the following command:

/tools/dotnet-gitversion /c $CI_COMMIT_SHA /config .gitlab/versioning/GitVersion.yml /output buildserver $VERBOSITYSETTING

CI_COMMIT_SHA is the sha of the commit to use to run the versioning script

This is my commit history:

14 Jul 2025 17:24:27 +0200 4c3e6f41f7a latest commit message 
14 Jul 2025 15:24:27 +0000 390f129e6a7 second to last commit message
...

I get this output:

INFO [25-07-14 15:25:02:07] Searching for specific commit '4c3e6f41f7a6c4b5d7de3c339e6594e1ccd57f3c'
INFO [25-07-14 15:25:05:12] Getting tagged semantic versions. TagPrefix: [r]? and Format: Strict
INFO [25-07-14 15:25:06:45] Running against branch: develop ('390f129' - second to last commit message)
INFO [25-07-14 15:25:06:46] -< Begin: Fetching the base versions for version calculation... >-

As you can see gitversion is running against commit 390f129 while the commit i have specified is 4c3e6f41.

The weird thing is that gitversion is not printing any error message like Commit 390f129 specified but not found or Using latest commit on specified branch (because the commit exists).

The other weird thing is that this does not happen all the time; this makes me think the bug is somehow related to GetCommitsPriorTo incorrectly sorting/removing the latest commit (4c3e6f41f7a)

What is expected?

I expect that gitversion uses the specified commit to compute the version

Steps to Reproduce

Its not easy to reproduce this because, as i was explaining earlier, this issue does not happen all the time and i have not yet understood what is causing the issue (maybe the timezones?)

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions