mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-13 02:57:44 -05:00
Git Hooks not editable and not working #3370
Closed
opened 2025-11-02 05:10:26 -06:00 by GiteaMirror
·
19 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1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
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/question
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#3370
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (May 23, 2019).
[x]):Description
Hi all,
I have successfully setup Gitea in a Docker environment using the official docker-compose.yml file to have things set up. All repositories are now migrated and I wanted to get my hooks done as well.
Coming from the git console, I was creating a post-receive file directly in the hooks directory and entered my code. However, after committing and pushing my changes to Gitea, the hook is not fired. I have tested the script alone and it worked perfectly. Next, I moved the script to the post-receive.d directory and tested it again with no effect.
I googled a bit and found out, that the hooks can be entered via the GUI in settings, too. The post-receive indicator is green (only if the file is in the post-receive.d folder). But, there is no way to edit the hooks! I found a screenshot where there is an edit button after each hook type but not in my setup (see screenshots below).
I tested it on various browsers, there are no edit buttons.
How do I get those edit buttons and how do I get Gitea to fire the hooks?
Thanks!
Screenshots
How I would expect it:

How it is on my setup

@ghost commented on GitHub (May 24, 2019):
Somehow, latest is Gitea Version: 1.9.0+dev-274-g6ff9349a0
@zeripath commented on GitHub (May 24, 2019):
How are you pushing?
If you are pushing by SSH are you sure that you're pushing with a key managed by Gitea?
If you push with a key that is not managed by Gitea its hooks will not run.
To test whether you are pushing with a key managed by Gitea you should SSH to the Gitea server as the git user and if you get a terminal rather than being told Gitea does not provide a shell then you are not pushing with a Gitea managed key.
@lafriks commented on GitHub (May 24, 2019):
Might be that your user does not have edit hooks rights or you have hooks editing disabled in app.ini
@ghost commented on GitHub (May 25, 2019):
I added specifically DISABLE_GIT_HOOKS = false in the app.ini located in
/var/lib/docker/volumes/gitea_main_data/_data/gitea/conf# nano app.iniI restarted the service but that wasn't the issue.
I am using an organisation which owns the repository and my user is member of that organisation. My user is administrator, too. So I should have the privileagues. Do you have any other ideas?
@zeripath commented on GitHub (May 25, 2019):
How are you pushing?
@ghost commented on GitHub (May 25, 2019):
I push with HTTPS and not SSH.
@zeripath commented on GitHub (May 25, 2019):
Are you sure that you have the repositories directory mounted executable?
@ghost commented on GitHub (May 25, 2019):
@zeripath commented on GitHub (May 25, 2019):
I mean the mount, not the directory.
@ghost commented on GitHub (May 25, 2019):
I use Docker volumes. My docker-compose.yml uses the following statements to mount the volume:
Withhin the service:
And the Volumes defintion:
How do I make it executable?
I tried to execute the post-receive hook from the container and it worked, though.
@zeripath commented on GitHub (May 25, 2019):
just check mount from within the gitea container - but the fact that you say you can execute the hooks makes this less suspect.
What is more concerning is that the index, HEAD and ORIG_HEAD being owned by root in that repository.
Being unable to update HEAD could easily be cause for things failing. I'm fairly certain that everything in those repositories should be owned by git.
@ghost commented on GitHub (May 25, 2019):
Here is what my mount settings looks from the container:
I rechecked that I can execute scripts from within the container. I logged in the container, switched from user root to git, created an executable shell script, added some stuff and executed it. Worked like a charm.
I changed recursively the owner to git:git for all files.
I pushed and it's the same issue :-(
@ghost commented on GitHub (May 25, 2019):
Just to be on the safe side:
I added my post-receive hook under
/var/lib/docker/volumes/gitea_main_data/_data/git/repositories/wordpress/ziin_hp_wp.git/hooks/post-receive.dThe file is also called
post-receive.@zeripath commented on GitHub (May 25, 2019):
You need to check these things from within the docker itself. It doesn't matter what you can do outside of the docker.
And then check these things.
@ghost commented on GitHub (May 26, 2019):
First, I have reset my Docker environment. At least, the edit buttons are now back. It must be something from an older update, I don't know. At least, I see the edit buttons and have now entered the hook over the GUI. Still, it is not executed.
@ghost commented on GitHub (May 26, 2019):
I can successfully execute the hook manually.
@ghost commented on GitHub (May 26, 2019):
Ok, it works!!! It was my fault. I tested the hook as root but not as git user. When running as git user, it finally through an error I could trace. The hook is now fired when the icons are visible. On my other instance, it is not fired. So I will use the new instance. Before closing the ticket, I need your help one more time.
The post-receive hook should make a checkout on the same machine but not within the container but on the host (web server). I have added a bind mount to the www directory. As the git user has no privileges on the www folder, I changed the owner to root:git and added the SETUID flag to the post-receive hook for the group and user (as the script can write to the file system as root from the container). However, though using the SETUID, I get a permission error. Is there a way to solve this?
I have also tried to add the git user/group to my docker machine with the same UIDs/GUIs and added the git group as secondary group to the www user without success.
Can you help me with that?
@ghost commented on GitHub (May 28, 2019):
Ok, not possible :-), at least with bind mounts. Thanks for all the support!
@shanyu-e commented on GitHub (Apr 27, 2020):
#6415 this worked for me - USER_UID=1026 - USER_GID=100,and named volumes I think also can be worked.