Add gh_mirror_org.sh
This commit is contained in:
parent
83bce6c2cc
commit
be3c479ad3
1 changed files with 28 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue