Skip to content

Instantly share code, notes, and snippets.

@karelhala
Created November 23, 2017 16:08
Show Gist options
  • Save karelhala/583505a7846f45abb0974b5a23a969eb to your computer and use it in GitHub Desktop.
Save karelhala/583505a7846f45abb0974b5a23a969eb to your computer and use it in GitHub Desktop.
#!/bin/sh
year=$(date --date="7 days ago" +"%Y")
month=$(date --date="7 days ago" +"%m")
day=$(date --date="7 days ago" +"%d")
file=/tmp/$2.html
wget -q -O $file "https://github.com/$1/$2/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3A$3%20updated%3A%3E%3D$year-$month-$day%20sort%3Acreated-asc" >/dev/null
urls=$(cat $file | sed -n "s/<a href=\"\(\/$1\/$2\/pull\/[0-9]*\)\" class=\"[^m][^>]*[^>]*>/\1/p")
descriptions=$(cat $file | sed -n "/<a href=\"\(\/$1\/$2\/pull\/[0-9]*\)\" class=\"[^m][^>]*[^>]*>/{n;p}")
statuses=$(cat $file | sed -n "s/<span class=\"tooltipped tooltipped-n\" aria-label=\"\([^ ]*\) .*/\1/p")
descriptions=$(echo "${descriptions}" | sed -e 's/^[ \t]*//g')
statuses=$(echo "${statuses}" | sed -e 's/^[ \t]*//g')
set -f # avoid globbing (expansion of *).
urlArray=(${urls// / })
IFS=$'\n' descriptionArray=($descriptions)
IFS=$'\n' statuseArray=($statuses)
for i in "${!urlArray[@]}"
do
description=$(echo "${descriptionArray[i]}" | perl -MHTML::Entities -pe 'decode_entities($_);')
echo "https://github.com${urlArray[i]} [${statuseArray[i]}] - $description"
done
@xeviknal
Copy link

That is really useful Karel!
Do you think it could be useful to have this little piece of help?

if [ "$#" -ne 3 ]; then
  echo "Usage: $0 repo_owner repo_name author" >&2
  exit 1
fi

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