Skip to content

Commit

Permalink
Fix NPE on view commit with notes
Browse files Browse the repository at this point in the history
Fix go-gitea#15558

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Apr 20, 2021
1 parent 5e85cda commit 88f39bf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/git/notes_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package git

import (
"io/ioutil"
"strings"
)

// GetNote retrieves the git-notes data for a given commit.
Expand Down Expand Up @@ -49,7 +50,13 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
}
note.Message = d

lastCommits, err := GetLastCommitForPaths(notes, "", []string{path})
treePath := ""
if idx := strings.LastIndex(path, "/"); idx > -1 {
treePath = path[:idx]
path = path[idx+1:]
}

lastCommits, err := GetLastCommitForPaths(notes, treePath, []string{path})
if err != nil {
return err
}
Expand Down

0 comments on commit 88f39bf

Please sign in to comment.