2

I have restored a Gitea backup. Everything seems to be fine except that clicking on URLs in the WebUI opens a URL only containing the hostname or a wrong URL (it is missing the repository part of the URL).

If I create a new repository, I can access it as usual when clicking the URL. If I manually type the URL of repositories (e.g. gitea.my-domain.de/username/reponame.git) I can access it.

My first attempt was setting a ROOT_URL in app.ini, but this did not work. Any Ideas?

Yun
  • 3,056
  • 6
  • 9
  • 28
vtmb
  • 21
  • 2

2 Answers2

3

This just happened to me and it looks to be because in the gitea database the owner_name column from the repository table gets dumped as NULL. Interestingly the owner_id column keeps the correct value.

I am using mysql(mariadb) and did the following:

USE gitea;
SELECT id, name, owner_id, owner_name FROM repository;

Inspect this output just to make sure it looks sane.

UPDATE repository INNER JOIN `user` ON `user`.id = repository.owner_id SET owner_name = `user`.name;

This will lookup and replace the user_name based on the user_id from the user table.

SELECT id, name, owner_id, owner_name FROM repository;

Just to make sure it worked. Compare the first output to the second.

I checked for issues on the gitea repo of github and didn't see any matching these symptoms. I will open a issue there later and link this article.

a7hybnj2
  • 31
  • 2
1

I had a similar issue and managed to solve it with the help of the previous answer by a7hybnj2.

My instance is running with an SQLite database, for which the update command needs to look like this:

UPDATE repository
SET owner_name = (SELECT name
          FROM `user`
          WHERE (repository.owner_id = `user`.id))
WHERE EXISTS (SELECT *
          FROM `user`
          WHERE (repository.owner_id = `user`.id));

The modification is necessary as SQLite syntax does not supporting INNER JOIN within an UPDATE.

teajay99
  • 36
  • 3
  • Remember to save the SQLite database before closing then run `sudo service gitea restart` to restart the Gitea service for your changes to take affect. – Matthew Aug 18 '21 at 13:53