diff options
author | Filip Navara <filip.navara@gmail.com> | 2019-09-12 03:14:41 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-09-12 09:14:41 +0800 |
commit | 52fda312dfd2ed93e512c8e210c5646e4ae53dbc (patch) | |
tree | 2451976cec416795a76ac7c66a3cf5b9d8d356b2 /modules/git/notes_test.go | |
parent | 5e67e0100ce0c0ad6cc8e595ab3d097e619e7e56 (diff) | |
download | gitea-52fda312dfd2ed93e512c8e210c5646e4ae53dbc.tar.gz gitea-52fda312dfd2ed93e512c8e210c5646e4ae53dbc.zip |
Fix reading git notes from nested trees (#8026)
* Fix reading notes from nested trees
The GIT documentation for notes states "Permitted pathnames have the
form ab/cd/ef/.../abcdef...: a sequence of directory names of two
hexadecimal digits each followed by a filename with the rest of
the object ID."
* Add test case
* Fix new lines
Diffstat (limited to 'modules/git/notes_test.go')
-rw-r--r-- | modules/git/notes_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/git/notes_test.go b/modules/git/notes_test.go index a954377f54..bf010b9a71 100644 --- a/modules/git/notes_test.go +++ b/modules/git/notes_test.go @@ -22,3 +22,17 @@ func TestGetNotes(t *testing.T) { assert.Equal(t, []byte("Note contents\n"), note.Message) assert.Equal(t, "Vladimir Panteleev", note.Commit.Author.Name) } + +func TestGetNestedNotes(t *testing.T) { + repoPath := filepath.Join(testReposDir, "repo3_notes") + repo, err := OpenRepository(repoPath) + assert.NoError(t, err) + + note := Note{} + err = GetNote(repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", ¬e) + assert.NoError(t, err) + assert.Equal(t, []byte("Note 2"), note.Message) + err = GetNote(repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", ¬e) + assert.NoError(t, err) + assert.Equal(t, []byte("Note 1"), note.Message) +} |