[MISC] disable 'update' git hook (#181)

This commit is contained in:
Johannes Batzill 2023-01-11 17:09:46 -08:00 committed by GitHub
parent 79318bd522
commit 5e3837b9cf
2 changed files with 20 additions and 3 deletions

View File

@ -39,7 +39,11 @@ var (
Email: "system@gitness",
}
gitServerHookNames = []string{"pre-receive", "update", "post-receive"}
gitServerHookNames = []string{
"pre-receive",
// "update", // update is disabled for performance reasons (called once for every ref)
"post-receive",
}
// gitSHARegex defines the valid SHA format accepted by GIT (full form and short forms).
// Note: as of now SHA is at most 40 characters long, but in the future it's moving to sha256

View File

@ -68,8 +68,21 @@ func (c *CLI) PreReceive(ctx context.Context) error {
// Update executes the update git hook.
func (c *CLI) Update(ctx context.Context, ref string, oldSHA string, newSHA string) error {
// Skip update hook as we don't have any per branch operations, and pre-receive is more performant!
return nil
in := &githook.UpdateInput{
BaseInput: githook.BaseInput{
RepoID: c.payload.RepoID,
PrincipalID: c.payload.PrincipalID,
},
RefUpdate: githook.ReferenceUpdate{
Ref: ref,
Old: oldSHA,
New: newSHA,
},
}
out, err := c.client.Update(ctx, in)
return handleServerHookOutput(out, err)
}
// PostReceive executes the post-receive git hook.