* Prevent server 500 on compare branches with no common history (#6555) * Update code.gitea.io/git module
This commit is contained in:
parent
2551660f49
commit
245089b9c9
6 changed files with 41 additions and 19 deletions
13
vendor/code.gitea.io/git/hook.go
generated
vendored
13
vendor/code.gitea.io/git/hook.go
generated
vendored
|
@ -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.
|
||||
|
|
27
vendor/code.gitea.io/git/repo_pull.go
generated
vendored
27
vendor/code.gitea.io/git/repo_pull.go
generated
vendored
|
@ -48,17 +48,22 @@ func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch stri
|
|||
|
||||
prInfo := new(PullRequestInfo)
|
||||
prInfo.MergeBase, err = repo.GetMergeBase(remoteBranch, headBranch)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetMergeBase: %v", err)
|
||||
}
|
||||
|
||||
logs, err := NewCommand("log", prInfo.MergeBase+"..."+headBranch, prettyLogFormat).RunInDirBytes(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
prInfo.Commits, err = repo.parsePrettyFormatLogToList(logs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsePrettyFormatLogToList: %v", err)
|
||||
if err == nil {
|
||||
// We have a common base
|
||||
logs, err := NewCommand("log", prInfo.MergeBase+"..."+headBranch, prettyLogFormat).RunInDirBytes(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
prInfo.Commits, err = repo.parsePrettyFormatLogToList(logs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsePrettyFormatLogToList: %v", err)
|
||||
}
|
||||
} else {
|
||||
prInfo.Commits = list.New()
|
||||
prInfo.MergeBase, err = GetFullCommitID(repo.Path, remoteBranch)
|
||||
if err != nil {
|
||||
prInfo.MergeBase = remoteBranch
|
||||
}
|
||||
}
|
||||
|
||||
// Count number of changed files.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue