蔚蓝色管道:git diff-tree显示空字符串

osh3o9ms  于 2022-11-20  发布在  Git
关注(0)|答案(1)|浏览(134)

我正在尝试获取Azure构建管道上的所有已提交文件。这是我正在使用的yaml脚本:

trigger:
  branches:
    include:
      - swagger_dev
  paths:
    include:
      - swagger_dev/swaggers/*.yaml

variables:
  CLIENT_CREDENTIALS: $(ClientCredentials)

steps:
  - powershell: |
      echo "$(Build.SourceVersion)"
      echo "$(git diff-tree --no-commit-id --diff-filter=d --name-only -r $(Build.SourceVersion))"

当我提交一个或多个文件时,管道会正确地回显Build.SourceVersion,但随后回显git命令的空输出:pipeline log
这怎么可能呢?我现在在一个叫做swagger_dev的分支上,提交的文件在swagger_dev/swaggers目录下。也许我应该把这些信息添加到diff-tree命令中?

enyaitl3

enyaitl31#

我使用的bash任务是检查tfvars文件的名称。

- bash: |
              PATH_FILTER="folder1/**/*"
              CHANGED_FILES=$(git diff HEAD HEAD~ --name-only -- `find . -name "*.auto.tfvars"`)
              MATCH_COUNT=0
              MATCH_FILE=""
              FILE_PATH=""
              FILE_NAME=""

              echo "Checking for file changes..."
              for FILE in $CHANGED_FILES
              do
                if [[ $FILE == *$PATH_FILTER* ]]; then
                  MATCH_FILE=${FILE}
                  MATCH_PATH="$(dirname ${FILE})"
                  FILE_NAME="$(basename ${FILE})"
                  echo "MATCH:  ${FILE} changed"
                  MATCH_COUNT=$(($MATCH_COUNT+1))
                else
                  echo "IGNORE: ${FILE} changed"
                fi
              done

相关问题