【问题标题】:Git/Bitbucket pipelines - What causes tags to appear different depending on what branch I push to?Git/Bitbucket 管道 - 是什么导致标签根据我推送到的分支而出现不同?
【发布时间】:2017-11-02 23:00:05
【问题描述】:

我试图理解为什么在运行我的 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 bitbucket git-tag bitbucket-pipelines git-describe


    【解决方案1】:

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

    来自the documentation(强调我的):

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

    【讨论】:

    • 谢谢。好的 - 这意味着它实际上表现得“正确”,只是不像我预期的那样。因此,如果我理解这一点,如果我将相同的技术应用于主分支,它会返回 1.0.24 1.0.25,因为这些是相对于该分支的。
    猜你喜欢
    • 2018-12-22
    • 2015-09-09
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 2019-05-30
    • 2013-11-27
    • 2019-03-18
    • 2017-01-29
    相关资源
    最近更新 更多