Original info:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
My goal:
Validate commit message and deny commit if a comment didn't contain required tag
Step 1
Create copy of file from ~project folder~/.git/hooks/
File name - commit-msg.sample
Step 2
Rename copy to "commit-msg"
Step 3
Perform command: chmod +x commit-msg
Step 4
Edit file:
Now try to perform commit ;)
Example of second validation message:

Additional info:
If you want to share your hooks with all members of project - perform next steps:
Step 1
Create folder 'git-hooks' in root project directory
Step 2
Store here created files with your hooks
Step 3
In android gradle file (in my case - build.gradle for app.module ) add next:
Step 4
Now rebuild your project. All your hooks will be copied to .git/hooks folder
WARNING:
If you want to remove hooks - don't forget to remove it manually from folder .git/hooks/
Android Studio in my post case use only hooks from .git/hooks/ folder
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
My goal:
Validate commit message and deny commit if a comment didn't contain required tag
Step 1
Create copy of file from ~project folder~/.git/hooks/
File name - commit-msg.sample
Step 2
Rename copy to "commit-msg"
Step 3
Perform command: chmod +x commit-msg
Step 4
Edit file:
Now try to perform commit ;)
Example of second validation message:

Additional info:
If you want to share your hooks with all members of project - perform next steps:
Step 1
Create folder 'git-hooks' in root project directory
Step 2
Store here created files with your hooks
Step 3
In android gradle file (in my case - build.gradle for app.module ) add next:
Step 4
Now rebuild your project. All your hooks will be copied to .git/hooks folder
WARNING:
If you want to remove hooks - don't forget to remove it manually from folder .git/hooks/
Android Studio in my post case use only hooks from .git/hooks/ folder
Комментариев нет:
Отправить комментарий