-
Notifications
You must be signed in to change notification settings - Fork 23
/
git-update
executable file
·81 lines (55 loc) · 1.75 KB
/
git-update
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
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
. ~/.kdm/rc.d/text
_out() {
local COLUMN_COUNT
local BANNER_EQ1_LENGTH BANNER_EQ1_STRING
local BANNER_EQ2_LENGTH BANNER_EQ2_STRING
local BANNER_TXT_LENGTH BANNER_TXT_ODD
# Init variables
BANNER_TXT_ODD="FALSE"
# Get length of input string
BANNER_TXT_LENGTH="${#1}"
# Subtract the modulo to even it out
if [[ "$((BANNER_TXT_LENGTH%2))" != "0" ]]; then
BANNER_TXT_ODD="TRUE"
((BANNER_TXT_LENGTH--))
fi
# Get 1/2 the number of columns
COLUMN_COUNT="$(echo "scale=0; $(tput cols)/2" | bc)"
# Ceil 1/2 column count value at 120
[[ "${COLUMN_COUNT}" -gt "120" ]] && COLUMN_COUNT="120"
# Floor 1/2 column count value at 57
[[ "${COLUMN_COUNT}" -lt "57" ]] && COLUMN_COUNT="57"
# Calculate number of = characters for main portion
BANNER_EQ1_LENGTH="$((COLUMN_COUNT-BANNER_TXT_LENGTH))"
BANNER_EQ1_LENGTH="$((BANNER_EQ1_LENGTH-9))"
# Subtract 1 if input text was odd-numbered, to even it out
[[ "${BANNER_TXT_ODD}" == "TRUE" ]] && ((BANNER_EQ1_LENGTH--))
# Number of = characters for smaller portion
BANNER_EQ2_LENGTH="6"
# Create ===== strings
BANNER_EQ1_STRING="$(printf '%*s' ${BANNER_EQ1_LENGTH} '' | sed 's/\ /=/g')"
BANNER_EQ2_STRING="$(printf '%*s' ${BANNER_EQ2_LENGTH} '' | sed 's/\ /=/g')"
printf "\n${C_RED}%s${C_RST} ${C_WHT_BRT}%s${C_RST} ${C_RED}%s${C_RST}\n" "${BANNER_EQ1_STRING}" "${1}" "${BANNER_EQ2_STRING}"
}
_smf() {
git submodule foreach git "${@}"
}
if [[ "${1}" != "--no-json" ]]; then
_out "JSON backup"
./json-backup
fi
_out "Repo fetch"
git fetch --all --prune
_out "Repo pull"
git pull --prune
_out "Submodule fetch"
_smf fetch --all --prune
_out "Submodule checkout master"
_smf checkout master
_out "Submodule pull"
_smf pull
_out "Submodule status"
git submodule
_out "Repo status"
git status