@@ -10,19 +10,24 @@ import (
10
10
"context"
11
11
"io/ioutil"
12
12
13
+ "code.gitea.io/gitea/modules/log"
14
+
13
15
"github.com/go-git/go-git/v5/plumbing/object"
14
16
)
15
17
16
18
// GetNote retrieves the git-notes data for a given commit.
17
19
func GetNote (ctx context.Context , repo * Repository , commitID string , note * Note ) error {
20
+ log .Trace ("Searching for git note corresponding to the commit %q in the repository %q" , commitID , repo .Path )
18
21
notes , err := repo .GetCommit (NotesRef )
19
22
if err != nil {
23
+ log .Error ("Unable to get commit from ref %q. Error: %v" , NotesRef , err )
20
24
return err
21
25
}
22
26
23
27
remainingCommitID := commitID
24
28
path := ""
25
29
currentTree := notes .Tree .gogitTree
30
+ log .Trace ("Found tree with ID %q while searching for git note corresponding to the commit %q" , currentTree .Entries [0 ].Name , commitID )
26
31
var file * object.File
27
32
for len (remainingCommitID ) > 2 {
28
33
file , err = currentTree .File (remainingCommitID )
@@ -39,19 +44,22 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
39
44
if err == object .ErrDirectoryNotFound {
40
45
return ErrNotExist {ID : remainingCommitID , RelPath : path }
41
46
}
47
+ log .Error ("Unable to find git note corresponding to the commit %q. Error: %v" , commitID , err )
42
48
return err
43
49
}
44
50
}
45
51
46
52
blob := file .Blob
47
53
dataRc , err := blob .Reader ()
48
54
if err != nil {
55
+ log .Error ("Unable to read blob with ID %q. Error: %v" , blob .ID , err )
49
56
return err
50
57
}
51
58
52
59
defer dataRc .Close ()
53
60
d , err := ioutil .ReadAll (dataRc )
54
61
if err != nil {
62
+ log .Error ("Unable to read blob with ID %q. Error: %v" , blob .ID , err )
55
63
return err
56
64
}
57
65
note .Message = d
@@ -68,6 +76,7 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
68
76
69
77
lastCommits , err := GetLastCommitForPaths (ctx , commitNode , "" , []string {path })
70
78
if err != nil {
79
+ log .Error ("Unable to get the commit for the path %q. Error: %v" , path , err )
71
80
return err
72
81
}
73
82
note .Commit = convertCommit (lastCommits [path ])
0 commit comments