-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode_sync.sh
More file actions
executable file
·65 lines (52 loc) · 2.41 KB
/
code_sync.sh
File metadata and controls
executable file
·65 lines (52 loc) · 2.41 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
#!/bin/bash
SCRIPT_DIR="$(dirname "$0")";
source ${SCRIPT_DIR}/commons.sh;
echo "================================================================================";
echo "> CODE SYNC...";
echo "--------------------------------------------------------------------------------";
# TODO rename "git repo sync"
BEFORE_DATE=$(date +%D-%X);
BEFORE_DATE_SEC=$(date +%s);
# GIT SUBMODULEs
setGitProjectName;
setGitBranch;
setIsCI;
setGitCommitEnabled;
setGitCommitDependencyUpdateEnabled;
if [[ ${MT_GIT_COMMIT_ENABLED} != true && ${MT_GIT_COMMIT_DEPENDENCY_UPDATE_ENABLED} != true ]]; then
echo "> Git commit NOT enabled.. SKIP (MT_GIT_COMMIT_ENABLED:$MT_GIT_COMMIT_ENABLED|MT_GIT_COMMIT_DEPENDENCY_UPDATE_ENABLED:$MT_GIT_COMMIT_DEPENDENCY_UPDATE_ENABLED)";
exit 0 # success
fi
echo "> Git commit enabled ...";
echo "> Fetching latest from submodules...";
git submodule foreach git fetch -v --all;
echo "> Fetching latest from submodules... DONE";
echo "--------------------------------------------------------------------------------";
git submodule foreach git branch -v -a;
echo "--------------------------------------------------------------------------------";
echo "> Switching to branch '$GIT_BRANCH' (or '$DEFAULT_GIT_BRANCH')...";
git submodule foreach "git switch $GIT_BRANCH || git switch $DEFAULT_GIT_BRANCH";
RESULT=$?;
if [[ ${RESULT} -ne 0 ]]; then
echo "> Error while switching to branch '$GIT_BRANCH' (or '$DEFAULT_GIT_BRANCH') in submodules!";
exit ${RESULT};
fi
echo "> Switching to branch '$GIT_BRANCH' (or '$DEFAULT_GIT_BRANCH')... DONE";
echo "--------------------------------------------------------------------------------";
echo "--------------------------------------------------------------------------------";
echo "> Pulling latest from submodules...";
git submodule foreach "git pull -v --ff-only";
RESULT=$?;
if [[ ${RESULT} -ne 0 ]]; then
echo "> Error while pulling latest from submodules!";
exit ${RESULT};
fi
echo "> Pulling latest from submodules... DONE";
echo "--------------------------------------------------------------------------------";
echo "--------------------------------------------------------------------------------";
AFTER_DATE=$(date +%D-%X);
AFTER_DATE_SEC=$(date +%s);
DURATION_SEC=$(($AFTER_DATE_SEC-$BEFORE_DATE_SEC));
echo "> $DURATION_SEC secs FROM $BEFORE_DATE TO $AFTER_DATE";
echo "> CODE SYNC... DONE";
echo "================================================================================";