1
0
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:
Unknwon
2016-07-22 21:29:50 +08:00
parent db93fa5501
commit 53bcb7352f
2 changed files with 12 additions and 3 deletions

2
git.go
View File

@@ -10,7 +10,7 @@ import (
"time"
)
const _VERSION = "0.3.2"
const _VERSION = "0.3.3"
func Version() string {
return _VERSION

13
hook.go
View File

@@ -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)
}