mirror of
https://github.com/go-gitea/git.git
synced 2026-02-05 15:45:40 +01:00
gogits/gogs#3302 remove hook script and recreate with proper permission
If permission of hook script somehow changed, the rewrite operation does not fix the permission to what is expteced.
This commit is contained in:
2
git.go
2
git.go
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const _VERSION = "0.3.2"
|
||||
const _VERSION = "0.3.3"
|
||||
|
||||
func Version() string {
|
||||
return _VERSION
|
||||
|
||||
13
hook.go
13
hook.go
@@ -10,6 +10,8 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
)
|
||||
|
||||
// hookNames is a list of Git hooks' name that are supported.
|
||||
@@ -119,9 +121,16 @@ const (
|
||||
)
|
||||
|
||||
// SetUpdateHook writes given content to update hook of the reposiotry.
|
||||
func SetUpdateHook(repoPath, content string) error {
|
||||
func SetUpdateHook(repoPath, content string) (err error) {
|
||||
log("Setting update hook: %s", repoPath)
|
||||
hookPath := path.Join(repoPath, HOOK_PATH_UPDATE)
|
||||
os.MkdirAll(path.Dir(hookPath), os.ModePerm)
|
||||
if com.IsExist(hookPath) {
|
||||
err = os.Remove(hookPath)
|
||||
} else {
|
||||
err = os.MkdirAll(path.Dir(hookPath), os.ModePerm)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(hookPath, []byte(content), 0777)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user