Revise server side hook configuration to support dynamic hook file extensions. #12997

Closed
opened 2025-11-02 10:27:14 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @jozseffenyes on GitHub (May 15, 2024).

Feature Description

In the /modules/git/hook.go file each hook is hardcoded without a file extension, causing inconvenience in deploying any script git hook other than bash on Gitea.

Within modules/git/hook.go, the variable "hookNames" is defined as an array without file extensions:

var hookNames = []string{
    "pre-receive",
    "update",
    "post-receive",
}

Screenshots

No response

Originally created by @jozseffenyes on GitHub (May 15, 2024). ### Feature Description In the /modules/git/hook.go file each hook is hardcoded without a file extension, causing inconvenience in deploying any script git hook other than bash on Gitea. Within modules/git/hook.go, the variable "hookNames" is defined as an array without file extensions: ``` golang var hookNames = []string{ "pre-receive", "update", "post-receive", } ``` ### Screenshots _No response_
GiteaMirror added the type/proposalissue/needs-feedback labels 2025-11-02 10:27:14 -06:00
Author
Owner

@lunny commented on GitHub (May 21, 2024):

How does these hooks with extensions work? https://git-scm.com/docs/githooks

@lunny commented on GitHub (May 21, 2024): How does these hooks with extensions work? https://git-scm.com/docs/githooks
Author
Owner

@jozseffenyes commented on GitHub (May 21, 2024):

Hooks with extensions do work on Gitea, but currently, they do not appear on the frontend. It would be helpful to customize each hook's behavior without having to create a wrapper script that calls the script from bash.

For example, if I wanted to create a pre-receive.ps1 script inside the repository on the server, Gitea would not find it since the hook names are hard-coded. Additionally, calling the script from bash with #!/usr/bin/env pwsh without a file extension won't work either, as since PowerShell 7.2 scripts require a .ps1 file extension on windows.

@jozseffenyes commented on GitHub (May 21, 2024): Hooks with extensions do work on Gitea, but currently, they do not appear on the frontend. It would be helpful to customize each hook's behavior without having to create a wrapper script that calls the script from bash. For example, if I wanted to create a pre-receive.ps1 script inside the repository on the server, Gitea would not find it since the hook names are hard-coded. Additionally, calling the script from bash with #!/usr/bin/env pwsh without a file extension won't work either, as since PowerShell 7.2 scripts require a .ps1 file extension on windows.
Author
Owner

@lunny commented on GitHub (May 25, 2024):

Hooks with extensions do work on Gitea, but currently, they do not appear on the frontend. It would be helpful to customize each hook's behavior without having to create a wrapper script that calls the script from bash.

For example, if I wanted to create a pre-receive.ps1 script inside the repository on the server, Gitea would not find it since the hook names are hard-coded. Additionally, calling the script from bash with #!/usr/bin/env pwsh without a file extension won't work either, as since PowerShell 7.2 scripts require a .ps1 file extension on windows.

I don't think so. Gitea will create update.d, proc-receive.d, post-receive.d and pre-receive.d. You can put your scripts under these folders.

@lunny commented on GitHub (May 25, 2024): > Hooks with extensions do work on Gitea, but currently, they do not appear on the frontend. It would be helpful to customize each hook's behavior without having to create a wrapper script that calls the script from bash. > > For example, if I wanted to create a pre-receive.ps1 script inside the repository on the server, Gitea would not find it since the hook names are hard-coded. Additionally, calling the script from bash with #!/usr/bin/env pwsh without a file extension won't work either, as since PowerShell 7.2 scripts require a .ps1 file extension on windows. I don't think so. Gitea will create `update.d`, `proc-receive.d`, `post-receive.d` and `pre-receive.d`. You can put your scripts under these folders.
Author
Owner

@GiteaBot commented on GitHub (Jun 24, 2024):

We close issues that need feedback from the author if there were no new comments for a month. 🍵

@GiteaBot commented on GitHub (Jun 24, 2024): We close issues that need feedback from the author if there were no new comments for a month. :tea:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12997