Gitea: Update Hooks are broken when you move gitea to another folder

Created on 7 Jan 2017  路  3Comments  路  Source: go-gitea/gitea

  • Gitea version: 1.0.1
  • Git version: ?
  • Operating system: Arch Linux ARM, up-to-date
  • Database (use [x]):

    • [ ] PostgreSQL

    • [ ] MySQL

    • [x] SQLite

  • Can you reproduce the bug at https://try.gitea.io:

    • [ ] Yes (provide example URL)

    • [ ] No

    • [x] Not relevant

Description

Problem Description / Error Message

  1. You can clone, pull whatever. SSH properly setup and blabla.
  2. Error message on push is the following (where git-mirror is the host for the machine).
[lycheejs] (development)$ git push mirror development
Counting objects: 80, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (76/76), done.
Writing objects: 100% (80/80), 15.28 KiB | 0 bytes/s, done.
Total 80 (delta 50), reused 0 (delta 0)

# XXX: Note this /home/alarm/gitea path, this is the outdated update hook path
remote: hooks/update: line 2: /home/alarm/gitea: Permission denied

remote: error: hook declined to update refs/heads/development
To git-mirror:Artificial-Engineering/lycheejs.git
 ! [remote rejected] development -> development (hook declined)
error: failed to push some refs to 'git@git-mirror:Artificial-Engineering/lycheejs.git'

Steps to reproduce

  1. Installed gitea to /home/alarm to experiment around, start it and configure it.
  2. Setup correct git user account.
  3. Later moved things to /opt/gitea because I have an external HDD mount there (running on a Raspberry Pi 2).
  4. Everything was configurable and modifyable in the custom/conf/app.ini
  5. EXCEPT the update hooks. Those contain static paths to the old binary.

Quickfix for others

I made a little script that assumes the ./gitea-repositories folder is in the same folder as the gitea binary and that fixes all update hooks once run. In my case it's located in /opt/gitea/fix_repos.js where repos are in /opt/gitea/gitea-repositories. Link to the fix_repos.js script.

Problems caused

I saw a couple issues in upstream gogs where people had the same problems. It is totally unclear that you cannot move around gitea because I would assume that a binary can be copy/pasted with its config files and it should work isolated in that folder.

Suggestion

Maybe it makes sense to have a bootup routine that does a sanity checks for all update hooks when the gitea web service is started. So that it just makes sure that all paths are up to date and point to the correct binary.

revieweinvalid

Most helpful comment

Enter Gitea admin panel on the UI, run Rewrite '.ssh/authorized_keys' file (caution: non-Gitea keys will be lost) and Rewrite all update hook of repositories (needed when custom config path is changed).

All 3 comments

Enter Gitea admin panel on the UI, run Rewrite '.ssh/authorized_keys' file (caution: non-Gitea keys will be lost) and Rewrite all update hook of repositories (needed when custom config path is changed).

Since the data is a static part it must be rewritten within the admin ui.

First I try to push git but get this error.

[remote rejected] master -> master (pre-receive hook declined)

I run Update the '.ssh/authorized_keys' file with Gitea SSH keys. (Not needed for the built-in SSH server.) but got error.

open C:\Windows\system32\config\systemprofile.ssh\authorized_keys.tmp: The system cannot find the path specified.

Then I run Resynchronize pre-receive, update and post-receive hooks of all repositories.

And I try to push again and everything works fine.

I'm not sure is that for this or update .ssh/authorized_keys work even it display error or something but it work! I don't know why.

Was this page helpful?
0 / 5 - 0 ratings