Skip to content

Instantly share code, notes, and snippets.

@neerolyte
Last active October 31, 2018 02:32
Show Gist options
  • Save neerolyte/8c4989085523fa7f3fe35ef5b4bf23fa to your computer and use it in GitHub Desktop.
Save neerolyte/8c4989085523fa7f3fe35ef5b4bf23fa to your computer and use it in GitHub Desktop.

There's a lot of custom packages under https://gitlab.example.net/groups/example - I like to clone them all down to scan them every now and then.

First create an access token - https://gitlab.example.net/profile/personal_access_tokens .

Store it locally:

$ cat ~/.netrc 
machine gitlab.example.net
login youserbehere
password w0wTh1sIsmyr3alTokn1

Define a bash function to list out all repos (and ... test it's working):

curlrepos() {
    curl -s https://gitlab.example.net/api/v4/groups/example/projects?per_page=1000
}
extract_repo_paths() {
    php -r '$data = json_decode(stream_get_contents(STDIN), true); foreach ($data as $repo) { echo $repo["path"]."\n"; }'
}
getrepos() {
    curlrepos | extract_repo_paths
}

Clone 'em all!

getrepos | while read -r repo; do
    git clone "git@gitlab.example.net:/example/$repo"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment