-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-todo
More file actions
executable file
·49 lines (45 loc) · 1.45 KB
/
Copy pathgit-todo
File metadata and controls
executable file
·49 lines (45 loc) · 1.45 KB
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
45
46
47
48
49
#!/bin/bash
case $1 in
-h|--help)
echo "SUMMARY: Search a git repository for tasks"
echo "USAGE: git-todo [COMPARE]";
echo "COMPARE defaults to origin/develop, or similar git upstream.";
exit;;
esac
# --no-renames: does this cause larger diffs, because a rename is treated more like a mode change, not a code change?
diff_reference=$1
if [[ -z $diff_reference ]]; then
remote=origin
if [[ -z $(git remote | grep "\<$remote\>") ]]; then
remote=$(git branch -vv | grep '^\*' | perl -pe 's;^.* \[([^/]+).*;\1;')
if [[ $remote =~ ^\* ]]; then # no upstream branch found
remote=""
fi
fi
if [[ -n $remote ]]; then
remote_head_branch=develop
if [[ -z $(git branch | grep "\<$remote_head_branch\>") ]]; then
remote_head_branch=$(git remote show $remote | grep 'HEAD branch' | perl -pe 's/^\s*HEAD branch:\s*//')
fi
if [[ -n $remote_head_branch ]]; then
diff_reference=$remote/$remote_head_branch
fi
fi
fi
findTodos() {
local rootGitDir="$(git rev-parse --show-cdup)"
[[ -n $rootGitDir ]] && cd "$rootGitDir"
if [[ -n $diff_reference ]]; then
git diff -U0 $diff_reference | grep '^+++\|^+.*\(FIXME\|XXX\|TODO\)' | perl -pe 's/^\++( b\/)?//'| grep -B 1 --color=always 'FIXME\|XXX\|TODO'
else
git grep -n --color=always -n '\(FIXME\|XXX\|TODO\)'
fi
}
if [[ -t 1 ]]; then
# findTodos | less -RS
findTodos | more
else
findTodos
fi
# HISTORY
# v? 2024-12-26 Explicit git command for root dir. b2sum=564fcd40&size=1042