Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit hooks not recreated after migrating from gogs #16202

Open
2 of 6 tasks
Silberling opened this issue Jun 19, 2021 · 1 comment
Open
2 of 6 tasks

commit hooks not recreated after migrating from gogs #16202

Silberling opened this issue Jun 19, 2021 · 1 comment
Labels
topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them

Comments

@Silberling
Copy link

Silberling commented Jun 19, 2021

  • Gitea version (or commit ref): 1.14.3
  • Git version:
  • Operating system: debian rpi4 docker gitea/gitea:1.14.3
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist: Migration log got lost after a temporary migration container was automatically removed. But here is my note for the commands to run: https://gist.github.com/Silberling/228cfbe8d74214d4e82f84676c256787

Description

I just migrated from latest gogs 0.12.3 to gitea 1.0.2 -> 1.14.3 as documented here: (https://docs.gitea.io/en-us/upgrade-from-gogs/) - hopefully correct.

I got a bunch of warnings documented here: (https://docs.gitea.io/en-us/command-line/#doctor-recreate-table) related issue is #16201.

Problem

bash-5.1# git push
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 4 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.08 KiB | 550.00 KiB/s, done.
Total 6 (delta 1), reused 0 (delta 0)
remote: ./hooks/pre-receive.d/pre-receive: line 2: /app/gogs/gogs: No such file or directory
To https://HOSTNAME/USER/REPO.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://HOSTNAME/USER/REPO.git'

I did gitea admin regenerate hooks but the error remains.

bash-5.1# grep -Hnri gogs /data
/data/git/repositories/USER/REPOABC.git/hooks/pre-receive.d/pre-receive:2:"/app/gogs/gogs" hook --config='/data/gogs/conf/app.ini' pre-receive
/data/git/repositories/USER/REPOABC.git/hooks/post-receive.d/post-receive:2:"/app/gogs/gogs" hook --config='/data/gogs/conf/app.ini' post-receive
/data/git/repositories/USER/REPOXYZ.git/hooks/pre-receive.d/pre-receive:2:"/app/gogs/gogs" hook --config='/data/gogs/conf/app.ini' pre-receive
/data/git/repositories/USER/REPOXYZ.git/hooks/post-receive.d/post-receive:2:"/app/gogs/gogs" hook --config='/data/gogs/conf/app.ini' post-receive

[...] # as it seems for every repository

As far as I understand the documentation this should recreate the hooks.

I might be doing something wrong here but if I understand the documentation correctly, the hooks should be recreated but they don't change after running gitea admin regenerate hooks or using the function in the Web UI.

@Silberling
Copy link
Author

Silberling commented Jun 19, 2021

Solution and explanation

gitea admin regenerate hooks seems to create hooks like this structure

/data/git/repositories/USER/REPOSITORY.git/hooks/pre-receive.d # DIRECTORY
/data/git/repositories/USER/REPOSITORY.git/hooks/pre-receive.d/gitea # ACTUAL SCRIPT
/data/git/repositories/USER/REPOSITORY.git/hooks/update.d # ...
/data/git/repositories/USER/REPOSITORY.git/hooks/update.d/gitea # ...
/data/git/repositories/USER/REPOSITORY.git/hooks/post-receive.d
/data/git/repositories/USER/REPOSITORY.git/hooks/post-receive.d/gitea

but it seems to not touch any other existing hooks. Which sounds reasonable. But I was expecting it to modify the gogs hooks after migration. Gitea does not modify or remove the gogs hooks.

Those look like this:

/backup/data/git/repositories/USER/REPOSITORY.git/hooks/pre-receive.d # DIRECTORY
/backup/data/git/repositories/USER/REPOSITORY.git/hooks/pre-receive.d/pre-receive # ACTUAL SCRIPT
/backup/data/git/repositories/USER/REPOSITORY.git/hooks/post-receive.d
/backup/data/git/repositories/USER/REPOSITORY.git/hooks/post-receive.d/post-receive

So I assume that both pre-receive hooks will be executed after push and running the gogs hook will obviously fail.

After testing how the new hook structure will look like in gitea I assumed the gogs hooks can be deleted.

So I made a backup of my data path and executed grep -lr /app/gogs/gogs /data/git/repositories | while read ORIG; do rm -v "${ORIG}"; done

Short explanation for the later reader: grep will recursively look for the gogs application path in every file within the data directory yielding the gogs hooks file paths. For each found file remove this file.

After that I ran gitea admin regenerate hooks to make sure the gitea hooks were in place and verified this with grep -lr /app/gitea/gitea /data/git/repositories. The expected result here was and is a list of hooks matching the previous gogs output with different file name. An additional update hook is in place which is fine.

Pushes worked again.

Proposal

Please Add a comment that

  • existing hooks will not be touched
  • existing gogs hooks (after migration) will not be touched or removed
  • an example delete command like the one I posted for convenience

to the documentation at

This will help with future gogs to gitea migrations and clarifies what regenerate hooks actually does.

Disclaimer

  • I expected to find a hint at those two locations. If it already is documented somewhere I just might not have found it.
  • I did not modify the gitea hooks and add debug output to verify everything is working as I think it should be.

@noerw noerw added the topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them label Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them
Projects
None yet
Development

No branches or pull requests

2 participants