Last active
March 15, 2022 09:17
-
-
Save dynnamitt/b342f726e4b1415cbd1965aa42b1fb13 to your computer and use it in GitHub Desktop.
GITLAB ::: git-clone ALL favs into deep-nested dirs (( curl | jq | parallel ))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Make sure you have a PRIVATE_TOKEN in the file ~/.gitlab_token | |
GL_TOKEN=$(cat ~/.gitlab_token) | |
[ -z $GL_TOKEN ] && (printf "\n\nno token!\n\n\n";exit 1) | |
# USERID from username ARG1 on command-line | |
USER_NAME=${1:-kjetil.midtlie} | |
USERID=$(curl "https://gitlab.com/api/v4/users?private_token=$GL_TOKEN&username=$USER_NAME" | jq -r '.[0]|.id') | |
ENDPOINT=starred_projects | |
#ENDPOINT=projects | |
cd ~ | |
curl "https://gitlab.com/api/v4/users/$USERID/$ENDPOINT?per_page=100&private_token=$GL_TOKEN" \ | |
| jq -r '.[] | .ssh_url_to_repo + "\t" + .path_with_namespace' \ | |
| parallel --colsep '\t' git clone {1} {2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git pull like this (from same root)
cd $HOME && find . -name '.git' -exec dirname {} \; | parallel git -C {} pull -v