-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_gitlogs
More file actions
42 lines (37 loc) · 1 KB
/
update_gitlogs
File metadata and controls
42 lines (37 loc) · 1 KB
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
#!/bin/sh
# gitlog's update_gitlog script, run from cron daily
# set -x
BD=/srv/gitlogs
AFTER=${1:-"yesterday 0:00"}
BEFORE=${2:-"today 0:00"}
LOGALL=
umask 022
for i in *.git
do
LOG=$(git --git-dir $i log --all --after="$AFTER" --before="$BEFORE" --pretty=format:%ad --date=short)
if [ -n "$LOG" ]; then
[ -z "$LOGALL" ] && LOGALL="$LOG" || LOGALL="$LOGALL\n$LOG"
GD="${i%.git}"
FO="$BD/$GD"
mkdir -p "$FO"
find "$FO" -type f -not -name "git.log" -delete
echo -e "$LOG" | sort | uniq -c >> "$FO/git.log"
CURBR=$(git --git-dir $i branch --show-current)
for readme in $(git --git-dir $i ls-tree -r "$CURBR" --name-only | grep -Ei '^(install|readme)\.(txt|md)$')
do
git --git-dir $i archive "$CURBR" "$readme" | tar -xO >> "$FO/$readme"
done
fi
done
if [ -n "$LOGALL" ]; then
echo -e "$LOGALL" | sort | uniq -c >> $BD/git.log
fi
# cleanup old gitlogs
for i in $BD/*
do
if [ -d $i ]; then
GD="$(basename $i)"
[ ! -d $HOME/$GD.git ] && rm -rf $i
fi
done
exit 0