简体   繁体   English

是否可以将缓存用于Git预提交挂钩?

[英]Is it possible to use cache for Git pre-commit hook?

I use a pre-commit hook to check code-style and other rules for my project. 我使用预提交钩子来检查项目的代码样式和其他规则。

gulp.task('git-preCommit', ['jscs', 'jshint', 'tslint', 'stylint']);

Often this process is long-running. 通常,此过程是长期运行的。 I wonder, is it possible to set some cache for changed files in Git, or in jscs, jshint etc. 我想知道,是否可以在Git或jscs,jshint等中为更改的文件设置一些缓存。

For example there are 150 diff files, preCommit checked 149 successfully and threw an error on 1 ( path/example.ts ). 例如,有150个差异文件, preCommit成功检查了149个文件,并在1( path/example.ts )上抛出错误。 I fix the last one, and when I commit next time - git cache (or some tools) will know that I fixed only 1 file and check only this one, not all 150. 我修复了最后一个,当我下次提交时git cache (或某些工具)将知道我只修复了1个文件并仅检查了这个文件,而不是全部150个。

Git does not have any cache mechanism or support for content. Git没有任何缓存机制或对内容的支持。

So the simple answer is NO , it cant be done within git. 因此,简单的答案是NO ,它不能在git中完成。
You can still use any 3rd party tool which might be suitable for you. 您仍然可以使用任何适合您的第三方工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM