Commit message hook on github

一个人想着一个人 提交于 2019-12-05 10:48:17

GitHub only offers webhooks, which allows you to listen to and react to certain events, including the push.

But that only allows you to react to a push (like a post-receive hook would), not to prevent it.

You could build a listener to that push event which would:

  • examine the latest commit just pushed
  • reset to HEAD~1 if the commit doesn't follow the expected policy (push --force)

But that would be tricky for the user who initially pushed that commit to realize that said commit just disappeared from the GitHub repo.


A better solution would be to setup a bare repo in a server where you could setup that pre-receive hook: if that commit passes, then a post-receive hook would push it to the intended GitHub repo.

But depending on your team, it might be difficult to setup a repo which is accessible by everyone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!