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 (
1010 "time"
1111)
1212
13- const _VERSION = "0.3.2 "
13+ const _VERSION = "0.3.3 "
1414
1515func Version () string {
1616 return _VERSION
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
1010 "os"
1111 "path"
1212 "strings"
13+
14+ "github.com/Unknwon/com"
1315)
1416
1517// hookNames is a list of Git hooks' name that are supported.
@@ -119,9 +121,16 @@ const (
119121)
120122
121123// 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 ) {
123125 log ("Setting update hook: %s" , repoPath )
124126 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+ }
126135 return ioutil .WriteFile (hookPath , []byte (content ), 0777 )
127136}
You can’t perform that action at this time.
0 commit comments