diff options
author | Rowan Bohde <rowan.bohde@gmail.com> | 2024-08-14 16:50:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-15 05:50:09 +0800 |
commit | 1310649331648d747c57a52ea3bc92da85e7d4d1 (patch) | |
tree | b507f0052103392ff5c1fcd4282167f66298c28e /tests | |
parent | 7569a470fb552c8aa0186fcdcc8e8bd921cfd6e0 (diff) | |
download | gitea-1310649331648d747c57a52ea3bc92da85e7d4d1.tar.gz gitea-1310649331648d747c57a52ea3bc92da85e7d4d1.zip |
render plain text file if the LFS object doesn't exist (#31812)
We had an issue where a repo was using LFS to store a file, but the user
did not push the file. When trying to view the file, Gitea returned a
500 HTTP status code referencing `ErrLFSObjectNotExist`. It appears the
intent was the render this file as plain text, but the conditional was
flipped. I've also added a test to verify that the file is rendered as
plain text.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gitea-repositories-meta/user2/lfs.git/objects/30/77e1c4c8964613df72c37d14275c1eda5228a9 | 2 | ||||
-rw-r--r-- | tests/gitea-repositories-meta/user2/lfs.git/objects/6b/bc79965141058b0026f2064dfb6d2eae3c4540 | bin | 0 -> 259 bytes | |||
-rw-r--r-- | tests/gitea-repositories-meta/user2/lfs.git/objects/b0/89e97ee59224e8c5676673c096ee4b6a8b9342 | bin | 0 -> 123 bytes | |||
-rw-r--r-- | tests/gitea-repositories-meta/user2/lfs.git/objects/e9/c32647bab825977942598c0efa415de300304b | bin | 0 -> 170 bytes | |||
-rw-r--r-- | tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master | 2 | ||||
-rw-r--r-- | tests/integration/lfs_view_test.go | 13 |
6 files changed, 16 insertions, 1 deletions
diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/30/77e1c4c8964613df72c37d14275c1eda5228a9 b/tests/gitea-repositories-meta/user2/lfs.git/objects/30/77e1c4c8964613df72c37d14275c1eda5228a9 new file mode 100644 index 0000000000..c2dc6e5a4f --- /dev/null +++ b/tests/gitea-repositories-meta/user2/lfs.git/objects/30/77e1c4c8964613df72c37d14275c1eda5228a9 @@ -0,0 +1,2 @@ +xKÊÉOR0´0`pö÷ òt +
ñôs×ËMQHËÌ)I-²ÍI+VHÉLK3rS‹ÒSÁ,Ý’ÔŠ.-½¬‚t"U&eæ¥23¯,1'“8ûØæAÅ
\ No newline at end of file diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/6b/bc79965141058b0026f2064dfb6d2eae3c4540 b/tests/gitea-repositories-meta/user2/lfs.git/objects/6b/bc79965141058b0026f2064dfb6d2eae3c4540 Binary files differnew file mode 100644 index 0000000000..97455cbc46 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/lfs.git/objects/6b/bc79965141058b0026f2064dfb6d2eae3c4540 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/b0/89e97ee59224e8c5676673c096ee4b6a8b9342 b/tests/gitea-repositories-meta/user2/lfs.git/objects/b0/89e97ee59224e8c5676673c096ee4b6a8b9342 Binary files differnew file mode 100644 index 0000000000..33ab64e730 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/lfs.git/objects/b0/89e97ee59224e8c5676673c096ee4b6a8b9342 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/e9/c32647bab825977942598c0efa415de300304b b/tests/gitea-repositories-meta/user2/lfs.git/objects/e9/c32647bab825977942598c0efa415de300304b Binary files differnew file mode 100644 index 0000000000..f513e2a308 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/lfs.git/objects/e9/c32647bab825977942598c0efa415de300304b diff --git a/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master b/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master index 8832a3e857..487a433af2 100644 --- a/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master +++ b/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master @@ -1 +1 @@ -73cf03db6ece34e12bf91e8853dc58f678f2f82d +e9c32647bab825977942598c0efa415de300304b diff --git a/tests/integration/lfs_view_test.go b/tests/integration/lfs_view_test.go index c28ecf1d7a..05770e5e0a 100644 --- a/tests/integration/lfs_view_test.go +++ b/tests/integration/lfs_view_test.go @@ -89,6 +89,19 @@ func TestLFSRender(t *testing.T) { content := doc.Find("div.file-view").Text() assert.Contains(t, content, "Testing READMEs in LFS") }) + + // check that an invalid lfs entry defaults to plaintext + t.Run("Invalid", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/invalid") + resp := session.MakeRequest(t, req, http.StatusOK) + + doc := NewHTMLParser(t, resp.Body).doc + + content := doc.Find("div.file-view").Text() + assert.Contains(t, content, "oid sha256:9d178b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351") + }) } // TestLFSLockView tests the LFS lock view on settings page of repositories |