blob: e85fc3ef8c94bfee885c6a789dbb1d884f7c3e3e [file] [log] [blame]
Patrick Georgi274c6c22013-12-05 18:11:33 +01001#!/bin/sh
2# usage: $0 [weekly|monthly|quarterly] < filenames
3# sorts files of the form VENDOR/BOARD/COMMIT/DATE/revision.txt
4# into buckets of the given granularity
5
6weekly() {
Patrick Georgi47777562014-01-02 09:19:21 +01007 date --date="$1" +%GW%V
Patrick Georgi274c6c22013-12-05 18:11:33 +01008}
9
10monthly() {
11 date --date="$1" +%Y-%m
12}
13
14quarterly() {
15 date --date="$1" "+%Y %m" | awk '{ q=int(($2-1)/3+1); print $1 "Q" q}'
16}
17
18# TODO: restrict $1 to allowed values
19
20curr=""
21sort -r -k4 -t/ | while read file; do
22 timestamp=`printf $file | cut -d/ -f4`
23 new=`$1 $timestamp`
24 if [ "$new" != "$curr" ]; then
25 if [ "$curr" != "" ]; then
26 printf "\n"
27 fi
28 printf "$new:"
29 curr=$new
30 fi
31 printf "$file "
32done
33printf "\n"