-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-install.sh
More file actions
executable file
·72 lines (49 loc) · 1.46 KB
/
git-install.sh
File metadata and controls
executable file
·72 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
REPO_NAME=git-get
TEMP_DIR="${TMPDIR:-/tmp}"
REPO_PARENT_DIR=$(mktemp -d "${TEMP_DIR}"/XXXXXXXXX)
REPO_ROOT_PATH="$REPO_PARENT_DIR/$REPO_NAME"
die() {
echo "$*" 1>&2
exit 1
}
get_latest_tag() {
# Get new tags from the remote
git fetch --tags
# Get the latest tag name
local latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "$latest_tag"
return 0
}
clone() {
local branch
cd "${REPO_PARENT_DIR}"
git clone --no-checkout https://github.com/ajdruff/${REPO_NAME}.git || die "git-get: something went wrong trying to download installation files. Check your connection and try again"
cd "${REPO_ROOT_PATH}"
if [ -z "${1}" ]; then
branch=$(get_latest_tag)
else
branch="${1}"
fi
# Checkout the latest tag
git checkout -b "${branch}"
cd -
return 0
}
install() {
echo 'installing git-get...'
local install_dir=$(dirname $(which git))
if [ -d "$REPO_ROOT_PATH/dist" ]; then
echo 'installing production build..'
sudo install "$REPO_ROOT_PATH/dist/git-get" "${install_dir}"/
else
echo 'installing development build...'
sudo install "$REPO_ROOT_PATH/git-get" "${install_dir}"/
sudo install "$REPO_ROOT_PATH/parser/parser-build.sh" "${install_dir}"/
fi
return 0
}
clone;
install;
rm -rf "$REPO_ROOT_PATH"
(git get -h && git get -v && echo 'git get installed!') || die "git-get installation failed"