Skip to content

Instantly share code, notes, and snippets.

@h3
Last active June 4, 2018 19:45
Show Gist options
  • Save h3/e05b3dac8517f4d26c13aa4a6ecc2125 to your computer and use it in GitHub Desktop.
Save h3/e05b3dac8517f4d26c13aa4a6ecc2125 to your computer and use it in GitHub Desktop.
Check recursively if repositories have been migrated to Gitlab
#!/bin/bash
#
# Example usage:
#
# $ ./github-exodus.sh .
# $ ./github-exodus.sh venv/src/
#
README_EXTENSIONS=('.md' '.rst' '.txt' '')
if [ -v "$1" ]; then
DIR="$1"
else
DIR=`pwd`
fi
function check_readme {
rawurl="${1/https:\/\/github/https:\/\/raw.githubusercontent}/master/README$2"
out=$(curl -k --silent -L -w "\n%{http_code}" $rawurl 2>&1)
status_code="${out##*$'\n'}"
content="${out%$'\n'*}"
}
for repo in $(find venv/src/ -name 'config' -type f -print0 | xargs -0 grep -ho 'github.com\/.*'); do
url="https://${repo%.*}"
for ext in ${README_EXTENSIONS[@]}; do
check_readme $url $ext
if [ "$status_code" -eq 200 ]; then
match=$(echo "$content" | grep 'https://gitlab.com/')
if [ $match ]; then
echo " - Likely moved: $url -> $match"
else
echo " - Checked: $url"
fi
break
else
sleep 1
fi
done
done
@h3
Copy link
Author

h3 commented Jun 4, 2018

Oneliner using the raw URL:

curl https://gist.githubusercontent.com/h3/e05b3dac8517f4d26c13aa4a6ecc2125/raw/c80fa20b3920558fd8b97b0fd018ba9a20bdf387/github-exodus.sh | bash

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