~jacksonchen666/gitlab-archive-all-projects

a1f924b54af237d7d3beafb548a634397230b86a — Jackson Chen 1 year, 13 days ago 96eb2e1
add mirror clone script
1 files changed, 26 insertions(+), 0 deletions(-)

A git-mirror-repos/mirror_clone.sh
A git-mirror-repos/mirror_clone.sh => git-mirror-repos/mirror_clone.sh +26 -0
@@ 0,0 1,26 @@
#!/bin/bash
set -ex
cd "$(dirname "$0")"
# USAGE: <HTTPS|SSH|NONE> <full path...>
# first argument specifies cloning method, NONE to bypass any changes
type=$1

[ "$type" = "" ] && { echo "$0: what type of cloning do you want? expected 'HTTPS' or 'SSH' but got '$1'"; exit 1; }
[ "$2" = "" ] && { echo "$0: i need some full paths to clone where is it"; exit 1; }

for path in ${@:2}; do
    # bash is not a real enough programming language
    url="$path"
    if [ "$type" = "HTTPS" ]; then
        url="https://gitlab.com/${url}.git"
    elif [ "$type" = "SSH" ]; then
        url="git@gitlab.com:${url}.git"
    elif [ "$type" = "NONE" ]; then
        true # placeholder statement so it doesn't complain
    else
        echo "$0: what type of cloning do you want? expected 'HTTPS' or 'SSH' but got '$1'"
        exit 1
    fi
    echo $url;
    git clone --mirror "$url"
done