A memo on fixing Gitea repository last updated time
Go to file
Gregory Eremin 669368e16d Initial commit 2024-02-27 21:29:00 +01:00
README.md Initial commit 2024-02-27 21:29:00 +01:00

README.md

Update Gitea repo last updated time

Silly Gitea considers repositories updated when their description or other properties are updated. I prefer last update time to indicate the last commit instead. This script generates SQL that can be used to fix this discrepancy.

Use

Connect to the gitea container, e.g. docker exec -it gitea /bin/bash

Allow executing commands on repos:

git config --global --add safe.directory '*'

Run the following script to generate update statements:

#!/bin/bash

OWNER=localhots

cd /data/git/repositories/$OWNER
for d in */; do
	cd $d && ts=$(git --no-pager log -1 --format="%at") && cd - >/dev/null
	repo=${d::-5} # Trim .git suffix
    echo "UPDATE repository SET updated_unix=$ts WHERE owner_name='$OWNER' AND name='$repo';"
done

Connect to the Postgres container, e.g. docker exec -it gitea-postgres /bin/bash and execute the statements from the previous step. Done.