diff options
author | zeripath <art27@cantab.net> | 2021-11-17 20:37:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 20:37:00 +0000 |
commit | 3c4724d70e4ac7bfc06b97f6fad8936f97479b6b (patch) | |
tree | 754286def789b823e020d3ccfafae148d0017b62 /modules/repofiles | |
parent | 81a4fc752833101dd7d6b4f612bccc4b29c98dff (diff) | |
download | gitea-3c4724d70e4ac7bfc06b97f6fad8936f97479b6b.tar.gz gitea-3c4724d70e4ac7bfc06b97f6fad8936f97479b6b.zip |
Add .gitattribute assisted language detection to blame, diff and render (#17590)
Use check attribute code to check the assigned language of a file and send that in to
chroma as a hint for the language of the file.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/repofiles')
-rw-r--r-- | modules/repofiles/diff_test.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/repofiles/diff_test.go b/modules/repofiles/diff_test.go index 463ce4ec67..4bd1ef6f4d 100644 --- a/modules/repofiles/diff_test.go +++ b/modules/repofiles/diff_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/unittest" + "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/services/gitdiff" @@ -118,13 +119,21 @@ func TestGetDiffPreview(t *testing.T) { t.Run("with given branch", func(t *testing.T) { diff, err := GetDiffPreview(ctx.Repo.Repository, branch, treePath, content) assert.NoError(t, err) - assert.EqualValues(t, expectedDiff, diff) + expectedBs, err := json.Marshal(expectedDiff) + assert.NoError(t, err) + bs, err := json.Marshal(diff) + assert.NoError(t, err) + assert.EqualValues(t, expectedBs, bs) }) t.Run("empty branch, same results", func(t *testing.T) { diff, err := GetDiffPreview(ctx.Repo.Repository, "", treePath, content) assert.NoError(t, err) - assert.EqualValues(t, expectedDiff, diff) + expectedBs, err := json.Marshal(expectedDiff) + assert.NoError(t, err) + bs, err := json.Marshal(diff) + assert.NoError(t, err) + assert.EqualValues(t, expectedBs, bs) }) } |