mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	new repo git hooks UI
This commit is contained in:
		@@ -10,6 +10,8 @@ import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/Unknwon/com"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// hookNames is a list of Git hooks' name that are supported.
 | 
			
		||||
@@ -81,7 +83,10 @@ func (h *Hook) Name() string {
 | 
			
		||||
// Update updates hook settings.
 | 
			
		||||
func (h *Hook) Update() error {
 | 
			
		||||
	if len(strings.TrimSpace(h.Content)) == 0 {
 | 
			
		||||
		return os.Remove(h.path)
 | 
			
		||||
		if com.IsExist(h.path) {
 | 
			
		||||
			return os.Remove(h.path)
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	return ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user