mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 18:30:34 +00:00
Remove and recreate the hooks to set them executable with the umask (#9502)
Fix #9091
This commit is contained in:
parent
154424623a
commit
145c1ea0b6
1 changed files with 7 additions and 0 deletions
|
@ -967,6 +967,7 @@ func CreateDelegateHooks(repoPath string) error {
|
||||||
|
|
||||||
// createDelegateHooks creates all the hooks scripts for the repo
|
// createDelegateHooks creates all the hooks scripts for the repo
|
||||||
func createDelegateHooks(repoPath string) (err error) {
|
func createDelegateHooks(repoPath string) (err error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
hookNames = []string{"pre-receive", "update", "post-receive"}
|
hookNames = []string{"pre-receive", "update", "post-receive"}
|
||||||
hookTpls = []string{
|
hookTpls = []string{
|
||||||
|
@ -992,10 +993,16 @@ func createDelegateHooks(repoPath string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING: This will override all old server-side hooks
|
// WARNING: This will override all old server-side hooks
|
||||||
|
if err = os.Remove(oldHookPath); err != nil && !os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("unable to pre-remove old hook file '%s' prior to rewriting: %v ", oldHookPath, err)
|
||||||
|
}
|
||||||
if err = ioutil.WriteFile(oldHookPath, []byte(hookTpls[i]), 0777); err != nil {
|
if err = ioutil.WriteFile(oldHookPath, []byte(hookTpls[i]), 0777); err != nil {
|
||||||
return fmt.Errorf("write old hook file '%s': %v", oldHookPath, err)
|
return fmt.Errorf("write old hook file '%s': %v", oldHookPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = os.Remove(newHookPath); err != nil && !os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("unable to pre-remove new hook file '%s' prior to rewriting: %v", newHookPath, err)
|
||||||
|
}
|
||||||
if err = ioutil.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0777); err != nil {
|
if err = ioutil.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0777); err != nil {
|
||||||
return fmt.Errorf("write new hook file '%s': %v", newHookPath, err)
|
return fmt.Errorf("write new hook file '%s': %v", newHookPath, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue