PowerShell git hooks do not work on 7.2+ #13683

Closed
opened 2025-11-02 10:50:15 -06:00 by GiteaMirror · 13 comments
Owner

Originally created by @colejohnson66 on GitHub (Nov 6, 2024).

Description

PowerShell 7.2 now requires scripts to have a ps1 extension. Gitea's autogenerated git hooks do not have this, and fail to run.

https://github.com/PowerShell/PowerShell/pull/15859

https://github.com/PowerShell/PowerShell/issues/16480

Gitea Version

1.22.3

Can you reproduce the bug on the Gitea demo site?

Untested

Log Gist

No response

Screenshots

No response

Git Version

2.47.0.windows.1

Operating System

Windows Server 2016

How are you running Gitea?

Windows Service

Database

None

Originally created by @colejohnson66 on GitHub (Nov 6, 2024). ### Description PowerShell 7.2 now requires scripts to have a `ps1` extension. Gitea's autogenerated git hooks do not have this, and fail to run. https://github.com/PowerShell/PowerShell/pull/15859 https://github.com/PowerShell/PowerShell/issues/16480 ### Gitea Version 1.22.3 ### Can you reproduce the bug on the Gitea demo site? Untested ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.47.0.windows.1 ### Operating System Windows Server 2016 ### How are you running Gitea? Windows Service ### Database None
GiteaMirror added the issue/workaround label 2025-11-02 10:50:15 -06:00
Author
Owner

@colejohnson66 commented on GitHub (Nov 6, 2024):

I was able to hack a solution by changing the shebang from pwsh to bash. I can't see a reason they'd need to be executed in PowerShell instead of Git Bash.

@colejohnson66 commented on GitHub (Nov 6, 2024): I was able to hack a solution by changing the shebang from `pwsh` to `bash`. I can't see a reason they'd *need* to be executed in PowerShell instead of Git Bash.
Author
Owner

@lunny commented on GitHub (Nov 6, 2024):

You can change the SCRIPT_TYPE. https://docs.gitea.com/administration/config-cheat-sheet#repository-repository

@lunny commented on GitHub (Nov 6, 2024): You can change the `SCRIPT_TYPE`. https://docs.gitea.com/administration/config-cheat-sheet#repository-repository
Author
Owner

@colejohnson66 commented on GitHub (Nov 6, 2024):

Yeah. I was digging through the code to see where they're generated, and I saw it uses setting.ScriptType

b573512312/modules/repository/hooks.go (L16-L106)

However, considering scripts run under Git Bash (on Windows), is there any reason to support PowerShell ones? It would be less maintenance, in the long run, to just always use bash.

@colejohnson66 commented on GitHub (Nov 6, 2024): Yeah. I was digging through the code to see where they're generated, and I saw it uses `setting.ScriptType` https://github.com/go-gitea/gitea/blob/b573512312d82e894db7aac89f4938a6b61e1e70/modules/repository/hooks.go#L16-L106 However, considering scripts run under Git Bash (on Windows), is there any reason to support PowerShell ones? It would be less maintenance, in the long run, to just always use bash.
Author
Owner

@lunny commented on GitHub (Nov 6, 2024):

I think the default value is bash if you haven't changed it.

@lunny commented on GitHub (Nov 6, 2024): I think the default value is `bash` if you haven't changed it.
Author
Owner

@wxiaoguang commented on GitHub (Nov 7, 2024):

It is powershell's problem and can not be easily bypassed.

There could be some workarounds:

https://github.com/go-gitea/gitea/pull/31058#issuecomment-2131290276

(And one more thing: ask Microsoft to ignore the file extension check or add an argument for PowerShell to ignore the file extension check.)

@wxiaoguang commented on GitHub (Nov 7, 2024): It is powershell's problem and can not be easily bypassed. There could be some workarounds: https://github.com/go-gitea/gitea/pull/31058#issuecomment-2131290276 (And one more thing: ask Microsoft to ignore the file extension check or add an argument for PowerShell to ignore the file extension check.)
Author
Owner

@colejohnson66 commented on GitHub (Nov 7, 2024):

Yes, the ideal solution would be for Microsoft to revert the change. But it’s been two years since they said they’d consider it and haven’t given any updates. Perhaps the Gitea docs should be updated to warn against this?

@colejohnson66 commented on GitHub (Nov 7, 2024): Yes, the ideal solution would be for Microsoft to revert the change. But it’s been two years since they said they’d consider it and haven’t given any updates. Perhaps the Gitea docs should be updated to warn against this?
Author
Owner

@GiteaBot commented on GitHub (Dec 8, 2024):

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

@GiteaBot commented on GitHub (Dec 8, 2024): We close issues that need feedback from the author if there were no new comments for a month. :tea:
Author
Owner

@colejohnson66 commented on GitHub (Dec 8, 2024):

Wow

@colejohnson66 commented on GitHub (Dec 8, 2024): Wow
Author
Owner

@wxiaoguang commented on GitHub (Dec 8, 2024):

There are workarounds: https://github.com/go-gitea/gitea/pull/31058#issuecomment-2131290276

@wxiaoguang commented on GitHub (Dec 8, 2024): There are workarounds: https://github.com/go-gitea/gitea/pull/31058#issuecomment-2131290276
Author
Owner

@colejohnson66 commented on GitHub (Dec 9, 2024):

Until a proper solution is available, I still think the documentation should be updated to warn against this.

@colejohnson66 commented on GitHub (Dec 9, 2024): Until a proper solution is available, I still think the documentation should be updated to warn against this.
Author
Owner

@wxiaoguang commented on GitHub (Dec 9, 2024):

To be honest I have no idea about how to document it since I do not use Windows or PowerShell.

Would you like to propose some updates? https://gitea.com/gitea/docs/pulls

@wxiaoguang commented on GitHub (Dec 9, 2024): To be honest I have no idea about how to document it since I do not use Windows or PowerShell. Would you like to propose some updates? https://gitea.com/gitea/docs/pulls
Author
Owner

@GiteaBot commented on GitHub (Jan 8, 2025):

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

@GiteaBot commented on GitHub (Jan 8, 2025): We close issues that need feedback from the author if there were no new comments for a month. :tea:
Author
Owner

@wxiaoguang commented on GitHub (Apr 25, 2025):

https://github.com/go-gitea/gitea/pull/31058#issuecomment-2829558723

@wxiaoguang commented on GitHub (Apr 25, 2025): https://github.com/go-gitea/gitea/pull/31058#issuecomment-2829558723
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13683