Created
October 19, 2015 16:30
-
-
Save zph/95249ad4816d3ca0b1ae to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env bash | |
| # Credit: http://jezenthomas.com/using-git-to-manage-todos/ | |
| set -e | |
| main() { | |
| while IFS= read -r todo; do | |
| printf "%s\n" "$(file_path):$(line_number) $(line_author) $(message)" | |
| done < <(todo_list) | |
| } | |
| todo_list() { | |
| git ls-files -z | \ | |
| xargs -0 grep -InR 'TODO' | |
| } | |
| line_author() { | |
| LINE=$(line_number "$todo") | |
| FILE=$(file_path "$todo") | |
| tput setaf 6 | |
| printf "%s" "$(git log --pretty=format:"%cN" -s -L "$LINE","$LINE":"$FILE" | head -n 1)" | |
| tput sgr0 | |
| } | |
| file_path() { | |
| printf "%s" "$todo" | cut -d':' -f 1 | |
| } | |
| line_number() { | |
| printf "%s" "$todo" | cut -d':' -f 2 | |
| } | |
| message() { | |
| printf "%s" "$todo" | cut -d':' -f 3 | xargs | |
| } | |
| main | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment