Add gh_mirror_org.sh
This commit is contained in:
parent
83bce6c2cc
commit
be3c479ad3
28
scripts/gh_mirror_org.sh
Normal file
28
scripts/gh_mirror_org.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/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
|
Loading…
Reference in New Issue
Block a user