Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed usage of pointer to temporary variable.
  • Loading branch information
KN4CK3R committed Jun 30, 2021
commit f236707dd4b8517ab61ae9681b58cdb4f08d396e
8 changes: 4 additions & 4 deletions models/commit_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ type SignCommitWithStatuses struct {
}

// ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state
func ParseCommitsWithStatus(oldCommits []SignCommit, repo *Repository) []SignCommitWithStatuses {
newCommits := make([]SignCommitWithStatuses, 0, len(oldCommits))
func ParseCommitsWithStatus(oldCommits []*SignCommit, repo *Repository) []*SignCommitWithStatuses {
newCommits := make([]*SignCommitWithStatuses, 0, len(oldCommits))

for _, c := range oldCommits {
commit := SignCommitWithStatuses{
SignCommit: &c,
commit := &SignCommitWithStatuses{
SignCommit: c,
}
statuses, err := GetLatestCommitStatus(repo.ID, commit.ID.String(), ListOptions{})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions models/gpg_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,13 +829,13 @@ func verifyWithGPGSettings(gpgSettings *git.GPGSettings, sig *packet.Signature,
}

// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
func ParseCommitsWithSignature(oldCommits []UserCommit, repository *Repository) []SignCommit {
newCommits := make([]SignCommit, 0, len(oldCommits))
func ParseCommitsWithSignature(oldCommits []*UserCommit, repository *Repository) []*SignCommit {
newCommits := make([]*SignCommit, 0, len(oldCommits))
keyMap := map[string]bool{}

for _, c := range oldCommits {
signCommit := SignCommit{
UserCommit: &c,
signCommit := &SignCommit{
UserCommit: c,
Verification: ParseCommitWithSignature(c.Commit),
}

Expand Down
10 changes: 5 additions & 5 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ type Comment struct {
RefIssue *Issue `xorm:"-"`
RefComment *Comment `xorm:"-"`

Commits []SignCommitWithStatuses `xorm:"-"`
OldCommit string `xorm:"-"`
NewCommit string `xorm:"-"`
CommitsNum int64 `xorm:"-"`
IsForcePush bool `xorm:"-"`
Commits []*SignCommitWithStatuses `xorm:"-"`
OldCommit string `xorm:"-"`
NewCommit string `xorm:"-"`
CommitsNum int64 `xorm:"-"`
IsForcePush bool `xorm:"-"`
}

// PushActionContent is content of push pull comment
Expand Down
6 changes: 3 additions & 3 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1502,10 +1502,10 @@ func ValidateCommitWithEmail(c *git.Commit) *User {
}

// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
func ValidateCommitsWithEmails(oldCommits []*git.Commit) []UserCommit {
func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit {
var (
emails = make(map[string]*User)
newCommits = make([]UserCommit, 0, len(oldCommits))
newCommits = make([]*UserCommit, 0, len(oldCommits))
)
for _, c := range oldCommits {
var u *User
Expand All @@ -1518,7 +1518,7 @@ func ValidateCommitsWithEmails(oldCommits []*git.Commit) []UserCommit {
}
}

newCommits = append(newCommits, UserCommit{
newCommits = append(newCommits, &UserCommit{
User: u,
Commit: c,
})
Expand Down
8 changes: 3 additions & 5 deletions routers/web/repo/blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func RefBlame(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplBlame)
}

func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]models.UserCommit, map[string]string) {
func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*models.UserCommit, map[string]string) {
// store commit data by SHA to look up avatar info etc
commitNames := make(map[string]models.UserCommit)
commitNames := make(map[string]*models.UserCommit)
// previousCommits contains links from SHA to parent SHA,
// if parent also contains the current TreePath.
previousCommits := make(map[string]string)
Expand Down Expand Up @@ -190,8 +190,6 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
}

commits = append(commits, commit)

commitNames[commit.ID.String()] = models.UserCommit{}
}

// populate commit email addresses to later look up avatars.
Expand All @@ -202,7 +200,7 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
return commitNames, previousCommits
}

func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]models.UserCommit, previousCommits map[string]string) {
func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]*models.UserCommit, previousCommits map[string]string) {
repoLink := ctx.Repo.RepoLink

var lines = make([]string, 0)
Expand Down