GitVersion
GitVersion copied to clipboard
[Bug] -c is only used if -diag is also enabled
Describe the bug
Calling gitversion with the -c argument always prints out the version for the latest commit. If I add -diag the version for the given commit is returned.
Expected Behavior
gitversion -c 1234 returns version for commit 1234
Actual Behavior
gitversion -c 1234 returns version for the latest commit
Possible Fix
?
Steps to Reproduce
$ docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.11.1-ubuntu.20.04-6.0 /repo -c 17de5e82e927b6eadb017d6f2b93f58c2868a40e
{
"Major": 1,
"Minor": 2,
"Patch": 1,
"PreReleaseTag": "",
"PreReleaseTagWithDash": "",
"PreReleaseLabel": "",
"PreReleaseLabelWithDash": "",
"PreReleaseNumber": null,
"WeightedPreReleaseNumber": 60000,
"BuildMetaData": 5,
"BuildMetaDataPadded": "0005",
"FullBuildMetaData": "5.Branch.main.Sha.385ea85f21b306193dd6dcc4ae7df2c32c0d08d5",
"MajorMinorPatch": "1.2.1",
"SemVer": "1.2.1",
"LegacySemVer": "1.2.1",
"LegacySemVerPadded": "1.2.1",
"AssemblySemVer": "1.2.1.0",
"AssemblySemFileVer": "1.2.1.0",
"FullSemVer": "1.2.1+5",
"InformationalVersion": "1.2.1+5.Branch.main.Sha.385ea85f21b306193dd6dcc4ae7df2c32c0d08d5",
"BranchName": "main",
"EscapedBranchName": "main",
"Sha": "385ea85f21b306193dd6dcc4ae7df2c32c0d08d5",
"ShortSha": "385ea85",
"NuGetVersionV2": "1.2.1",
"NuGetVersion": "1.2.1",
"NuGetPreReleaseTagV2": "",
"NuGetPreReleaseTag": "",
"VersionSourceSha": "4dda6a4ebd70c7b8d0f45621ef3848b3e1d4699c",
"CommitsSinceVersionSource": 5,
"CommitsSinceVersionSourcePadded": "0005",
"UncommittedChanges": 1,
"CommitDate": "2022-11-09"
}
$ docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.11.1-ubuntu.20.04-6.0 /repo -c 17de5e82e927b6eadb017d6f2b93f58c2868a40e -diag
INFO [11/25/22 12:19:37:41] Dumping commit graph:
INFO [11/25/22 12:19:37:44] ERROR: fatal: detected dubious ownership in repository at '/repo'
ERROR: To add an exception for this directory, call:
ERROR:
ERROR: git config --global --add safe.directory /repo
INFO [11/25/22 12:19:37:44] Working directory: /repo
INFO [11/25/22 12:19:37:46] Project root is: /repo/
INFO [11/25/22 12:19:37:46] DotGit directory is: /repo/.git
INFO [11/25/22 12:19:37:46] Branch from build environment:
INFO [11/25/22 12:19:37:49] Searching for specific commit '17de5e82e927b6eadb017d6f2b93f58c2868a40e'
INFO [11/25/22 12:19:37:53] Running against branch: main (17de5e8 bump boards)
INFO [11/25/22 12:19:37:54] Begin: Calculating base versions
INFO [11/25/22 12:19:37:55] Fallback base version: 0.1.0 with commit count source 5fe5ae0a5bcd168230f62ab4f46c6425fa9591c8
INFO [11/25/22 12:19:37:58] Git tag '1.0.0': 1.0.0 with commit count source ba3c26dce7c97d635b67fdded8df2c3f1960db22
INFO [11/25/22 12:19:37:61] Found multiple base versions which will produce the same SemVer (1.0.1), taking oldest source for commit counting (Git tag '1.0.0')
INFO [11/25/22 12:19:37:61] Base version used: Git tag '1.0.0': 1.0.0 with commit count source ba3c26dce7c97d635b67fdded8df2c3f1960db22
INFO [11/25/22 12:19:37:61] End: Calculating base versions (Took: 68.04ms)
INFO [11/25/22 12:19:37:61] 4 commits found between ba3c26d bump dependencies and 17de5e8 bump boards
INFO [11/25/22 12:19:37:61] 4 commits found between ba3c26d bump dependencies and 17de5e8 bump boards
Executing GenerateSetVersionMessage for 'LocalBuild'.
Executing GenerateBuildLogOutput for 'LocalBuild'.
{
"Major": 1,
"Minor": 0,
"Patch": 1,
"PreReleaseTag": "",
"PreReleaseTagWithDash": "",
"PreReleaseLabel": "",
"PreReleaseLabelWithDash": "",
"PreReleaseNumber": null,
"WeightedPreReleaseNumber": 60000,
"BuildMetaData": 4,
"BuildMetaDataPadded": "0004",
"FullBuildMetaData": "4.Branch.main.Sha.17de5e82e927b6eadb017d6f2b93f58c2868a40e",
"MajorMinorPatch": "1.0.1",
"SemVer": "1.0.1",
"LegacySemVer": "1.0.1",
"LegacySemVerPadded": "1.0.1",
"AssemblySemVer": "1.0.1.0",
"AssemblySemFileVer": "1.0.1.0",
"FullSemVer": "1.0.1+4",
"InformationalVersion": "1.0.1+4.Branch.main.Sha.17de5e82e927b6eadb017d6f2b93f58c2868a40e",
"BranchName": "main",
"EscapedBranchName": "main",
"Sha": "17de5e82e927b6eadb017d6f2b93f58c2868a40e",
"ShortSha": "17de5e8",
"NuGetVersionV2": "1.0.1",
"NuGetVersion": "1.0.1",
"NuGetPreReleaseTagV2": "",
"NuGetPreReleaseTag": "",
"VersionSourceSha": "ba3c26dce7c97d635b67fdded8df2c3f1960db22",
"CommitsSinceVersionSource": 4,
"CommitsSinceVersionSourcePadded": "0004",
"UncommittedChanges": 2,
"CommitDate": "2022-04-04"
}
INFO [11/25/22 12:19:37:65] Done writing
$ docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.11.1-ubuntu.20.04-6.0 -version
5.11.1+Branch.support-5.x.Sha.82cbf2c587897ed9906624f3b55f200ac99f084e
Context
I'm evaluating gitversion and wanted to see which versions gitversion would have generated for individual commits in my repository.
Your Environment
- Version Used:
5.11.1+Branch.support-5.x.Sha.82cbf2c587897ed9906624f3b55f200ac99f084e - Operating System and version: Docker container
gittools/gitversion:5.11.1-ubuntu.20.04-6.0on an Ubuntu 18.04 host - Link to your project:
- Link to your CI build (if appropriate):
I'm able to reproduce this on macOS 11.7.1. Seems like our test coverage for the -c argument is poor. I don't use the -c argument myself, so I don't have much incentive to fix this, but I would warmly welcome a PR that adds tests and fixes this bug.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.