@@ -7,11 +7,9 @@ package git
77import (
88 "errors"
99 "os"
10- "path"
1110 "path/filepath"
1211 "strings"
1312
14- "code.gitea.io/gitea/modules/log"
1513 "code.gitea.io/gitea/modules/util"
1614)
1715
@@ -51,7 +49,7 @@ func GetHook(repoPath, name string) (*Hook, error) {
5149 }
5250 h := & Hook {
5351 name : name ,
54- path : path .Join (repoPath , "hooks" , name + ".d" , name ),
52+ path : filepath .Join (repoPath , "hooks" , name + ".d" , name ),
5553 }
5654 samplePath := filepath .Join (repoPath , "hooks" , name + ".sample" )
5755 if isFile (h .path ) {
@@ -103,7 +101,7 @@ func (h *Hook) Update() error {
103101
104102// ListHooks returns a list of Git hooks of given repository.
105103func ListHooks (repoPath string ) (_ []* Hook , err error ) {
106- if ! isDir (path .Join (repoPath , "hooks" )) {
104+ if ! isDir (filepath .Join (repoPath , "hooks" )) {
107105 return nil , errors .New ("hooks path does not exist" )
108106 }
109107
@@ -116,28 +114,3 @@ func ListHooks(repoPath string) (_ []*Hook, err error) {
116114 }
117115 return hooks , nil
118116}
119-
120- const (
121- // HookPathUpdate hook update path
122- HookPathUpdate = "hooks/update"
123- )
124-
125- // SetUpdateHook writes given content to update hook of the repository.
126- func SetUpdateHook (repoPath , content string ) (err error ) {
127- log .Debug ("Setting update hook: %s" , repoPath )
128- hookPath := path .Join (repoPath , HookPathUpdate )
129- isExist , err := util .IsExist (hookPath )
130- if err != nil {
131- log .Debug ("Unable to check if %s exists. Error: %v" , hookPath , err )
132- return err
133- }
134- if isExist {
135- err = util .Remove (hookPath )
136- } else {
137- err = os .MkdirAll (path .Dir (hookPath ), os .ModePerm )
138- }
139- if err != nil {
140- return err
141- }
142- return os .WriteFile (hookPath , []byte (content ), 0o777 )
143- }
0 commit comments