Skip to content

[ISSUE]: GitVersion 6.0.5 fails to calculate the version and says the repo is shallow #4348

Closed
@USBAkimbo

Description

@USBAkimbo

Prerequisites

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

GitVersion package

AzureDevops task, GitVersion.Tool

GitVersion version

6.0.5 and 5.12.0

Operating system

Linux

What are you seeing?

Here is my 5.12.0 config that works

# dotnet-tools.json
{
  "version": 1,
  "isRoot": true,
  "tools": {   
    "gitversion.tool": {
      "version": "5.12.0",
      "commands": [
        "dotnet-gitversion"
      ]
    }
  }
}
# gitversion.yml
assembly-informational-format: '{FullSemVer}'
branches:
  feature:
    mode: ContinuousDeployment
    regex: features?[/-]
    tag: feature.{BranchName}
  develop:
    regex: dev(elop)?(ment)?$
  master:
    regex: master$
  pull-request:
    regex: (pull|pull\-requests|pr)[/-]
    mode: ContinuousDelivery
    tag: pr
    increment: Inherit
    tag-number-pattern: '[/-](?<number>\d+)[-/]'
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
# azure-pipelines.yml
          - checkout: self
            clean: true
            fetchDepth: '0' # Clone full repo history for GitVersion to work

          - task: Bash@3
            displayName: Determine GitVersion
            inputs:
              targetType: inline
              script: |
                echo "=== Install GitVersion version as defined in .config/dotnet-tools.json ==="
                dotnet tool restore

                echo "=== Run GitVersion and select the semantic version ==="
                SEMVER=$(dotnet gitversion | grep '"SemVer"' | cut -d'"' -f 4)
                echo "Semantic version is: $SEMVER"

                echo "=== Exit with an error if the output is null ==="
                if [ -z "$SEMVER" ]; then
                  echo "Error: Failed to extract semver"
                  exit 1
                fi

                echo "=== Export SEMVER variable for use with other stages ==="
                echo "##vso[task.setvariable variable=SEMVER;isOutput=true]$SEMVER"

I'm using the actual GitVersion commands rather than the ADO task because we keep getting random errors with 5.12.0 - sometimes it works and sometimes it fails with error: undefined message

Now when I change the below config options for version 6.0.5, it doesn't work

# dotnet-tools.json
{
  "version": 1,
  "isRoot": true,
  "tools": {   
    "gitversion.tool": {
      "version": "6.0.5",
      "commands": [
        "dotnet-gitversion"
      ]
    }
  }
}
# gitversion.yml
assembly-informational-format: '{FullSemVer}'
branches:
  feature:
    mode: ContinuousDeployment
    regex: features?[/-]
    label: feature.{BranchName}
  develop:
    regex: dev(elop)?(ment)?$
  master:
    regex: master$
  pull-request:
    regex: (pull|pull\-requests|pr)[/-]
    mode: ContinuousDelivery
    label: pr
    increment: Inherit
    label-number-pattern: '[/-](?<number>\d+)[-/]'
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false

I just get this error

INFO [24-12-12 16:47:02:99] HEAD points at branch 'refs/heads/feature/dev-env-mig'.
INFO [24-12-12 16:47:02:99] -< End: Normalizing git directory for branch 'refs/heads/feature/dev-env-mig' (Took: 259.26ms) >-
WARN [24-12-12 16:47:02:99] An error occurred:
Repository is a shallow clone. Git repositories must contain the full history. See https://gitversion.net/docs/reference/requirements#unshallow for more info.
Semantic version is: 
=== Exit with an error if the output is null ===

And as you can see above, it's lying to me - this is definitely a shallow clone

What is expected?

I know with v6 I have to make some config changes to gitversion.yml which I've done - yet the error doesn't make sense because IT IS a full clone of the repo

Steps to Reproduce

Use the above config to make a pipeline with the defined config and run it

It should work with 5.12.0 and fail with 6.0.5

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