update clone script to support archived/ repos

master
Andrew Coleman 2020-05-27 11:44:27 -04:00
parent 8733e7ab04
commit 74d43b7c62
1 changed files with 20 additions and 5 deletions

View File

@ -9,15 +9,30 @@ if [ -z "$GITEA_HOST" ] || [ -z "$GITEA_ACCESS_TOKEN" ] ; then
exit 1 exit 1
fi 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 mkdir -p archived
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 + "," + (.archived | tostring)) | flatten[]') ; do
OLDIFS=$IFS OLDIFS=$IFS
IFS=',' IFS=','
set -- $i set -- $i
if [ -d $1 ] ; then if [ "$3" == "true" ] ; then
echo "Repo $1 already exists, skipping." if [ -d $1 ] ; then
echo "Moving $1 into archived/$1..."
mv $1 archived/
else
if [ -d "archived/$1" ] ; then
echo "Archived repo $1 already exists, skipping."
else
echo "Cloning archived/$1 from $2"
git clone -q $2 archived/$1
fi
fi
else else
echo "Cloning $1 from $2" if [ -d $1 ] ; then
git clone -q $2 echo "Repo $1 already exists, skipping."
else
echo "Cloning $1 from $2"
git clone -q $2
fi
fi fi
IFS=$OLDIFS IFS=$OLDIFS
done done