-
Notifications
You must be signed in to change notification settings - Fork 3
/
oldCommits.sh
executable file
·77 lines (63 loc) · 2.19 KB
/
oldCommits.sh
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
#!/bin/bash
PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
#set -x
GetCommitSha()
{
#set -x
testDate=$1
sourceDate=$( date -I -d "$testDate - 1 day" )
pushd ~/HPCC-Platform
sha=$( git log --after="$sourceDate 00:00" --before="$testDate 00:00$" --merges | grep -A3 'commit' | head -n 1 | cut -d' ' -f2 )
until [[ -n "$sha" ]]
do
# step one day back
sourceDate=$( date -I -d "$sourceDate - 1 day" )
# Get SHA
sha=$( git log --after="$sourceDate 00:00" --before="$testDate 00:00$" --merges | grep -A3 'commit' | head -n 1 | cut -d' ' -f2 )
done
echo $sha
popd > /dev/null
#set +x
}
CWD=$( pwd )
targetFile="${PWD}/settings.inc"
firstDate="2023-09-16"
sourceDate=$firstDate
testDate=$( date -I -d "$firstDate + 1 day" )
lastDate="2023-09-19"
printf "from %s to %s\n" "$firstDate" "$lastDate"
printf "#\n" > ${targetFile}
printf "# from %s to %s\n#\n\n" "$firstDate" "$lastDate" >> ${targetFile}
pushd ~/HPCC-Platform
dayCount=0
commitConuts=0
mark=''
printf "Test date\tsource date\tcommit\n"
until [[ "$testDate" > "$lastDate" ]]
do
#cmd="git log --after="\""$d_after 00:00"\"" --before="\""$test_date 00:00$"\"" --merges"
#echo "cmd: $cmd"
commit=$( git log --after="$sourceDate 00:00" --before="$testDate 00:00" --merges | grep -A3 'commit' )
#echo "$commit"
sha=$( git log --after="$sourceDate 00:00" --before="$testDate 00:00" --merges | grep -A3 'commit' | head -n 2 | cut -d' ' -f2 )
if [[ -n "$sha" ]]
then
testSha=$sha
commitCounts=$(( $commitCounts + 1 ))
mark=''
else
mark="$mark +"
fi
printf "%s\t%s\t%s %s\n" "$testDate" "$sourceDate" "$testSha" "$mark"
printf "# test date:%s source date:%s\n" "$testDate" "$sourceDate" >> ${targetFile}
printf "#SHA=%s\n\n" "$testSha" >> ${targetFile}
sourceDate="$testDate"
testDate=$( date -I -d "$sourceDate + 1 day")
dayCount=$(( $dayCount + 1 ))
done
printf "day counts:%d, commit counts: %d\n" $dayCount $commitCounts
testDate=$( date -I -d "$firstDate + 6 days" )
sha=$( GetCommitSha "$testDate" )
printf "test date %s, sha: %s\n" "$testDate" "$sha"
popd
#set +x