From 3507f0c1540871ea815359b16ccf23af79bd8e30 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 3 Nov 2019 03:37:55 +0100 Subject: Ideas for getting recent TODOs from a range of Git refs The goal will be to list all TODOs since the branch point. Additionally, there should be an option to print the TODOs with file names and line numbers to enable loading the list into Vim's quickfix list. --- git-oldest-ancestor | 16 ++++++++++++++++ git-todos | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 git-oldest-ancestor create mode 100755 git-todos diff --git a/git-oldest-ancestor b/git-oldest-ancestor new file mode 100755 index 0000000..57db44d --- /dev/null +++ b/git-oldest-ancestor @@ -0,0 +1,16 @@ +#!/bin/bash + +# git-oldest-ancestor +# +# Finds the branch point of the current HEAD. +# +# From lindes (https://stackoverflow.com/users/313756/lindes) on Stack Overflow +# https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git/4991675#4991675 +# https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git/4991675#comment42897586_4991675 + +diff \ + --old-line-format='' \ + --new-line-format='' \ + <(git rev-list --first-parent "${1:-master}") \ + <(git rev-list --first-parent "${2:-HEAD}") | + head -1 diff --git a/git-todos b/git-todos new file mode 100755 index 0000000..8ab96eb --- /dev/null +++ b/git-todos @@ -0,0 +1,20 @@ +#!/bin/sh + +# Show TODOs since base branch + +git diff --diff-filter=a -S'TODO' "$(git oldest-ancestor)"... | + egrep --after-context 1 '^\+.*\bTODO\b' | + sed 's/^+[[:space:]]*//' + + +# Want: +# - filename +# - line number + +# Use git blame? + +# fgrep -A 1 -n TODO $(git diff --name-only $(git oldest-ancestor)... ) +# ^ not quite the same thing, as it will catch old TODOs in updated files + +# https://stackoverflow.com/questions/23298812/python-unified-diff-with-line-numbers-from-both-files +# diff --unchanged-line-format=' %.2dn %L' --old-line-format="-%.2dn %L" --new-line-format="+%.2dn %L" <(git show @~:app/module/background/nativeMessageManager.js) app/module/background/nativeMessageManager.js -- cgit v1.2.3