Git describe" output differs b/w local & GitHub Actions runner

Issue

I am having different results when running the command

git describe 26888c716fd70bde90c73ed603134bd1162018c6 --abbrev=7 --match="v33.4.*" --always

on different environments: Windows local machine, docker ubuntu:latest machine, and GitHub runner.

The expected output is v33.4.0-5-g26888c7. On Windows and docker, this is the output I get, however, on GitHub runner it is 26888c7.

Environment Details

Git Version

  • GitHub runner: git version 2.41.0
  • docker ubuntu:latest: git version 2.34.1
  • Windows local machine: git version 2.41.0.windows.1

The issue you are experiencing is related to the different versions of Git installed on the different environments. The git describe command behaves differently in each version, resulting in different output.

On the GitHub runner, which has Git version 2.41.0, the git describe command omits the prefix “v” and the trailing commit count when there are no tags matching the specified pattern. This is why you are getting 26888c7 as the output.

To have consistent output across all environments, you can modify your command to include the prefix “v” and the trailing commit count manually. Here’s the modified command:

git describe 26888c716fd70bde90c73ed603134bd1162018c6 --abbrev=7 --match="v33.4.*" --always --long --tags | sed -E 's/^v//;s/-([0-9]+)-g/-\1-/;'

This command uses the --long and --tags options to include the commit count and tags in the output. The sed command is used to remove the prefix “v” and modify the commit count format.

Executing this modified command should give you the expected output v33.4.0-5-g26888c7 across all environments.