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

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

Open
jozseffenyes opened this issue May 15, 2024 · 3 comments · May be fixed by #31058
Open

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

jozseffenyes opened this issue May 15, 2024 · 3 comments · May be fixed by #31058
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@jozseffenyes
Copy link

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

@jozseffenyes jozseffenyes added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label May 15, 2024
@lunny
Copy link
Member

lunny commented May 21, 2024

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

@lunny lunny added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label May 21, 2024
@jozseffenyes
Copy link
Author

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 pushed a commit to jozseffenyes/gitea that referenced this issue May 23, 2024
jozseffenyes pushed a commit to jozseffenyes/gitea that referenced this issue May 23, 2024
@jozseffenyes jozseffenyes linked a pull request May 23, 2024 that will close this issue
jozseffenyes pushed a commit to jozseffenyes/gitea that referenced this issue May 23, 2024
@lunny
Copy link
Member

lunny commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants