From 3906c417ba6c0fe65668e7da33ad8b4f1f30a40d Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Tue, 26 May 2020 12:55:20 -0400 Subject: [PATCH] add script to pull all of my repos out of gitea --- bin/clone-all-gitea-repos.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 bin/clone-all-gitea-repos.sh diff --git a/bin/clone-all-gitea-repos.sh b/bin/clone-all-gitea-repos.sh new file mode 100755 index 0000000..652f173 --- /dev/null +++ b/bin/clone-all-gitea-repos.sh @@ -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 " + 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