aboutsummaryrefslogtreecommitdiffstats
path: root/extract.sh
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-09-05 15:49:19 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-09-05 16:00:14 +0200
commitebd9664313c0a1984fc9a06d0e247e4832212957 (patch)
treebf97f06e739be4e8a5dc1a231f5f513233917698 /extract.sh
parent4c019f382762f55e9595b151e186cf360d0605fa (diff)
*.sh -> src
Diffstat (limited to 'extract.sh')
-rwxr-xr-xextract.sh58
1 files changed, 0 insertions, 58 deletions
diff --git a/extract.sh b/extract.sh
deleted file mode 100755
index ba611d3..0000000
--- a/extract.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env bash
-
-set -efu
-
-input_dir=$1
-
-find "$input_dir" -type f |
- while read -r input_file; do
- ext=
- case $input_file in
- *.elm) ext="elm" ;;
- *.nix) ext="nix" ;;
- *) ;;
- esac
-
- if test -z $ext; then
- echo "warning, file $input_file ignored" >&2
- continue
- fi
-
- ./extract-$ext.sh "$input_file"
- done |
- while read -r item; do
- start_row=$(echo "$item" | jq '.match.start.row')
- end_row=$(echo "$item" | jq '.match.end.row')
-
- last_commit=$(echo "$item" | jq '.last_commit' -r)
- text=$(echo "$item" | jq '.text' -r)
- file=$(echo "$item" | jq '.file' -r)
-
- first_commit=$(git --no-pager log --reverse -S"$text" --format=%H | \
- head -n 1)
-
- created_at=$(git show $first_commit --no-patch --format=%ad)
- heading=$(echo "$text" | sed '/^$/Q' | sed 's/.*TODO //')
- body=$(echo "$text" | tail -n +$(($(echo "$heading" | wc -l) + 2)) | \
- awk -F '[^ ]' '
- NR == 1 {n = length($1)}
- {sub("^ {1,"n"}", ""); print}'
- )
-
- GREEN='\033[0;32m'
- BOLD=$(tput bold)
- NORMAL=$(tput sgr0)
- NC='\033[0m'
- echo -e "$GREEN--- $created_at --- $file$NC"
- echo
- echo "$BOLD$heading$NORMAL" | fold -s
- if test -n "$body"; then
- echo
- echo "$body" | fold -s
- echo
- fi
- echo
- cat "$file" | nl -w 4 -s "| " -p -d '' -b a| tail -n +$(($start_row - 2)) | head -n $(($end_row - $start_row + 7))
- echo
- echo
- done