0

我试图理解为什么在运行我的 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..

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

4

1 回答 1

1

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

文档(强调我的):

该命令查找可从提交中访问的最新标记。

于 2017-06-01T17:23:42.797 回答