-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Hook configuration through filenames #31058
base: main
Are you sure you want to change the base?
Conversation
TBH I am not sure whether this change is necessary or safe enough. By design, the git hooks must be managed by Gitea, otherwise there might be "access bypass" if the hooks are wrong. And, the current "hook" script looks like this, it already has the ability to run anything in |
Thank you for your input. This capability remains necessary for our organization, as we need to modify our scripts directly from the frontend. Changing the file extension from the bash script does not make it available through the UI. We understand the risks involved but have determined that this approach is safe enough. |
Since the script is executed by git bash, so I would suppose you could use shebang line directly for your PowerShell scripts without extension? https://stackoverflow.com/questions/48216173/how-can-i-use-a-shebang-in-a-powershell-script |
Sadly this approach doesn't work anymore on windows since Powershell's 7.2 release. |
Hmm, it seems to be a bad design from PowerShell side. I think we should still do the best to follow the posix-standard / shebangline, instead of introducing too many options or workarounds, since it isn't a widely-requested feature -- until there are many end users need such "customized hook extension name". For your case, I think it could be resolved by some of these approaches:
Then use it as your hook script's shebang line:
|
return fmt.Errorf("can only contain filenames, not other directories") | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a very similar function in routers/api/packages/generic/generic.go:65
, move it to modules/util
and share from there.
|
||
<dt>{{ctx.Locale.Tr "admin.config.git_hookprereceivename"}}</dt> | ||
<dd>{{.GitHookPrereceiveName}}</dd> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
<dt>{{ctx.Locale.Tr "admin.config.git_hookupdatename"}}</dt> | ||
<dd>{{.GitHookUpdateName}}</dd> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
<dt>{{ctx.Locale.Tr "admin.config.git_postreceivename"}}</dt> | ||
<dd>{{.GitHookPostreceiveName}}</dd> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to the author's work and thanks to reviewers' suggestions. However, I think this change is not good enough and I do not think it could be merged.
So I will put a "blocked" label, and leave the final decision to the @go-gitea/technical-oversight-committee |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow hooks to run under different filenames set in app.ini
Resolves #30985