-
Notifications
You must be signed in to change notification settings - Fork 8
/
gitpullrecursive
executable file
·90 lines (74 loc) · 1.62 KB
/
gitpullrecursive
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
82
83
84
85
86
87
88
89
90
#!/bin/bash
# 1st arg is the branch name
set -e # exit on failure
EXECDIR="$(pwd)"
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # The directory of this script
cd $SCRIPTDIR
function clearcache {
echo "...Clearing cache recursively"
find . -type d -name ".terragrunt-cache" -prune -exec rm -rf {} \;
echo "git status"
git status
}
function deinitsubmodules {
echo "...deinit submodules"
git submodule deinit -f $SCRIPTDIR
}
function initsubmodules {
echo "...submodule update"
git submodule update --init --recursive
}
function options {
branch=""
while [[ $# > 0 ]]; do
local key="$1"
clear_cache="false"
deinit_submodules="true"
init_submodules="false"
case "$key" in
--clear-cache)
clear_cache="true"
;;
--init-submodules)
init_submodules="true"
;;
--init-all)
init_submodules="true"
clear_cache="true"
;;
--skip-deinit)
deinit_submodules="false"
;;
--branch)
branch="$2"
shift
;;
# --help)
# print_usage
# exit
# ;;
*)
log_error "Unrecognized argument: $key"
print_usage
exit 1
;;
esac
shift
done
if [[ "$clear_cache" == "true" ]]; then
clearcache
fi
if [[ "$init_submodules" == "true" ]]; then
if [[ "$deinit_submodules" == "true" ]]; then
deinitsubmodules
fi
initsubmodules
fi
}
options "$@"
# git pull origin $branch --recurse
echo "...Submodule status"
git submodule status --recursive
cd ~
cd $EXECDIR
echo "Done pulling git repo."