-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshipgit-update
More file actions
48 lines (40 loc) · 1.45 KB
/
Copy pathshipgit-update
File metadata and controls
48 lines (40 loc) · 1.45 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
#!/usr/bin/env bash
usage() {
MAIN_BRANCH=$(git config --get shipgit.branch.main)
PRODUCTION_BRANCH=$(git config --get shipgit.branch.production)
echo "usage: shipgit update"
echo "This will pull latest changes from remote $MAIN_BRANCH and $PRODUCTION_BRANCH."
}
cmd_help() {
usage
exit 0
}
cmd_default() {
local initialized=$(git config --get shipgit.initialized)
if [ "$initialized" != "true" ]; then
echo "+++++++++++++++++++++++ ATTENTION +++++++++++++++++++++++"
echo ""
echo "shipgit can only be used inside a shipgit initialized directory."
echo "Run shipgit init to initialize."
echo ""
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
exit 0
fi
CURRENT_BRANCH=$(git branch --show-current)
MAIN_BRANCH=$(git config --get shipgit.branch.main)
PRODUCTION_BRANCH=$(git config --get shipgit.branch.production)
echo "========================== Syncing =========================="
echo ""
echo "Steps:"
git checkout -q "$MAIN_BRANCH" &> /dev/null
git pull origin "$MAIN_BRANCH" &> /dev/null
git fetch --tags &> /dev/null
echo " 1. Pulled latest changes from remote $MAIN_BRANCH."
git checkout -q "$PRODUCTION_BRANCH" &> /dev/null
git pull origin "$PRODUCTION_BRANCH" &> /dev/null
git fetch --tags &> /dev/null
echo " 2. Pulled latest changes from remote $PRODUCTION_BRANCH."
git checkout -q "$CURRENT_BRANCH" &> /dev/null
echo ""
echo "============================================================="
}