Skip to content

Instantly share code, notes, and snippets.

@Sohalt
Created September 13, 2020 15:09
Show Gist options
  • Save Sohalt/0a87aa5a0730e81a4320e061806ee5e5 to your computer and use it in GitHub Desktop.
Save Sohalt/0a87aa5a0730e81a4320e061806ee5e5 to your computer and use it in GitHub Desktop.
searches for comments to github issues and reports if there was any activity since the time the comment was added (inspired by https://github.com/ogham/checkback)
#!/usr/bin/env bash
# searches for comments to github issues and reports if there was any activity since the time the comment was added
# inspired by https://github.com/ogham/checkback
rg --with-filename --line-number --only-matching "(https?://)?github.com/([^/]+)/([^/]+)/issues/(\d+)" | while read -r issue; do
file=$(echo "$issue" | sed -e 's,\([^:]\+\):[^:]\+:\(.*\),\1,')
line=$(echo "$issue" | sed -e 's,[^:]\+:\([^:]\+\):\(.*\),\1,')
author_time=$(git blame -L"$line","$line" -p "$file" 2>/dev/null | rg --replace='$1' 'author-time (\d+)')
api=$(echo "$issue" | sed -ne 's,\([^:]\+:[^:]\+\):\(https\?://\)\?github.com/\([^/]\+\)/\([^/]\+\)/issues/\([[:digit:]]\+\),https://api.github.com/repos/\3/\4/issues/\5,p')
updated=$(curl --silent -H "Accept: application/vnd.github.v3+json" "$api" | jq '.updated_at' | sed 's/"//g')
if [[ -n $author_time ]] && [[ $(date -d "$updated" +%s) -gt $author_time ]]; then
echo "$issue was updated after the comment got added: $updated"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment