A memo on fixing Gitea repository last updated time
Go to file
Gregory Eremin ebdb5f3a6a Initial commit 2024-02-27 21:30:00 +01:00
README.md Initial commit 2024-02-27 21:30: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.

Start the Postgres client, e.g. psql -U gitea gitea.

Execute the statements from the previous step.

Done.