Skip to content

Instantly share code, notes, and snippets.

Forked from athiththan11/pre-commit
Last active July 9, 2022 22:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Git Pre Commit Hook for FIXME TODO
- id: deny-todos
name: Denies TODOs or FIXME
description: 'Denies TODOs or FIXME in commits'
language: script


- repo:
    rev: 56dcacd575e88fc2b8052a6cf3c4ff9bf77ab62d
      - id: deny-todos
# 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
# Define what term will be searched for.
# 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* ]]
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment