29 lines
726 B
Bash
29 lines
726 B
Bash
|
#!/usr/local/bin/zsh
|
||
|
######################################################
|
||
|
# Mirror all repositories from a Github organisation #
|
||
|
######################################################
|
||
|
|
||
|
org="$1"
|
||
|
|
||
|
if [ -z $org ]; then
|
||
|
echo "Usage: $0 <organisation>"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
mkdir -p $org
|
||
|
pushd $org
|
||
|
|
||
|
for repo in $(curl -v -s "https://api.github.com/orgs/$org/repos?per_page=100&type=sources" 2>&1 | grep '"full_name": "*"' | cut -d':' -f2 | sed s'/,$//' | sed s'/"//g' ); do
|
||
|
|
||
|
filename=$(echo "$repo" | cut -d'/' -f2)
|
||
|
if [ -e $filename ]; then
|
||
|
pushd $filename
|
||
|
git pull
|
||
|
popd
|
||
|
else
|
||
|
git clone https://github.com/$repo
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
popd
|