# git-hooks ### How it works Git hooks adds `prepare-commit-msg` hook which is executed before committing message. Hook script will take current branch name and parse issue ticket name/number from it. If found, ticket will be prepend to commit message, and link to jira ticket will be added at the end. For example, if current branch is `CLOUD-12345-some-important-branch` and we add commit: ``` git commit -m "some important message" ``` resulting commit message will be: ``` git log commit 963dca96dd658a7df590c8b27b45d7f7536f9c1d (HEAD -> CLOUD-12345-some-important-branch) Author: Eden Kirin Date: Fri Sep 1 09:57:54 2023 +0200 CLOUD-12345: some important message https://smartvending.atlassian.net/browse/CLOUD-12345 ``` ## Installation 1. Clone repository ``` git clone https://gitea.ekirin.com/Intis/git-hooks.git ``` ### Use in single repository 1. Copy `intis-hooks` directory content to `your-repo-dir/.git/hooks` directory. 2. Make sure `prepare-commit-msg` is executable. If not, make it: `chmod +x prepare-commit-msg`. ### Use globally, as default hooks 1. Create `~/.git-templates` 2. Run the command: ``` git config --global init.templateDir '~/.git-templates' ``` 3. Copy `intis-hooks` directory content to `~/.git-templates/hooks` 4. Reinitialize existing git repos you wish to use this in with: `git init` 5. Rename `your-repo-dir/.git/intis-hooks` to `your-repo-dir/.git/hooks`