Skip to content

Commit 9c4604e

Browse files
committed
Remove the unused and inefficent update hook
1 parent 7bfb83e commit 9c4604e

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

cmd/hook.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,7 @@ Gitea or set your environment appropriately.`, "")
181181
}
182182

183183
func runHookUpdate(c *cli.Context) error {
184-
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
185-
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
186-
fail(`Rejecting changes as Gitea environment not set.
187-
If you are pushing over SSH you must push with a key managed by
188-
Gitea or set your environment appropriately.`, "")
189-
} else {
190-
return nil
191-
}
192-
}
193-
194-
setup("hooks/update.log", false)
195-
184+
// Update is empty and is kept only for backwards compatibility
196185
return nil
197186
}
198187

models/repo.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ func createDelegateHooks(repoPath string) (err error) {
976976
}
977977
giteaHookTpls = []string{
978978
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
979-
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
979+
"",
980980
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
981981
}
982982
)
@@ -996,11 +996,20 @@ func createDelegateHooks(repoPath string) (err error) {
996996
return fmt.Errorf("write old hook file '%s': %v", oldHookPath, err)
997997
}
998998

999+
if len(giteaHookTpls[i]) == 0 {
1000+
continue
1001+
}
9991002
if err = ioutil.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0777); err != nil {
10001003
return fmt.Errorf("write new hook file '%s': %v", newHookPath, err)
10011004
}
10021005
}
10031006

1007+
// Remove the old unused update.d/gitea hook as it is empty
1008+
newHookPath := filepath.Join(hookDir, "update.d", "gitea")
1009+
if err := os.Remove(newHookPath); err != nil && !os.IsNotExist(err) {
1010+
return fmt.Errorf("remove unused update hook file '%s': %v", newHookPath, err)
1011+
}
1012+
10041013
return nil
10051014
}
10061015

0 commit comments

Comments
 (0)