命令"['git', 'rev-parse', 'HEAD^1']"返回了非零的退出状态码128。

3

我是一名嵌入式编程的初学者,尝试建立一个工作流程,在其中代码大小会自动放入数据库并与以前的版本进行比较。显然,在Github上也是新手。

我正在尝试通过Github Action调用Python脚本。

以下是该操作:

- name: Stamp revision
        working-directory: cobrax
        continue-on-error: True
        run: |
          pip install psycopg2-binary
          pip install click
          pip install prettytable
          python3 codesizes.py stamp build/zephyr/zephyr.elf

以下是Python代码中有问题的行,我正尝试获取父版本:

    revision = subprocess.check_output(
        ["git", "rev-parse", "{}".format(revision)], encoding="UTF-8"
    ).strip()
    parent_revision = subprocess.check_output(
        ["git", "rev-parse", "{}^1".format(revision)], encoding="UTF-8"
    ).strip()

现在,针对工作完美的修订版。但只因为'^1'是父级修订版,我一直收到来自github action的以下错误消息:

subprocess.CalledProcessError: Command '...' returned non-zero exit status 128

所以,我尝试了一些东西,特别是:

["git", "rev-parse", "{}^".format(revision)], encoding="UTF-8"
    ).strip()

["git", "rev-list", "--parents", "-n", "1", revision, "|", "cut", "-d'", "'", "-f2-"], encoding="UTF-8"

但是,这个错误来自其他地方。作为一个初学者,我希望有人能解释一下,因为显然这是github actions 的虚拟环境问题,因为在我的ubuntu VM存储库中,我没有遇到这个问题。

谢谢你的帮助。

1个回答

3

经过一些研究,我发现我使用的actions/checkout@v2默认使用浅克隆(--depth=1)。这使我可以使用HEAD但是HEAD^。

我的工作流程配置如下:

      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 2

一切正常!


有一个新的语法:- checkout: self \n fetchDepth: 2 - emi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接