mirror of
https://github.com/go-gitea/gitea
synced 2025-07-15 15:07:20 +00:00
Cache PullRequest Divergence (#10914)
* Cache PullRequest Divergence * only re-calc divergence if AddTestPullRequestTask() is exec * migrate already open pulls * finalize * take care of closed¬-merged+deleted-branch pull requests * fix nil pointer exeption Signed-off-by: 6543 <6543@obermui.de> * try this * no error its a warn * init gitea-repositories-meta * dont use gitDivergence type * CI.restart() * CI.restart() * CI.restart() * CI.restart() * check IsUserAllowedToUpdate independend from CommitsBehind
This commit is contained in:
@ -42,6 +42,8 @@ type PullRequest struct {
|
||||
Type PullRequestType
|
||||
Status PullRequestStatus
|
||||
ConflictedFiles []string `xorm:"TEXT JSON"`
|
||||
CommitsAhead int
|
||||
CommitsBehind int
|
||||
|
||||
IssueID int64 `xorm:"INDEX"`
|
||||
Issue *Issue `xorm:"-"`
|
||||
@ -615,6 +617,21 @@ func (pr *PullRequest) GetWorkInProgressPrefix() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// UpdateCommitDivergence update Divergence of a pull request
|
||||
func (pr *PullRequest) UpdateCommitDivergence(ahead, behind int) error {
|
||||
return pr.updateCommitDivergence(x, ahead, behind)
|
||||
}
|
||||
|
||||
func (pr *PullRequest) updateCommitDivergence(e Engine, ahead, behind int) error {
|
||||
if pr.ID == 0 {
|
||||
return fmt.Errorf("pull ID is 0")
|
||||
}
|
||||
pr.CommitsAhead = ahead
|
||||
pr.CommitsBehind = behind
|
||||
_, err := e.ID(pr.ID).Cols("commits_ahead", "commits_behind").Update(pr)
|
||||
return err
|
||||
}
|
||||
|
||||
// IsSameRepo returns true if base repo and head repo is the same
|
||||
func (pr *PullRequest) IsSameRepo() bool {
|
||||
return pr.BaseRepoID == pr.HeadRepoID
|
||||
|
Reference in New Issue
Block a user