forked from zwave-js/node-zwave-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-git.sh
54 lines (49 loc) · 1.74 KB
/
setup-git.sh
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
#!/bin/bash
RED='\033[1;31m'
GREEN='\033[0;32m'
BLUE='\033[1;34m'
GRAY='\033[1;30m'
NC='\033[0m'
echo ""
echo -e "${GREEN}==================================================${NC}"
echo -e "${GREEN} Welcome to the Z-Wave JS GitPod! ${NC}"
echo -e "${GREEN}==================================================${NC}"
echo ""
echo "Just a few more questions to help you get started..."
echo ""
while true; do
read -p "Have you already forked the repo? (y/n) " fork
case $fork in
[Yy]* ) break;;
[Nn]* )
echo -e "${BLUE}Please open https://github.com/zwave-js/node-zwave-js/fork in another browser window and select your account as the destination.${NC}"
read -p "Press ENTER when the fork was created... "
break;;
* ) echo -e "${RED}Please answer yes (y) or no (n)!${NC}";;
esac
done
while true; do
read -p "What is your GitHub username? " username
if [[ -z "$username" ]]; then
echo -e "${RED}Please enter a username!${NC}"
else
break;
fi
done
echo -e "${BLUE}Setting up git remotes for you...${NC}"
git remote set-url origin "https://github.com/$username/node-zwave-js"
git fetch origin
echo ""
echo -e "Your fork is now configured as ${BLUE}origin${NC}, the original repo as ${BLUE}upstream${NC}"
echo ""
if [[ "$(git rev-parse --abbrev-ref HEAD)" == "master" ]]; then
if [[ "$(git rev-list --left-right --count HEAD...origin/master | cut -f2)" != "0" ]]; then
echo -e "Your fork's master branch seems to be out of sync. To update it, execute these commands:"
echo -e "${GRAY} git fetch upstream${NC}"
echo -e "${GRAY} git reset --hard upstream/master${NC}"
echo -e "${GRAY} git push --force origin master${NC}"
echo -e ""
echo -e "${RED}WARNING: This will overwrite changes in your master branch!${NC}"
echo -e ""
fi
fi