- repo: https://gist.github.com/freakboy3742/dce5c6a8efee1085750a10327580bc05
rev: 871b8132169bcec243127de1d4e8d69cccdce90e
hooks:
- id: deny-todos
Forked from coryodaniel/.pre-commit-hooks.yaml
Last active
November 27, 2025 01:00
-
-
Save freakboy3742/dce5c6a8efee1085750a10327580bc05 to your computer and use it in GitHub Desktop.
Git Pre Commit Hook for FIXME TODO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - id: deny-todos | |
| name: Denies TODOs or FIXME | |
| description: 'Denies TODOs or FIXME in commits' | |
| entry: run.sh | |
| language: script |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Adapted from https://gist.github.com/coryodaniel/6575466155b1b8e505ecc047fe5c4bcd | |
| # | |
| # An hook script to verify changes to be committed do not contain | |
| # any 'FIXME:' comments. Called by "git commit" with no arguments. | |
| # | |
| # The hook should exit with non-zero status after issuing an appropriate | |
| # message if it stops the commit. | |
| # | |
| # To bypass this hook, use the "--no-verify" parameter when committing. | |
| # Redirect output to stderr. | |
| exec 1>&2 | |
| # Define colors | |
| RED='\033[0;31m' | |
| NC='\033[0m' | |
| # Define what term will be searched for. | |
| SEARCH_TERM_FIXME="FIXME:" | |
| SEARCH_TERM_TODO="TODO:" | |
| # Check for the presence of the SEARCH_TERM in updated files. | |
| if [[ $(git diff --cached | grep -E "^\+" | grep -v '+++ b/' | cut -c 2-) == *$SEARCH_TERM_FIXME* ]] || [[ $(git diff --cached | grep -E "^\+" | grep -v '+++ b/' | cut -c 2-) == *$SEARCH_TERM_TODO* ]] | |
| then | |
| printf "${RED}Error:${NC} Found ${SEARCH_TERM_FIXME} | ${SEARCH_TERM_TODO} in attempted commit.\n" | |
| printf "Please remove all occurances of ${SEARCH_TERM_FIXME} | ${SEARCH_TERM_TODO} before committing.\n" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment