简体   繁体   English

Git预提交挂钩配置

[英]Git pre-commit hook configuration

I'm following the office guidance to create and add a hook to the pre-commit check process. 我正在按照Office的指导来创建一个钩子,并将其添加到提交前检查过程中。 There are 3 files I need to create 我需要创建3个文件

  .pre-commit-config.yaml

  .pre-commit-hooks.yaml

   theCheckFile.sh

The config file configs the hooks file which calls the theCheckFils.sh file to check my code style. 配置文件配置了钩子文件,该文件调用theCheckFils.sh文件来检查我的代码样式。

Q.1 Where should I put those files? Q.1我应该把那些文件放在哪里? I currently put them into my project folder, and edit the .gitignore file to ignore all of them, any better suggestion? 我目前将它们放到我的项目文件夹中,然后编辑.gitignore文件以忽略所有它们,还有更好的建议吗? or this is OK. 还是可以的

Q.2 The rev is needed in pre-commit-config.yaml file, where should I find this information, there is not version information from the code Repo I'm currently working with, can I just randomly create a number? Q.2 pre-commit-config.yaml文件中需要rev,我应该在哪里找到此信息,我正在使用的Repo代码中没有版本信息,我可以随机创建一个数字吗?

1) These files seem like project-root files to me (though I've never used this tool myself). 1)在我看来,这些文件似乎是项目根文件(尽管我自己从未使用过此工具)。 I'd suggest putting them at the project folder to start with (likely next to your .gitignore file). 我建议将它们放在项目文件夹的开头(可能在.gitignore文件旁边)。 Add them to .gitignore if you want to be the only person using pre-commit on your team, or add them to the repo if your entire team will be using pre-commit with the same settings. 如果要成为团队中唯一使用预提交的人,请将它们添加到.gitignore中;如果整个团队将使用相同设置的预提交,则将它们添加到存储库中。

2) It looks like the repo's rev field is 'the revision or tag to clone at' of the repo with the pre-commit check code. 2)看起来该存储库的rev字段是带有预提交检查代码的该存储库的“要克隆到的修订或标签”。 This would be used to identify which version of the check code to use, so it would likely be required. 这将用于识别使用哪个版本的检查代码,因此可能需要使用。 https://pre-commit.com/#pre-commit-configyaml---repos https://pre-commit.com/#pre-commit-configyaml---repos

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

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