Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexandrecarlton/git-hooks
Personal set of git hooks to automate mundane tasks
https://github.com/alexandrecarlton/git-hooks
Last synced: 17 days ago
JSON representation
Personal set of git hooks to automate mundane tasks
- Host: GitHub
- URL: https://github.com/alexandrecarlton/git-hooks
- Owner: AlexandreCarlton
- License: mit
- Created: 2016-08-07T07:43:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-09T10:39:33.000Z (over 3 years ago)
- Last Synced: 2024-10-30T07:57:04.428Z (2 months ago)
- Language: Shell
- Size: 22.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git-hooks
A personal set of [git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)
to automate mundane tasks.## Setting up
### Post Git 2.9
If you are using [Git 2.9](https://github.com/git/git/blob/master/Documentation/RelNotes/2.9.0.txt)
you can clone this repository, set your `core.hooksPath` variable and you'll be
good to go:```bash
mkdir --parents "${HOME}/.config/git"
git config --global core.hooksPath "${HOME}/.config/git/hooks"
git clone https://github.com/AlexandreCarlton/git-hooks.git "${HOME}/.config/git/hooks"
```### Pre Git 2.9
If you aren't using a new enough version of Git, you'll have to clone this
repository into your templates directory, which will be copied into every git
repository you create. The downside of this is that you will have to manually
update each repository's hooks when you update this one.```bash
mkdir --parents "${HOME}/.config/git/templates"
git config --global init.templatedir "${HOME}/.config/git/templates"
git clone https://github.com/AlexandreCarlton/git-hooks.git "${HOME}/.config/git/templates/hooks"
```If you would like to use these hooks in existing repositories, you will have to
call `git init` in every single one, which will copy the template directory
across into each `.git` folder.## Scripts
These are called by our git hooks.
### clean-python-bytecode-files
Deletes any `.pyc`, `.pyo` and `__pycache__` files found in the project to
force recompilation of `.py` files on a checkout.### create-tags-file
"Adapted" from [Effortless Ctags with Git](https://tbaggery.com/2011/08/08/effortless-ctags-with-git.html),
this script will create a tags file from all tracked files in the repository.### insert-jira-ticket
Attempts to determine the ticket number of a [JIRA issue](https://confluence.atlassian.com/jira064/what-is-an-issue-720416138.html)
from the current branch name ([generated by Bitbucket Server](https://confluence.atlassian.com/bitbucketserver/using-branches-in-bitbucket-server-776639968.html#UsingbranchesinBitbucketServer-Creatingbranches))
and substitutes it into a special expression in the message template if present.The syntax is:
```
{{.*TICKET.*}}
```
where characters before and after 'TICKET' are preserved.
For example, `{{[TICKET] }}` for `ISSUE-123` would translate to `[ISSUE-123] `.
If no ticket can be extracted, the expressions are removed.