GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[ISSUE]: remote compute with /url and /b

Open xpicio opened this issue 1 year ago • 3 comments

Prerequisites

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

GitVersion package

GitVersion.Tool

GitVersion version

6.0.1 and 6.0.2

Operating system

macOS

What are you seeing?

Hello, i tried upgrading gitversion 5.12 to 6.0.2 to use this new feature #3453, but there seems to be an issue using the parameters /url and /b. I also tried computing the version locally, and that works fine. The command docker run --rm -v $(pwd):/repo gittools/gitversion:6.0.2 /repo works correctly, but I rely heavily on the remote mode.

6.0.1 on develop with remote repository:

❯ docker run --rm gittools/gitversion:6.0.1 /url https://github.com/xpicio/compute-version.git /b develop
INFO [24-09-26 15:37:17:58] Applicable build agent found: 'LocalBuild'.
INFO [24-09-26 15:37:17:61] Working directory: /tools
INFO [24-09-26 15:37:17:62] Project root is: /tools
INFO [24-09-26 15:37:17:62] DotGit directory is: /tmp/compute-version/.git
INFO [24-09-26 15:37:17:62] Branch from build environment: develop
INFO [24-09-26 15:37:17:62] -< Begin: Creating dynamic repository at '/tmp/compute-version/.git' >-
  INFO [24-09-26 15:37:17:63] -< Begin: Cloning repository from url 'https://github.com/xpicio/compute-version.git' >-
    INFO [24-09-26 15:37:18:02] Returned path after repository clone: /tmp/compute-version/.git/
  INFO [24-09-26 15:37:18:02] -< End: Cloning repository from url 'https://github.com/xpicio/compute-version.git' (Took: 392.82ms) >-
INFO [24-09-26 15:37:18:02] -< End: Creating dynamic repository at '/tmp/compute-version/.git' (Took: 395.21ms) >-
INFO [24-09-26 15:37:18:02] -< Begin: Normalizing git directory for branch 'develop' >-
INFO [24-09-26 15:37:18:03] -< End: Normalizing git directory for branch 'develop' (Took: 6.64ms) >-
ERROR [24-09-26 15:37:18:05] An unexpected error occurred:
System.ArgumentNullException: Value cannot be null. (Parameter 'path')
   at LibGit2Sharp.Core.Ensure.ArgumentNotNull(Object argumentValue, String argumentName) in /_/LibGit2Sharp/Core/Ensure.cs:line 24
   at LibGit2Sharp.Core.Ensure.ArgumentNotNullOrEmptyString(String argumentValue, String argumentName) in /_/LibGit2Sharp/Core/Ensure.cs:line 50
   at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter) in /_/LibGit2Sharp/Repository.cs:line 149
   at LibGit2Sharp.Repository..ctor(String path) in /_/LibGit2Sharp/Repository.cs:line 70
   at GitVersion.Git.GitRepository.<>c__DisplayClass23_0.<DiscoverRepository>b__0() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs:line 37
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at GitVersion.Git.GitRepository.get_RepositoryInstance() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs:line 15
   at GitVersion.Git.GitRepository.get_Head() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs:line 24
   at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 153
   at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 131
   at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 55
   at GitVersion.GitPreparer.Prepare() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 45
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in /_/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 35
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 66
INFO [24-09-26 15:37:18:05] Attempting to show the current git graph (please include in issue):
INFO [24-09-26 15:37:18:05] Showing max of 100 commits
INFO [24-09-26 15:37:18:08] ERROR: fatal: not a git repository (or any of the parent directories): .git

6.0.2 on develop with remote repository:

❯ docker run --rm gittools/gitversion:6.0.2 /url https://github.com/xpicio/compute-version.git /b develop
INFO [24-09-26 15:24:55:68] Applicable build agent found: 'LocalBuild'.
INFO [24-09-26 15:24:55:71] Working directory: /tools
INFO [24-09-26 15:24:55:71] Project root is: /tools
INFO [24-09-26 15:24:55:71] DotGit directory is: /tmp/compute-version/.git
INFO [24-09-26 15:24:55:71] Branch from build environment: develop
INFO [24-09-26 15:24:55:71] -< Begin: Creating dynamic repository at '/tmp/compute-version/.git' >-
  INFO [24-09-26 15:24:55:72] -< Begin: Cloning repository from url 'https://github.com/xpicio/compute-version.git' >-
    INFO [24-09-26 15:24:56:07] Returned path after repository clone: /tmp/compute-version/.git/
  INFO [24-09-26 15:24:56:07] -< End: Cloning repository from url 'https://github.com/xpicio/compute-version.git' (Took: 355.67ms) >-
