【问题标题】:using `git commit —no-verify` for pre-commit azure pipeline使用 `git commit —no-verify` 进行预提交 azure 管道
【发布时间】:2020-09-18 14:50:12
【问题描述】:

我看到我可以将预提交与管道一起使用,有没有办法为 azure 管道设置 yaml 文件以在特定情况下失败时使用git commit --no-verify?或者有没有办法在问题发生时对管道进行故障排除?

这就是我的 yaml 文件

  pool:
    vmImage: ubuntu-18.04
  variables:
    PRE_COMMIT_HOME: $(Pipeline.Workspace)/pre-commit-cache

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: ${{ parameters.python }}
  - script: |
      echo "##vso[task.setvariable variable=PY]$(python -VV)"
    displayName: set version variables
  - task: CacheBeta@0
    inputs:
      key: pre-commit | .pre-commit-config.yaml | "$(PY)" 
      path: $(PRE_COMMIT_HOME)

  - script: python -m pip install --upgrade pre-commit
    displayName: install pre-commit
  - script: pre-commit run --all-files --show-diff-on-failure
    displayName: run pre-commit

【问题讨论】:

  • 有什么阻止您访问|| true|| git commit?你想摆脱什么行为?
  • @AnthonySottile 我希望预提交钩子在管道中运行,但在静态分析由于钩子标记错误而失败的情况下,我希望能够覆盖在管线中。我知道在本地我可以运行git commit --no-verify,我可以在管道中做类似的事情吗?
  • 是的,你会使用|| true,或者SKIP 环境变量——但是--no-verify 只是跳过了整个过程,所以你根本就不会运行它吗?
  • @AnthonySottile 哦,我明白了,是的,这不是我想要的,感谢您澄清这一点。

标签: azure-devops pre-commit-hook pre-commit pre-commit.com


【解决方案1】:

查看文档here

并非所有挂钩都是完美的,因此有时您可能需要跳过执行 一个或多个钩子。预提交通过查询SKIP 解决了这个问题 环境变量。 SKIP 环境变量是逗号 单独的钩子 ID 列表。这允许您跳过单个钩子 而不是 --no-verifying 整个提交。

$ SKIP=flake8 git commit -m "foo"

【讨论】:

  • 我的回复有用吗?你的问题怎么样了?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-04-19
  • 2018-09-14
  • 1970-01-01
  • 2014-01-17
  • 1970-01-01
  • 2021-03-31
  • 2021-08-12
相关资源
最近更新 更多