@@ -7,11 +7,9 @@ package git
7
7
import (
8
8
"errors"
9
9
"os"
10
- "path"
11
10
"path/filepath"
12
11
"strings"
13
12
14
- "code.gitea.io/gitea/modules/log"
15
13
"code.gitea.io/gitea/modules/util"
16
14
)
17
15
@@ -51,7 +49,7 @@ func GetHook(repoPath, name string) (*Hook, error) {
51
49
}
52
50
h := & Hook {
53
51
name : name ,
54
- path : path .Join (repoPath , "hooks" , name + ".d" , name ),
52
+ path : filepath .Join (repoPath , "hooks" , name + ".d" , name ),
55
53
}
56
54
samplePath := filepath .Join (repoPath , "hooks" , name + ".sample" )
57
55
if isFile (h .path ) {
@@ -103,7 +101,7 @@ func (h *Hook) Update() error {
103
101
104
102
// ListHooks returns a list of Git hooks of given repository.
105
103
func ListHooks (repoPath string ) (_ []* Hook , err error ) {
106
- if ! isDir (path .Join (repoPath , "hooks" )) {
104
+ if ! isDir (filepath .Join (repoPath , "hooks" )) {
107
105
return nil , errors .New ("hooks path does not exist" )
108
106
}
109
107
@@ -116,28 +114,3 @@ func ListHooks(repoPath string) (_ []*Hook, err error) {
116
114
}
117
115
return hooks , nil
118
116
}
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