File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -967,6 +967,7 @@ func CreateDelegateHooks(repoPath string) error {
967
967
968
968
// createDelegateHooks creates all the hooks scripts for the repo
969
969
func createDelegateHooks (repoPath string ) (err error ) {
970
+
970
971
var (
971
972
hookNames = []string {"pre-receive" , "update" , "post-receive" }
972
973
hookTpls = []string {
@@ -992,10 +993,16 @@ func createDelegateHooks(repoPath string) (err error) {
992
993
}
993
994
994
995
// WARNING: This will override all old server-side hooks
996
+ if err = os .Remove (oldHookPath ); err != nil && ! os .IsNotExist (err ) {
997
+ return fmt .Errorf ("unable to pre-remove old hook file '%s' prior to rewriting: %v " , oldHookPath , err )
998
+ }
995
999
if err = ioutil .WriteFile (oldHookPath , []byte (hookTpls [i ]), 0777 ); err != nil {
996
1000
return fmt .Errorf ("write old hook file '%s': %v" , oldHookPath , err )
997
1001
}
998
1002
1003
+ if err = os .Remove (newHookPath ); err != nil && ! os .IsNotExist (err ) {
1004
+ return fmt .Errorf ("unable to pre-remove new hook file '%s' prior to rewriting: %v" , newHookPath , err )
1005
+ }
999
1006
if err = ioutil .WriteFile (newHookPath , []byte (giteaHookTpls [i ]), 0777 ); err != nil {
1000
1007
return fmt .Errorf ("write new hook file '%s': %v" , newHookPath , err )
1001
1008
}
You can’t perform that action at this time.
0 commit comments