Gitea: 1.10.0 (release)
Importing a local repository from the API seems to miss certain steps. When I do:
curl -X POST https://git.xxx.com.ar/api/v1/repos/migrate -H 'accept: application/json' \
-H 'Authorization: token xxxxxxxx' -H 'Content-Type: application/json' \
-d '{ "clone_addr": "/home/xxxxx/convert/projectxxxx", "description": "Project XXX",
"mirror": false, "private": true, "repo_name": "projectxxx", "uid": 9}' -i
The call succeeds and I get the expected JSON response (new repo ID: 103), but when I use the UI to see the repository I get a 500 Server Error. The log shows:
2019/11/25 11:21:23 routers/repo/view.go:376:Home() [E] models.GetMigratingTask: task is not exist [id: 0, repo_id: 103, type: 0]
The record in the database was created and the _directory_ for the repo was created too (sorry, I couldn't check any further because this was my prod site and I was in a hurry). The row in the database was:
gitea=# select * from repository where id = 103;
id | owner_id | lower_name | name | description | website | default_branch | num_watches | num_stars | num_forks | num_issues | num_closed_issues | num_pulls | num_closed_pulls | num_milestones | num_closed_milestones | is_private | is_empty | is_archived | is_mirror | is_fork | fork_id | size | is_fsck_enabled | close_issues_via_commit_in_any_branch | topics | created_unix | updated_unix | avatar | original_url | status | original_service_type
-----+----------+----------------+----------------+------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+----------+-------------+-----------+---------+---------+---------+-----------------+---------------------------------------+--------+--------------+--------------+--------+--------------+--------+-----------------------
103 | 9 | xxxxxxxxxxxxxx | xxxxxxxxxxxxxx | XXXXXXXXXXXXXXXX | | master | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | t | f | f | f | f | 0 | 4741120 | t | f | null | 1574691626 | 1574691627 | | | 1 | 0
(1 row)
I am using gitea 1.10 linux-amd64 and am facing the same problem after migrating private and public github repositories with this script: https://jpmens.net/2019/04/15/i-mirror-my-github-repositories-to-gitea/ . This script is using the rest api. The problem seems to exist for every of these repositories (I have only verified some of these).
The problem is not reproducible with 1.9.6.
Console output when triggering the migration (for one of the repositories):
[Macaron] 2019-12-05 18:29:59: Completed POST /api/v1/repos/migrate 201 Created in 5.224582117s
[Macaron] 2019-12-05 18:29:59: Started POST /api/v1/repos/migrate for 127.0.0.1
Afterwards the directory ~/git-repositories
contains the cloned git repository. An issued git rev-list --all --objects | sha1sum
command on both the original repository and the gitea mirrored repository does return the same value.
Console output when opening the according gitea repository page in browser:
[Macaron] 2019-12-05 19:22:22: Started GET /mrtwnklr/mrtwnklr-ansible-playbook-warship-proof-of-concept-environment for 127.0.0.1
[Macaron] 2019-12-05 19:22:22: Completed GET /mrtwnklr/mrtwnklr-ansible-playbook-warship-proof-of-concept-environment 500 Internal Server Error in 29.240684ms
Log output when opening gitea repository page in browser:
2019/12/05 18:19:51 routers/repo/view.go:376:Home() [E] models.GetMigratingTask: task is not exist [id: 0, repo_id: 62, type: 0]
@mrtwnklr have you used v1.10.0?
I have the same issue with 1.10.1 (current Docker image version for 1.10). I tried to import local repositories using the API, the repos are there I just get a 500 error and the GetMigratingTask: task is not exist
error in the log.
I found a small workaround.
gitea=# select * from task;
id | doer_id | owner_id | repo_id | type | status | start_time | end_time | payload_content | errors | created
----+---------+----------+---------+------+--------+------------+----------+-----------------+--------+---------
(0 rows)
RepositoryBeingMigrated
to RepositoryReady
gitea=# update repository set status = 0 where status = 1;
UPDATE 1
It seems the api method doesn't run this code https://github.com/go-gitea/gitea/blob/1615b3c1874932c08d504fcc111f46105a2207b6/models/task.go#L222-L240 for some reason when importing local repositories.
Another workaround if you're setting up a new Gitea installation: I used 1.9 to import and then upgraded to 1.10.
Fixed in #9511
Most helpful comment
Fixed in #9511