-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-annotated-history
More file actions
executable file
·38 lines (36 loc) · 967 Bytes
/
git-annotated-history
File metadata and controls
executable file
·38 lines (36 loc) · 967 Bytes
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
#!/usr/bin/env bash
git_annotated_history () {
read -ra files <<<"$@"
if ! [ "${#files[@]}" ]
then
mapfile -t files < <(
find -s . -mindepth 1 -maxdepth 1 \
-not \( -wholename '*.git*' -type d \)
)
fi
filename_width=0
for filename in "${files[@]}"
do
filename="${filename/.\/}"
if [ "${#filename}" -gt "$filename_width" ]
then
filename_width="$((${#filename}+1))"
fi
done
for filename in "${files[@]}"
do
filename="${filename/.\/}"
info="$(git log -n 1 --relative-date --pretty=reference "$filename")"
if ! [ "$info" ]
then
if grep "$filename" .gitignore >/dev/null 2>&1
then
info='Ignored'
else
info='Untracked'
fi
fi
printf "%-$((filename_width))s%s\n" "$filename" "$info"
done
}
git_annotated_history "$*"