INFO [24-09-26 15:24:56:07] -< End: Creating dynamic repository at '/tmp/compute-version/.git' (Took: 357.94ms) >-
INFO [24-09-26 15:24:56:07] -< Begin: Normalizing git directory for branch 'develop' >-
INFO [24-09-26 15:24:56:08] -< End: Normalizing git directory for branch 'develop' (Took: 3.53ms) >-
ERROR [24-09-26 15:24:56:09] An unexpected error occurred:
System.ArgumentNullException: Value cannot be null. (Parameter 'path')
   at LibGit2Sharp.Core.Ensure.ArgumentNotNull(Object argumentValue, String argumentName) in /_/LibGit2Sharp/Core/Ensure.cs:line 24
   at LibGit2Sharp.Core.Ensure.ArgumentNotNullOrEmptyString(String argumentValue, String argumentName) in /_/LibGit2Sharp/Core/Ensure.cs:line 50
   at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter) in /_/LibGit2Sharp/Repository.cs:line 149
   at LibGit2Sharp.Repository..ctor(String path) in /_/LibGit2Sharp/Repository.cs:line 70
   at GitVersion.Git.GitRepository.<>c__DisplayClass23_0.<DiscoverRepository>b__0() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs:line 37
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at GitVersion.Git.GitRepository.get_RepositoryInstance() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs:line 15
   at GitVersion.Git.GitRepository.get_Head() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs:line 24
   at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 153
   at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 131
   at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 55
   at GitVersion.GitPreparer.Prepare() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 45
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in /_/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 35
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 66
INFO [24-09-26 15:24:56:09] Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*` to see the git graph. This can help you troubleshoot any issues.

What is expected?

6.0.0-rc.2 on develop with remote repository -> 0.3.0-alpha.0

❯ docker run --rm gittools/gitversion:6.0.0-rc.2 /url https://github.com/xpicio/compute-version.git /b develop
{
  "AssemblySemFileVer": "0.3.0.0",
  "AssemblySemVer": "0.3.0.0",
  "BranchName": "develop",
  "BuildMetaData": null,
  "CommitDate": "2023-03-29",
  "CommitsSinceVersionSource": 0,
  "EscapedBranchName": "develop",
  "FullBuildMetaData": "Branch.develop.Sha.53720f5d878cbc9eab27fbb127615c3e85971409",
  "FullSemVer": "0.3.0-alpha.0",
  "InformationalVersion": "0.3.0-alpha.0+Branch.develop.Sha.53720f5d878cbc9eab27fbb127615c3e85971409",
  "Major": 0,
  "MajorMinorPatch": "0.3.0",
  "Minor": 3,
  "Patch": 0,
  "PreReleaseLabel": "alpha",
  "PreReleaseLabelWithDash": "-alpha",
  "PreReleaseNumber": 0,
  "PreReleaseTag": "alpha.0",
  "PreReleaseTagWithDash": "-alpha.0",
  "SemVer": "0.3.0-alpha.0",
  "Sha": "53720f5d878cbc9eab27fbb127615c3e85971409",
  "ShortSha": "53720f5",
  "UncommittedChanges": 0,
  "VersionSourceSha": "53720f5d878cbc9eab27fbb127615c3e85971409",
  "WeightedPreReleaseNumber": 0
}

6.0.0-rc.2 on main with remote repository -> 0.2.4

❯ docker run --rm gittools/gitversion:6.0.0-rc.2 /url https://github.com/xpicio/compute-version.git /b main
{
  "AssemblySemFileVer": "0.2.4.0",
  "AssemblySemVer": "0.2.4.0",
  "BranchName": "main",
  "BuildMetaData": null,
  "CommitDate": "2023-03-29",
  "CommitsSinceVersionSource": 0,
  "EscapedBranchName": "main",
  "FullBuildMetaData": "Branch.main.Sha.53720f5d878cbc9eab27fbb127615c3e85971409",
  "FullSemVer": "0.2.4",
  "InformationalVersion": "0.2.4+Branch.main.Sha.53720f5d878cbc9eab27fbb127615c3e85971409",
  "Major": 0,
  "MajorMinorPatch": "0.2.4",
  "Minor": 2,
  "Patch": 4,
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "SemVer": "0.2.4",
  "Sha": "53720f5d878cbc9eab27fbb127615c3e85971409",
  "ShortSha": "53720f5",
  "UncommittedChanges": 0,
  "VersionSourceSha": "53720f5d878cbc9eab27fbb127615c3e85971409",
  "WeightedPreReleaseNumber": 60000
}

Steps to Reproduce

Simply run:

docker run --rm gittools/gitversion:6.0.1 /url https://github.com/xpicio/compute-version.git /b develop

docker run --rm gittools/gitversion:6.0.2 /url https://github.com/xpicio/compute-version.git /b develop

RepositoryFixture Test

No response

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

No response

xpicio avatar Sep 26 '24 15:09 xpicio

I think we will remove the support of dynamic repository in the tool as I think it should be the responsibility of the developer that uses the tool to prepare the git repository for the tool to compute the version.

arturcic avatar Oct 04 '24 16:10 arturcic

Thanks for the update.

Just to clarify, will the current issue we're facing be fixed, and are you planning to remove the dynamic repository support in a new major release 7.x.x ? Or will the dynamic repository support remain broken in the 6.x.x releases ?

xpicio avatar Oct 04 '24 17:10 xpicio

I think it will be removed in v7 as part of the cli refactoring. If you want to invest some time in debugging it and filling in a PR, that work would be much appreciated and possibly included in the v6

arturcic avatar Oct 04 '24 17:10 arturcic

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.

github-actions[bot] avatar Jan 03 '25 11:01 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

github-actions[bot] avatar Feb 03 '25 11:02 github-actions[bot]