有没有办法让 github 上创建 pull 请求时,运行一些 npm 命令(例如 npm run beautify)后自动创建一个新的 pull 请求,这样我就不必担心美化过程。
如果可以完成这样的事情,自动将提交添加到当前的 pull 请求中,从而美化所有文件,即使这样也可以正常工作。
我可以使用任何免费的第三方软件(Greenkeeper、travis 或其他软件)
最佳答案
您可以在服务器和本地使用 git hook,或者设置本地过滤器(涂抹/清理)来美化您的代码,然后再将其提交到存储库。
Git Hook
阅读official docs以获得完整的引用。
<小时/>涂抹/清洁
阅读所有相关内容并在此处进行设置:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
It turns out that you can write your own filters for doing substitutions in files on commit/checkout.
These are called
clean
andsmudge
filters.In the
.gitattributes
file, you can set a filter for particular paths and then set up scripts that will process files just before they’re checked out (“smudge”, see Figure below) and just before they’re staged (“clean”, see Figure 8-3).These filters can be set to do all sorts of fun things.
关于javascript - 美化 github 上 pull 请求之前/之后的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38697406/