简体   繁体   中英

Git pre-commit hook configuration

I'm following the office guidance to create and add a hook to the pre-commit check process. There are 3 files I need to create

  .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.

Q.1 Where should I put those files? I currently put them into my project folder, and edit the .gitignore file to ignore all of them, any better suggestion? 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?

1) These files seem like project-root files to me (though I've never used this tool myself). I'd suggest putting them at the project folder to start with (likely next to your .gitignore file). 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.

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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