add script to pull all of my repos out of gitea

master
Andrew Coleman 2020-05-26 12:55:20 -04:00
parent 2fbdca54a6
commit 3906c417ba
1 changed files with 23 additions and 0 deletions

23
bin/clone-all-gitea-repos.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
GITEA_HOST=$1
if [ -z "$GITEA_HOST" ] || [ -z "$GITEA_ACCESS_TOKEN" ] ; then
echo "Clones all repos that you have access to into the current directory."
echo "You must set \$GITEA_ACCESS_TOKEN to a value from the gitea interface."
echo "Usage: $0 <gitea_host>"
exit 1
fi
for i in $(curl -s --header "Authorization: token $GITEA_ACCESS_TOKEN" "${GITEA_HOST}/api/v1/user/repos?limit=50" | jq -r 'map(.name + "," + .ssh_url) | flatten[]') ; do
OLDIFS=$IFS
IFS=','
set -- $i
if [ -d $1 ] ; then
echo "Repo $1 already exists, skipping."
else
echo "Cloning $1 from $2"
git clone -q $2
fi
IFS=$OLDIFS
done