Clean-up HookPreReceive and restore functionality for pushing non-standard refs (#16705)
* Clean-up HookPreReceive and restore functionality for pushing non-standard refs There was an inadvertent breaking change in #15629 meaning that notes refs and other git extension refs will be automatically rejected. Further following #14295 and #15629 the pre-recieve hook code is untenably long and too complex. This PR refactors the hook code and removes the incorrect forced rejection of non-standard refs. Fix #16688 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
a959ed99c2
commit
8de44d1995
9 changed files with 1000 additions and 780 deletions
|
@ -31,6 +31,7 @@ func Wrap(handlers ...interface{}) http.HandlerFunc {
|
|||
func(ctx *context.Context) goctx.CancelFunc,
|
||||
func(*context.APIContext),
|
||||
func(*context.PrivateContext),
|
||||
func(*context.PrivateContext) goctx.CancelFunc,
|
||||
func(http.Handler) http.Handler:
|
||||
default:
|
||||
panic(fmt.Sprintf("Unsupported handler type: %#v", t))
|
||||
|
@ -59,6 +60,15 @@ func Wrap(handlers ...interface{}) http.HandlerFunc {
|
|||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
case func(*context.PrivateContext) goctx.CancelFunc:
|
||||
ctx := context.GetPrivateContext(req)
|
||||
cancel := t(ctx)
|
||||
if cancel != nil {
|
||||
defer cancel()
|
||||
}
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
case func(ctx *context.Context):
|
||||
ctx := context.GetContext(req)
|
||||
t(ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue