Git/Bitbucket 管道 - 是什么导致标签根据我推送到的分支而显示不同?

Git/Bitbucket pipelines - What causes tags to appear different depending on what branch I push to?

我试图理解为什么当 运行 我的 bitbucket-pipelines.yml 文件时,我会得到两个与 git 标签相关的不同结果。目前我的项目有来自 1.0.0 - 1.0.25 的标签 运行。 .yml 文件看起来像这样...

pipelines:
  branches:
    diff-test:
      - step:
        script:
          - export PREVIOUS_GIT_HASH=`git rev-list --tags --skip=2 --max-count=1`
          - export PREVIOUS_GIT_TAG=`git describe ${PREVIOUS_GIT_HASH} --abbrev=0`
          - export GIT_TAG=`git describe --tags --abbrev=0`
          - echo ${PREVIOUS_GIT_TAG} ${GIT_TAG}
  # A develop step/script happens here but it's irrelevant...

    master:
      - step:
        script:
        # set the most recent tag as an environment variable.
          - export GIT_TAG=`git describe --tags --abbrev=0`
          - zip -FSr ${BITBUCKET_REPO_SLUG}-${GIT_TAG}.zip ./ -x@exclude.lst
          - curl -u ${BB_AUTH_STRING} -X POST "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${BITBUCKET_REPO_SLUG}-${GIT_TAG}.zip"

当我推送到 master 时,附加到下载工件的标签是正确的 (1.0.25)。但是,当我推送到 diff-test 时,回显的标签是 1.0.141.0.15

在 git 文档中,对于 describe,它表示 --tags: Instead of using only the annotated tags, use any tag found in refs/tags namespace. This option enables matching a lightweight (non-annotated) tag.

我的问题是 - 是什么导致标签根据我推送到的分支而显示不同?

Git describe 提供有关特定提交的信息,其他所有内容(即标记)都与该提交有关。它不会报告该提交的祖先中不存在的标签。因为分支有不同的祖先,描述不同分支中的提交可能会产生不同的结果。

来自 the documentation(强调我的):

The command finds the most recent tag that is reachable from a commit.