#!/bin/sh

[ "$4" = "W" ] || exit 0

cd "$GL_REPO_BASE/$2.git"
head=$(git symbolic-ref HEAD)

if ! [ -f "$head" ]; then
    set -- refs/heads/*
    if [ "$#" -eq 1 ]; then
        git symbolic-ref HEAD "$1"
        echo "NOTICE: Default branch set to $1" >&2
    else
        echo "WARNING: The default branch is $head, but no such branch exists" >&2
    fi
fi

git log -1 --all --date-order --format=%ci >agefile