-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfind_todo_author.sh
More file actions
executable file
·44 lines (35 loc) · 936 Bytes
/
find_todo_author.sh
File metadata and controls
executable file
·44 lines (35 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# This script is used to find and print all the 'TODO' comments in your code along with the author's name and other relevant metadata.
# Original source from: http://jezenthomas.com/using-git-to-manage-todos/
set -e
todo_list() {
grep -InR 'TODO' ./* \
--exclude-dir=node_modules \
--exclude-dir=public \
--exclude-dir=vendor \
--exclude-dir=compiled \
--exclude-dir=bin \
--exclude-dir=git-hooks
}
line_author() {
LINE=$(line_number)
FILE=$(file_path)
tput setaf 6 2>/dev/null
printf "%s" "$(git log --pretty=format:"%cN" -s -L "$LINE","$LINE":"$FILE" | head -n 1)"
tput sgr0 2>/dev/null
}
file_path() {
parse_line 1
}
line_number() {
parse_line 2
}
message() {
parse_line 3
}
parse_line() {
printf "%s" "$todo" | cut -d':' -f "$1"
}
while IFS= read -r todo; do
printf "%s\n" "$(file_path):$(line_number) $(line_author) $(message | xargs)"
done < <(todo_list)