File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 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 {
967967
968968// createDelegateHooks creates all the hooks scripts for the repo
969969func createDelegateHooks (repoPath string ) (err error ) {
970+
970971 var (
971972 hookNames = []string {"pre-receive" , "update" , "post-receive" }
972973 hookTpls = []string {
@@ -992,10 +993,16 @@ func createDelegateHooks(repoPath string) (err error) {
992993 }
993994
994995 // 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+ }
995999 if err = ioutil .WriteFile (oldHookPath , []byte (hookTpls [i ]), 0777 ); err != nil {
9961000 return fmt .Errorf ("write old hook file '%s': %v" , oldHookPath , err )
9971001 }
9981002
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+ }
9991006 if err = ioutil .WriteFile (newHookPath , []byte (giteaHookTpls [i ]), 0777 ); err != nil {
10001007 return fmt .Errorf ("write new hook file '%s': %v" , newHookPath , err )
10011008 }
You can’t perform that action at this time.
0 commit comments