Created
July 25, 2017 18:49
-
-
Save syldrathecat/6fb00e80122600a72c1583013ccafb3d to your computer and use it in GitHub Desktop.
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/bash | |
function usage() | |
{ | |
echo "Usage: $0 remote directory" >&2 | |
exit 1 | |
} | |
if [ $# -lt 2 ]; then | |
usage | |
fi | |
REMOTE=$1 | |
REPO=$2/`basename $2`.git | |
GIT="git -C $REPO" | |
if [ -d $REPO ]; then | |
rmdir $REPO || echo "Aborting: $REPO already exists" >&2 | |
exit 1 | |
fi | |
mkdir -p $REPO || exit 1 | |
$GIT init --bare || exit 1 | |
$GIT remote add origin $REMOTE || exit 1 | |
TAGLIST=$($GIT ls-remote --quiet --tags | awk '$2 !~ /\^/ {tag = $2; sub(/^refs\/tags\//, "", tag); print $2,tag}') || exit 1 | |
TAG=$(whiptail --notags --menu "Select latest release" 0 0 0 $TAGLIST 3>&1 1>&2 2>&3) || exit 1 | |
$GIT fetch --depth=1 origin $TAG:$TAG || exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment