Skip to content

Instantly share code, notes, and snippets.

@noisy
Last active November 12, 2015 23:07
Show Gist options
  • Save noisy/48114158802589908f56 to your computer and use it in GitHub Desktop.
Save noisy/48114158802589908f56 to your computer and use it in GitHub Desktop.
#!/bin/bash
# To make sure, that proper refs are added to .git/config
# run: git config --add remote.origin.fetch "+refs/pull/*:refs/remotes/pr/*"
git fetch origin
touch last_update
pull_requests_refs="`git show-ref | grep "refs/remotes/pr/.*/head"`"
pull_requests="`echo "$pull_requests_refs" | sed -e "s#\([0-9a-f]*\)\ refs/remotes/pr/\(.*\)/head.*#pr\2 \1#g" | sort`"
changed_prs="`echo "$pull_requests" && cat last_update | sort | uniq -u`"
grep -F -x -v -f last_update <(echo "$changed_prs")
echo "$pull_requests" > last_update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment