-
-
Notifications
You must be signed in to change notification settings - Fork 807
/
Copy pathfilename_changes
executable file
·52 lines (49 loc) · 985 Bytes
/
filename_changes
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
#!/usr/bin/env bash
#
# Prints filename changes.
#
# <weekday> <month> <day> <time> <year> <first_name> <last_name> <original_filename> <new_filename> <%>
# * `git log --reverse`
# - Show commit logs in reverse order.
# * `--find-renames`
# - Find file renames.
# * `--name-status`
# - Show only names.
# * `--diff-filter R`
# - Only select files which are renamed (R).
# * `--format=format:""`
# - Format the log.
# * `--date=format:""`
# - Format the date.
# * `awk '{}'
# - Process each commit.
git log \
--reverse \
--find-renames \
--name-status \
--diff-filter R \
--format=format:"%ad %aN" \
--date=format:"%a %b %d %T %Y" \
| awk '
# Skip empty lines:
NF == 0 {
next
}
# Date lines:
! /^R/ {
date = $0
next
}
# Filename changes:
{
pct = substr($1, 2)
if (match(pct, /^0[1-9]/)) {
pct = substr(pct, 2)
} else if (match(pct, /^00[1-9]/)) {
pct = substr(pct, 2)
} else if (match(pct, /^000/)) {
pct = 0
}
print date OFS $2 OFS $3 OFS pct
}
'