Skip to content

Commit 1f74418

Browse files
committed
EasyKey.git diff since date time optimized
1 parent ba8c770 commit 1f74418

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

EasyKey.git/ezk-git-diff.sh

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,14 @@ function showCommits () {
6868
}
6969

7070
function diffDate () {
71-
echo "Enter date since in [yyyy-mm-dd]:"
71+
echo "Enter date since in [yyyy-mm-dd hh:mm:ss]:"
7272
read sincedate
73-
lastcommitdate=$(git log --pretty=format:'%h %ad' --graph --date=format:"%Y-%m-%d" --since "$sincedate 00:00:00" | cut -f3 -d' ' | tail -1) # the last commit date since the date given
74-
echo "first commit date equal or after since date: $lastcommitdate"
75-
commitpriortolast=$(git log --pretty=format:'%h %ad' --graph --date=format:"%Y-%m-%d" | grep "$lastcommitdate" -A 1 | tail -1 | cut -f2 -d' ') # commit before the last commit in period
76-
echo "next commit date prior since date: $commitpriortolast"
77-
commitdatepriortolast=$(git log --pretty=format:'%h %ad' --graph --date=format:"%Y-%m-%d" | grep "$lastcommitdate" -A 1 | tail -1 | cut -f3 -d' ') # commit date before the last commit in period
78-
echo "next commit date prior since date: $commitpriortolast ... on: $commitdatepriortolast"
79-
newestcommit=$(git log --pretty=format:'%h %ad' --graph --date=format:"%Y-%m-%d" | head -1 | cut -f2 -d' ') # the newest commit in the branch (actual head state)
80-
echo "latest commit in this branch hstory: $newestcommit"
81-
newestcommitdate=$(git log --pretty=format:'%h %ad' --graph --date=format:"%Y-%m-%d" | head -1 | cut -f3 -d' ') # the newest commit date
82-
coloredLog "changes since $sincedate 12 a.m. / midnight: comparing commit $commitpriortolast made on $commitdatepriortolast against $newestcommit (latest commit) made on $newestcommitdate"
83-
diffDrillDownAdvanced "git diff --name-status $commitpriortolast $newestcommit" "awk '{print \$2}'" "$commitpriortolast" "$newestcommit"
73+
[ "${sincedate}" = "" ] && waitonexit && return
74+
sincedate=$(echo "$sincedate" | cut -d' ' -f1)
75+
sincetime=$(echo "$sincedate" | cut -d' ' -f2)
76+
newestcommit=$(git log --pretty=format:'%h %ad' --date=format:"%Y-%m-%d %H:%M:%S" --since "2024-03-20 12:00:00" | head -1 | cut -d' ' -f1)
77+
thatcommit=$(git log --pretty=format:'%h %ad' --date=format:"%Y-%m-%d %H:%M:%S" --since "2024-03-20 12:00:00" | tail -1 | cut -d' ' -f1)
78+
diffDrillDownAdvanced "git diff --name-status $newestcommit $thatcommit" "awk '{print \$2}'" "$commitpriortolast" "$newestcommit"
8479
#git log --oneline | grep --color -E 'Add slack integration to pipeline|$'
8580
# why git log is so strange: http://stackoverflow.com/questions/14618022/how-does-git-log-since-count why
8681
# alternative: git diff 'HEAD@{2017-03-03T00:00:00}' HEAD --name-status | nl

0 commit comments

Comments
 (0)