【问题标题】:use git's prepare-commit-msg hook during an interactive rebase在交互式变基期间使用 git 的 prepare-commit-msg 钩子
【发布时间】:2019-08-21 06:23:51
【问题描述】:

在 lerna/yarn monorepo 中,我们使用 commitizencz-conventional-changelog 来管理发布。我们使用huskycommit-msg 挂钩中检查提交消息,并在prepare-commit-msg 挂钩中运行commitizen cli:

  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
      "pre-commit": "lint-staged",
      "prepare-commit-msg": "exec < /dev/tty && yarn commit --hook || true"
    }
  },

只要不需要变基就可以正常工作,但是,当我们的团队仍在学习绳索时,我们经常需要变基功能分支以修复提交消息。

git rebase --interactive origin/master

在运行rebase时,如果我选择reword命令,我将能够在我的编辑器中编辑提交消息,但是commitizen cli不会运行,换句话说,没有什么可以阻止我们提交错误提交消息。

虽然我们在 CI 中对提交消息进行 lint,但我更愿意通过在所有阶段强制使用 commitizen CLI 向导来完全避免这个问题。

问题:

我可以将 git 配置为在 rebase reword 操作期间使用 prepare-commit-msg 挂钩吗?

【问题讨论】:

    标签: git git-rebase commitizen


    【解决方案1】:

    git rebase 运行 pre-rebasepost-rewrite 挂钩。我怀疑它运行任何其他钩子。

    我认为您可以在每次重新提交后使用git rebase --exec 运行验证脚本。任何错误代码都会暂停 rebase 进程。

    【讨论】:

      猜你喜欢
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 2013-10-16
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多