Mike Gerwitz's Thoughts and Ramblings
Mike Gerwitz's Thoughts and Ramblings
EOH
prevdate=
lastts=
firstyear=
lastyear=
lasthash=
# generate index
while read hash commit ts id subject; do
echo "Found $commit: $subject" >&2
dateout="$( printf "%(%Y-%m-%d)T" "$ts" )"
dategroup="${dateout%-*}"
day="${dateout##*-}"
month="$( printf "%(%m)T" "$ts" )"
year="${dateout%%-*}"
# commits are ordered by date desc
lasthash="${lasthash:-$hash}"
lastts="${lastts:-$ts}"
lastyear="${lastyear:-$year}"
firstyear="$year"
pagefile="$year/$month/$id.html"
fmtsubject="$( ./msgfmt < <( echo "$subject"; echo ) )"
[ "$prevdate" == "$dategroup" ] || {
echo "$dategroup
"
}
printf '' \
"$day" "$pagefile" "$fmtsubject"
prevdate="$dategroup"
# create the containing directory (if it does not yet exist and then generate
# the commit page
mkdir -p "$( dirname "$pagefile" )" \
&& (
# make the majority of the data available as environment variables (for
# convenience), lowercase so as not to be conflict with conventional
# environment variables
export hash commit id subject="$fmtsubject" timestamp="$ts"
export dategroup month day year
# invoke template
"$repotype"/commit2html "$commit" | ./tpl/commit.sh
) > "$path_out/$pagefile"
done
yearrange="$firstyear"
if [ "$lastyear" -gt "$firstyear" ]; then
yearrange="$firstyear–$lastyear"
fi
cat <
EOF