Hooks don't work after gitea migration #4651

Closed
opened 2025-11-02 05:57:44 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @asonix on GitHub (Jan 15, 2020).

  • Gitea version (or commit ref): 1.10.2 (upgraded from 1.7.x)
  • Git version: 2.17.1
  • Operating system: Ubuntu aarch64 (with docker)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

After migrating from the binary install of gitea to using the official docker image, SSH pushes no longer worked. I would get an error such as (pre-receive hook declined)

I discovered, thanks to this discourse post that there are hooks embedded in each git repository with hard-coded paths to a gitea config. Since I had migrated, my gitea config was no longer in the same spot.

Here's the sed command I used to fix this:

su -p git -s /bin/bash -c "sed -i'' 's/\/etc\/gitea\/app.ini/\/data\/gitea\/conf\/app.ini/g' **/*/hooks/*/gitea"

The important bits here for people in this same situation are the \/etc\/gitea\/app.ini, which is where my config used to be, and the \/data\/gitea\/conf\/app.ini, which is where the config is placed in the docker image

While I have outlined a solution that worked for me, I'd like to encourage the project to look into a better way to define hooks like these so that other people may not need to search the internet to find this issue.

Originally created by @asonix on GitHub (Jan 15, 2020). - Gitea version (or commit ref): 1.10.2 (upgraded from 1.7.x) - Git version: 2.17.1 - Operating system: Ubuntu aarch64 (with docker) - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant ## Description After migrating from the binary install of gitea to using the official docker image, SSH pushes no longer worked. I would get an error such as `(pre-receive hook declined)` I discovered, thanks to [this discourse post](https://discourse.gitea.io/t/pre-receive-hook-declined-error-on-fresh-gitea-shared-hosting/78) that there are hooks embedded in each git repository with hard-coded paths to a gitea config. Since I had migrated, my gitea config was no longer in the same spot. Here's the sed command I used to fix this: ``` su -p git -s /bin/bash -c "sed -i'' 's/\/etc\/gitea\/app.ini/\/data\/gitea\/conf\/app.ini/g' **/*/hooks/*/gitea" ``` The important bits here for people in this same situation are the `\/etc\/gitea\/app.ini`, which is where my config used to be, and the `\/data\/gitea\/conf\/app.ini`, which is where the config is placed in the docker image While I have outlined a solution that worked for me, I'd like to encourage the project to look into a better way to define hooks like these so that other people may not need to search the internet to find this issue.
GiteaMirror added the type/question label 2025-11-02 05:57:44 -06:00
Author
Owner

@asonix commented on GitHub (Jan 15, 2020):

I should note that I was lucky (or maybe unlucky) that my bare-metal install AND the docker image both placed the gitea binary in /usr/local/bin/gitea. The error may be different (possibly more obvious) if these paths had not aligned

@asonix commented on GitHub (Jan 15, 2020): I should note that I was lucky (or maybe unlucky) that my bare-metal install AND the docker image both placed the `gitea` binary in `/usr/local/bin/gitea`. The error may be different (possibly more obvious) if these paths had not aligned
Author
Owner

@asonix commented on GitHub (Jan 15, 2020):

I should also add that I executed that sed command from withing the repositories folder of my gitea install

@asonix commented on GitHub (Jan 15, 2020): I should also add that I executed that `sed` command from withing the `repositories` folder of my gitea install
Author
Owner

@zeripath commented on GitHub (Jan 15, 2020):

There's a task on the admin settings page that will resynchronize hooks and will do all of this for you.

@zeripath commented on GitHub (Jan 15, 2020): There's a task on the admin settings page that will resynchronize hooks and will do all of this for you.
Author
Owner

@techknowlogick commented on GitHub (Jan 22, 2020):

Closing as task linked above will rewrite hooks as needed.

@techknowlogick commented on GitHub (Jan 22, 2020): Closing as task linked above will rewrite hooks as needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4651