Prevent server 500 on compare branches with no common history (#6555) (#6558)

* Prevent server 500 on compare branches with no common history (#6555)
* Update code.gitea.io/git module
This commit is contained in:
zeripath 2019-04-11 21:31:17 +01:00 committed by GitHub
parent 2551660f49
commit 245089b9c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 19 deletions

13
vendor/code.gitea.io/git/hook.go generated vendored
View file

@ -82,11 +82,20 @@ func (h *Hook) Name() string {
func (h *Hook) Update() error {
if len(strings.TrimSpace(h.Content)) == 0 {
if isExist(h.path) {
return os.Remove(h.path)
err := os.Remove(h.path)
if err != nil {
return err
}
}
h.IsActive = false
return nil
}
return ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
if err != nil {
return err
}
h.IsActive = true
return nil
}
// ListHooks returns a list of Git hooks of given repository.