File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
10
10
"time"
11
11
)
12
12
13
- const _VERSION = "0.3.2 "
13
+ const _VERSION = "0.3.3 "
14
14
15
15
func Version () string {
16
16
return _VERSION
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
10
10
"os"
11
11
"path"
12
12
"strings"
13
+
14
+ "github.com/Unknwon/com"
13
15
)
14
16
15
17
// hookNames is a list of Git hooks' name that are supported.
@@ -119,9 +121,16 @@ const (
119
121
)
120
122
121
123
// SetUpdateHook writes given content to update hook of the reposiotry.
122
- func SetUpdateHook (repoPath , content string ) error {
124
+ func SetUpdateHook (repoPath , content string ) ( err error ) {
123
125
log ("Setting update hook: %s" , repoPath )
124
126
hookPath := path .Join (repoPath , HOOK_PATH_UPDATE )
125
- os .MkdirAll (path .Dir (hookPath ), os .ModePerm )
127
+ if com .IsExist (hookPath ) {
128
+ err = os .Remove (hookPath )
129
+ } else {
130
+ err = os .MkdirAll (path .Dir (hookPath ), os .ModePerm )
131
+ }
132
+ if err != nil {
133
+ return err
134
+ }
126
135
return ioutil .WriteFile (hookPath , []byte (content ), 0777 )
127
136
}
You can’t perform that action at this time.
0 commit comments