2013-12-05 18:11:33 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# usage: $0 [weekly|monthly|quarterly] < filenames
|
|
|
|
# sorts files of the form VENDOR/BOARD/COMMIT/DATE/revision.txt
|
|
|
|
# into buckets of the given granularity
|
|
|
|
|
|
|
|
weekly() {
|
2014-01-02 09:19:21 +01:00
|
|
|
date --date="$1" +%GW%V
|
2013-12-05 18:11:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
monthly() {
|
|
|
|
date --date="$1" +%Y-%m
|
|
|
|
}
|
|
|
|
|
|
|
|
quarterly() {
|
|
|
|
date --date="$1" "+%Y %m" | awk '{ q=int(($2-1)/3+1); print $1 "Q" q}'
|
|
|
|
}
|
|
|
|
|
|
|
|
# TODO: restrict $1 to allowed values
|
|
|
|
|
|
|
|
curr=""
|
|
|
|
sort -r -k4 -t/ | while read file; do
|
2016-02-22 03:01:57 +01:00
|
|
|
timestamp=`printf $file | cut -d/ -f4 | tr _ :`
|
2013-12-05 18:11:33 +01:00
|
|
|
new=`$1 $timestamp`
|
|
|
|
if [ "$new" != "$curr" ]; then
|
|
|
|
if [ "$curr" != "" ]; then
|
|
|
|
printf "\n"
|
|
|
|
fi
|
|
|
|
printf "$new:"
|
|
|
|
curr=$new
|
|
|
|
fi
|
|
|
|
printf "$file "
|
|
|
|
done
|
|
|
|
printf "\n"
|