From 7b7ee633ddd31cf2911e41f6e3aabcdba23a2231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 28 Aug 2015 14:58:23 -0700 Subject: [PATCH] google-code-moved: support pages that directly redirect --- tools/google-code-moved.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/google-code-moved.sh b/tools/google-code-moved.sh index 59f1ebd233..db3a72f421 100755 --- a/tools/google-code-moved.sh +++ b/tools/google-code-moved.sh @@ -10,12 +10,31 @@ len=$(echo "$all" | wc -l) echo "$len apps left" +moved() { + printf "\n%s\n" $1 + printf "\tProject moved: %s\n" $2 +} + echo "$all" | sort -u | shuf | while read url; do printf "." + + redurl=$(curl -s -I $url/checkout | perl -n -e '/^Location: (.*)$/ && print "$1\n"') + + if echo $redurl | grep -q hosting/moved; then + found=$(curl -L -s $url/checkout | sed -n 's/.*View the project at: .*/\1/p') + moved $url $found + continue + fi + if [ -n "$redurl" ] && [ "$redurl" != "$url" ]; then + moved $url $redurl + continue + fi - found=$(curl -s $url/checkout | sed -n 's/.*here<\/A>.*/\1/p') + found=$(curl -L -s $url/checkout | sed -n 's/.*here<\/A>.*/\1/p') if [ -n "$found" ]; then - printf "\n%s\n" $url - printf "\tProject moved: %s\n" $found + moved $url $found + continue fi done + +echo