forked from holatuwol/liferay-faster-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
githashtime
executable file
·55 lines (42 loc) · 1.42 KB
/
githashtime
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
#!/bin/bash
dirnames() {
python $(dirname "${BASH_SOURCE[0]}")/dirnames.py
}
githashtime() {
local CURRENT_HASH=$(git log -1 --pretty='%H')
. $(dirname "${BASH_SOURCE[0]}")/getparent
BASELINE_HASH=
if [ -f ${LIFERAY_HOME}/baseline.txt ]; then
BASELINE_HASH=$(cat "${LIFERAY_HOME}/baseline.txt")
elif [ "" != "${BASE_TAG}" ]; then
BASELINE_HASH=${BASE_TAG}
else
BASELINE_HASH=${BASE_BRANCH}
fi
$(dirname "${BASH_SOURCE[0]}")/gitchanges ${BASELINE_HASH} ${CURRENT_HASH}
local REFERENCE_HASH=
local FOLDER=
if [ -d $1 ]; then
FOLDER=$1
REFERENCE_HASH=$(git log -1 --pretty='%H' ${BASELINE_HASH} -- ${FOLDER})
else
FOLDER=.
REFERENCE_HASH=${BASELINE_HASH}
fi
echo "Resetting timestamps for ${FOLDER} to reference hash ${REFERENCE_HASH}..."
if [ "." == "${FOLDER}" ]; then
(
sed -n '/target name="deploy"/,/\/target/p' ${GIT_ROOT}/build.xml | grep -F 'ant dir' | grep -F 'target="deploy"' | cut -d'"' -f 2
git ls-files ${GIT_ROOT}/modules | grep -F .lfrbuild-portal | dirnames
if [ -f git-commit-portal ]; then
git ls-tree -r --name-only $(cat git-commit-portal) -- ${GIT_ROOT}/modules | grep -F .lfrbuild-portal | dirnames
fi
) | python $(dirname ${BASH_SOURCE[0]})/githashtime.py ${REFERENCE_HASH} ${FOLDER}
else
echo ${FOLDER} | python $(dirname ${BASH_SOURCE[0]})/githashtime.py ${REFERENCE_HASH} ${FOLDER}
fi
}
setopts() {
. $(dirname ${BASH_SOURCE[0]})/setopts
}
setopts && githashtime $@