diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/pull/pull.go | 9 | ||||
-rw-r--r-- | services/repository/files/tree.go | 7 | ||||
-rw-r--r-- | services/repository/push.go | 11 |
3 files changed, 8 insertions, 19 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go index 2829e15441..e55d4f5bb1 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -33,7 +33,6 @@ import ( repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - gitea_context "code.gitea.io/gitea/services/context" issue_service "code.gitea.io/gitea/services/issue" notify_service "code.gitea.io/gitea/services/notify" ) @@ -1065,11 +1064,9 @@ type CommitInfo struct { // GetPullCommits returns all commits on given pull request and the last review commit sha // Attention: The last review commit sha must be from the latest review whose commit id is not empty. // So the type of the latest review cannot be "ReviewTypeRequest". -func GetPullCommits(ctx *gitea_context.Context, issue *issues_model.Issue) ([]CommitInfo, string, error) { +func GetPullCommits(ctx context.Context, baseGitRepo *git.Repository, doer *user_model.User, issue *issues_model.Issue) ([]CommitInfo, string, error) { pull := issue.PullRequest - baseGitRepo := ctx.Repo.GitRepo - if err := pull.LoadBaseRepo(ctx); err != nil { return nil, "", err } @@ -1105,11 +1102,11 @@ func GetPullCommits(ctx *gitea_context.Context, issue *issues_model.Issue) ([]Co } var lastReviewCommitID string - if ctx.IsSigned { + if doer != nil { // get last review of current user and store information in context (if available) lastreview, err := issues_model.FindLatestReviews(ctx, issues_model.FindReviewOptions{ IssueID: issue.ID, - ReviewerID: ctx.Doer.ID, + ReviewerID: doer.ID, Types: []issues_model.ReviewType{ issues_model.ReviewTypeApprove, issues_model.ReviewTypeComment, diff --git a/services/repository/files/tree.go b/services/repository/files/tree.go index 419dbedd74..e481a3e7d2 100644 --- a/services/repository/files/tree.go +++ b/services/repository/files/tree.go @@ -90,11 +90,8 @@ func GetTreeBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git if rangeStart >= len(entries) { return tree, nil } - var rangeEnd int - if len(entries) > perPage { - tree.Truncated = true - } - rangeEnd = min(rangeStart+perPage, len(entries)) + rangeEnd := min(rangeStart+perPage, len(entries)) + tree.Truncated = rangeEnd < len(entries) tree.Entries = make([]api.GitEntry, rangeEnd-rangeStart) for e := rangeStart; e < rangeEnd; e++ { i := e - rangeStart diff --git a/services/repository/push.go b/services/repository/push.go index af3c873d15..7c68a7f176 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -402,16 +402,11 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo } rel, has := relMap[lowerTag] - - parts := strings.SplitN(tag.Message, "\n", 2) - note := "" - if len(parts) > 1 { - note = parts[1] - } + title, note := git.SplitCommitTitleBody(tag.Message, 255) if !has { rel = &repo_model.Release{ RepoID: repo.ID, - Title: parts[0], + Title: title, TagName: tags[i], LowerTagName: lowerTag, Target: "", @@ -430,7 +425,7 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo rel.Sha1 = commit.ID.String() rel.CreatedUnix = timeutil.TimeStamp(createdAt.Unix()) if rel.IsTag { - rel.Title = parts[0] + rel.Title = title rel.Note = note } else { rel.IsDraft = false |