Commit f1fffcfa authored by Zach van Rijn's avatar Zach van Rijn
Browse files

cgit.a.o: implement 'idle' to mean time since most recent commit to any branch

parent 772ef50d
......@@ -18,20 +18,30 @@ mkdir -p "${DATA}";
#
sync ()
{
# cache server response
# TODO: support pagination
##
# Cache GitLab API server response (JSON) as pre-parsed CSV data.
# TODO: support pagination (API supports max 100 results per page).
#
curl -s ${GLAB}/api/v4/groups/${1}/projects?per_page=100 \
| jq -r '.[] | select(.archived == false) | .http_url_to_repo + "%" + .description' > "${KEEP}";
# clone, pull, and/or update descriptions for current repositories
##
# Clone, pull, and/or update descriptions for current repositories.
#
while read k; do
(
repo=${k%\%*};
name=${repo##*/};
desc=${k#*\%};
cd "${DATA}";
mkdir -p ${1};
cd ${1};
##
# Core data.
#
if ! test -d ${name%.*}; then
mkdir ${name%.*};
git clone --mirror ${repo} ${name%.*}/.git;
......@@ -40,7 +50,28 @@ sync ()
else
git -C ${name%.*} remote update --prune;
fi
##
# Write repository description from GitLab API for cgit to read.
#
printf > ${name%.*}/.git/description "%s" "${desc}";
##
# Delete '.git/refs/' directory contents (cgit uses 'packed-refs' when empty).
# Find time of latest commit to any branch, and set 'packed-refs' mtime to it.
#
find ${name%.*}/.git/refs -type f -delete;
when=$(git -C ${name%.*} --no-pager branch -al \
| sed -e 's/*//g' \
| while read b; do git -C ${name%.*} --no-pager log -1 --format=%cd --date=unix ${b}; done \
| sort -nr \
| head -n 1 \
);
touch --date=@${when} ${name%.*}/.git/packed-refs;
##
# Mark as wanting to keep this repository during cleanup.
#
printf >> "${HAVE}" "%s/%s\n" "${1}" "${name%.*}";
)
done < "${KEEP}";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment