Skip to content

Instantly share code, notes, and snippets.

@nulpunkt
Created October 27, 2014 10:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nulpunkt/92bc464d86a54622e223 to your computer and use it in GitHub Desktop.
Save nulpunkt/92bc464d86a54622e223 to your computer and use it in GitHub Desktop.
Find the oldest TODO in the codebase
git grep -n -w "FIXME\|TODO\|XXX" | awk '{ print $1 }' | while read fileline; do
filename=`echo $fileline | cut -d: -f1`
lineno=`echo $fileline | cut -d: -f2`
time=`git blame -p -t $filename -L$lineno,$lineno | grep author-time | cut -d' ' -f2`
msg=`git blame $filename -L$lineno,$lineno`
echo "$time $fileline $msg"
done | sort | cut -d' ' -f1-
@petemounce
Copy link

Beautiful!

Tweaked to output dates as human-readable.

git grep -n -w "FIXME\|TODO\|XXX" | awk '{ print $1 }' | while read fileline; do
        filename=$(echo ${fileline} | cut -d: -f1)
        lineno=$(echo ${fileline} | cut -d: -f2)
        time=$(git blame -p -t ${filename} -L${lineno},${lineno} | grep author-time | cut -d' ' -f2)
        msg=$(git blame ${filename} -L${lineno},${lineno})
        echo "$(date -u -r "${time}" +'%Y-%m-%d %H:%M:%S') ${fileline} ${msg}"
done | sort | cut -d' ' -f1-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment