-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommit_code_change.sh
More file actions
executable file
·75 lines (59 loc) · 2.11 KB
/
commit_code_change.sh
File metadata and controls
executable file
·75 lines (59 loc) · 2.11 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
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
source commons/commons.sh;
echo "================================================================================";
echo "> COMMIT CODE CHANGE..";
echo "--------------------------------------------------------------------------------";
BEFORE_DATE=$(date +%D-%X);
BEFORE_DATE_SEC=$(date +%s);
CURRENT_PATH=$(pwd);
CURRENT_DIRECTORY=$(basename ${CURRENT_PATH});
AGENCY_ID=$(basename -s -gradle ${CURRENT_DIRECTORY});
CONFIRM=false;
setIsCI;
setGradleArgs;
setGitCommitEnabled;
if [[ ${MT_GIT_COMMIT_ENABLED} != true ]]; then
echo "> Git commit NOT enabled.. SKIP";
exit 0 # success
fi
echo "> Git commit enabled ...";
cd app-android || exit;
./keys_cleanup.sh; # FAIL OK
cd ..;
setGitUser;
GIT_MSG="Sync code";
if [[ ${IS_CI} = true ]]; then
GIT_MSG="CI: sync code";
fi
echo "GIT_MSG: $GIT_MSG";
echo "> GIT submodule > add...";
git submodule foreach git add -v -A;
checkResult $?;
echo "> GIT submodule > add... DONE";
echo "> GIT submodule > commit '$GIT_MSG'...";
# git submodule foreach git commit -q -m "$GIT_MSG";
# git submodule foreach git diff-index --quiet HEAD || git commit -m "$GIT_MSG";
git submodule foreach "git diff-index --quiet HEAD || git commit -m '$GIT_MSG'";
checkResult $?;
echo "> GIT submodule > commit '$GIT_MSG'... DONE";
# TODO ? git submodule foreach git push;
echo "> GIT > add...";
git add -v -A; # needed for other files than git submodules
checkResult $?;
echo "> GIT > add... DONE";
echo "> GIT > git_commit_all_submodules.sh...";
./git_commit_all_submodules.sh;
checkResult $?;
echo "> GIT > git_commit_all_submodules.sh... DONE";
echo "> GIT > remaining repo files to commit (if no submodule change)...";
git diff-index --quiet HEAD || git commit -m "$GIT_MSG";
checkResult $?;
echo "> GIT > remaining repo files to commit (if no submodule change)... DONE";
# TODO ? git push;
printGitStatus;
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 "> COMMIT CODE CHANGE... DONE";
echo "================================================================================";