47777569d2
The last few days of the year might belong to the first week of the new year in the ISO week numbering scheme. GNU date accounts for that with different-than-usual notation. Change-Id: I8047c197971077a845d6c1fdc9da6eb9f3741539 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/4610 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
34 lines
634 B
Bash
Executable file
34 lines
634 B
Bash
Executable file
#!/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() {
|
|
date --date="$1" +%GW%V
|
|
}
|
|
|
|
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
|
|
timestamp=`printf $file | cut -d/ -f4`
|
|
new=`$1 $timestamp`
|
|
if [ "$new" != "$curr" ]; then
|
|
if [ "$curr" != "" ]; then
|
|
printf "\n"
|
|
fi
|
|
printf "$new:"
|
|
curr=$new
|
|
fi
|
|
printf "$file "
|
|
done
|
|
printf "\n"
|
|
|