From 6037043adf23dcd87a77c2d0855e2d902e2bacc7 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Thu, 22 Dec 2022 12:33:17 +0200 Subject: [PATCH 1/6] Fix container layer display overflow (#22208) Before: ![attels](https://user-images.githubusercontent.com/165205/209109653-6c690569-ddbe-4d8b-ab42-66b9a9c6a556.png) After: ![attels](https://user-images.githubusercontent.com/165205/209110521-8aa8fc1c-21c8-4280-9b39-ab560b6d95f4.png) --- templates/package/content/container.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/package/content/container.tmpl b/templates/package/content/container.tmpl index a79963e732..34d495f356 100644 --- a/templates/package/content/container.tmpl +++ b/templates/package/content/container.tmpl @@ -46,7 +46,7 @@ {{end}} {{if .PackageDescriptor.Metadata.ImageLayers}}

{{.locale.Tr "packages.container.layers"}}

-
+
{{range .PackageDescriptor.Metadata.ImageLayers}} From ac5b44b2f40a8d427805470f334b2c87bc4fdd32 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 22 Dec 2022 12:29:33 +0100 Subject: [PATCH 2/6] Upgrade hugo to 0.82 (#22209) See https://github.com/go-gitea/gitea/pull/22206#issuecomment-1362523796. Apparently hugo 0.81.0 is a broken release in regards to checksums. https://github.com/gohugoio/hugo/releases/tag/v0.82.0 Co-authored-by: Lauris BH --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index fcc932c07d..f47ad4de3c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ THEME := themes/gitea PUBLIC := public ARCHIVE := https://dl.gitea.io/theme/master.tar.gz -HUGO_PACKAGE := github.com/gohugoio/hugo@v0.81.0 +HUGO_PACKAGE := github.com/gohugoio/hugo@v0.82.0 .PHONY: all all: build From 8c1bb7743784bb0f0754acc7f6855432fddca653 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 22 Dec 2022 21:09:35 +0800 Subject: [PATCH 3/6] Remove test session cache to reduce possible concurrent problem (#22199) --- tests/integration/integration_test.go | 10 ++-------- tests/integration/signout_test.go | 3 --- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 3537409aeb..911d9ddf4c 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -209,8 +209,6 @@ func (s *TestSession) MakeRequestNilResponseHashSumRecorder(t testing.TB, req *h const userPassword = "password" -var loginSessionCache = make(map[string]*TestSession, 10) - func emptyTestSession(t testing.TB) *TestSession { t.Helper() jar, err := cookiejar.New(nil) @@ -225,12 +223,8 @@ func getUserToken(t testing.TB, userName string) string { func loginUser(t testing.TB, userName string) *TestSession { t.Helper() - if session, ok := loginSessionCache[userName]; ok { - return session - } - session := loginUserWithPassword(t, userName, userPassword) - loginSessionCache[userName] = session - return session + + return loginUserWithPassword(t, userName, userPassword) } func loginUserWithPassword(t testing.TB, userName, password string) *TestSession { diff --git a/tests/integration/signout_test.go b/tests/integration/signout_test.go index 0416930c67..0e822ac04e 100644 --- a/tests/integration/signout_test.go +++ b/tests/integration/signout_test.go @@ -21,7 +21,4 @@ func TestSignOut(t *testing.T) { // try to view a private repo, should fail req = NewRequest(t, "GET", "/user2/repo2") session.MakeRequest(t, req, http.StatusNotFound) - - // invalidate cached cookies for user2, for subsequent tests - delete(loginSessionCache, "user2") } From 7bf7c13b64f15f957bc280f0744d34518dde69e9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 22 Dec 2022 23:36:01 +0800 Subject: [PATCH 4/6] Frontport 1.17.4 changelog (#22216) --- CHANGELOG.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1150d70081..e9ba23b4c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,60 @@ This changelog goes through all the changes that have been made in each release without substantial changes to our git log; to see the highlights of what has been added to each release, please refer to the [blog](https://blog.gitea.io). +## [1.17.4](https://github.com/go-gitea/gitea/releases/tag/1.17.4) - 2022-12-21 + +* SECURITY + * Do not allow Ghost access to limited visible user/org (#21849) (#21875) + * Fix package access for admins and inactive users (#21580) (#21592) +* ENHANCEMENTS + * Fix button in branch list, avoid unexpected page jump before restore branch actually done (#21562) (#21927) + * Fix vertical align of committer avatar rendered by email address (#21884) (#21919) + * Fix setting HTTP headers after write (#21833) (#21874) + * Ignore line anchor links with leading zeroes (#21728) (#21777) + * Enable Monaco automaticLayout (#21516) +* BUGFIXES + * Do not list active repositories as unadopted (#22034) (#22167) + * Correctly handle moved files in apply patch (#22118) (#22136) + * Fix condition for is_internal (#22095) (#22131) + * Fix permission check on issue/pull lock (#22114) + * Fix sorting admin user list by last login (#22081) (#22106) + * Workaround for container registry push/pull errors (#21862) (#22069) + * Fix issue/PR numbers (#22037) (#22045) + * Handle empty author names (#21902) (#22028) + * Fix ListBranches to handle empty case (#21921) (#22025) + * Fix enabling partial clones on 1.17 (#21809) + * Prevent panic in doctor command when running default checks (#21791) (#21808) + * Upgrade golang.org/x/crypto (#21792) (#21794) + * Init git module before database migration (#21764) (#21766) + * Set last login when activating account (#21731) (#21754) + * Add HEAD fix to gitea doctor (#21352) (#21751) + * Fix UI language switching bug (#21597) (#21748) + * Remove semver compatible flag and change pypi to an array of test cases (#21708) (#21729) + * Allow local package identifiers for PyPI packages (#21690) (#21726) + * Fix repository adoption on Windows (#21646) (#21651) + * Sync git hooks when config file path changed (#21619) (#21625) + * Added check for disabled Packages (#21540) (#21614) + * Fix `Timestamp.IsZero` (#21593) (#21604) + * Fix issues count bug (#21600) + * Support binary deploy in npm packages (#21589) + * Update milestone counters when issue is deleted (#21459) (#21586) + * SessionUser protection against nil pointer dereference (#21581) + * Case-insensitive NuGet symbol file GUID (#21409) (#21575) + * Suppress `ExternalLoginUserNotExist` error (#21504) (#21572) + * Prevent Authorization header for presigned LFS urls (#21531) (#21569) + * Update binding to fix bugs (#21560) + * Fix generating compare link (#21519) (#21530) + * Ignore error when retrieving changed PR review files (#21487) (#21524) + * Fix incorrect notification commit url (#21479) (#21483) + * Display total commit count in hook message (#21400) (#21481) + * Enforce grouped NuGet search results (#21442) (#21480) + * Return 404 when user is not found on avatar (#21476) (#21477) + * Normalize NuGet package version on upload (#22186) (#22201) +* MISC + * Check for zero time instant in TimeStamp.IsZero() (#22171) (#22173) + * Fix warn in database structs sync (#22111) + * Allow for resolution of NPM registry paths that match upstream (#21568) (#21723) + ## [1.17.3](https://github.com/go-gitea/gitea/releases/tag/v1.17.3) - 2022-10-15 * SECURITY From ea5a752ee66f5f8dccbc058c4e1220e24e01b3e8 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Thu, 22 Dec 2022 10:47:57 -0500 Subject: [PATCH 5/6] update docs latest to 1.17.4 --- docs/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.yaml b/docs/config.yaml index 91afc2e972..b80602cb61 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -18,7 +18,7 @@ params: description: Git with a cup of tea author: The Gitea Authors website: https://docs.gitea.io - version: 1.17.3 + version: 1.17.4 minGoVersion: 1.18 goVersion: 1.19 minNodeVersion: 14 From a2779def36590518157c4315a02e7cbaefcecb92 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 22 Dec 2022 18:41:56 -0500 Subject: [PATCH 6/6] Test views of LFS files (#22196) --- CONTRIBUTING.md | 2 + models/db/iterate_test.go | 2 +- models/fixtures/lfs_meta_object.yml | 32 +++++++ models/fixtures/repo_unit.yml | 6 ++ models/fixtures/repository.yml | 11 +++ models/fixtures/user.yml | 2 +- ...51df93acc2bdd9e6373be478b968e4cad6b6647351 | Bin 0 -> 107 bytes ...2daa20075cff1d97d9d2349a8977efe9c03661737c | Bin 0 -> 2048 bytes ...69b67fee2b698ef7e9399c4ca4f34a14ccbe39f623 | 1 + ...ec6afe9ea052f3c9b6ff9f4b07956d8c48c86fca82 | 1 + .../user2/lfs.git/HEAD | 1 + .../user2/lfs.git/config | 4 + .../15/2de0f78bc6815b58cd9f08aebe3f66fb0f172e | Bin 0 -> 228 bytes .../23/10e4a07f9314a1a92fdfbdcd3d2884f01e96ab | Bin 0 -> 123 bytes .../2b/6c6c4eaefa24b22f2092c3d54b263ff26feb58 | Bin 0 -> 122 bytes .../73/cf03db6ece34e12bf91e8853dc58f678f2f82d | 2 + .../74/21a018a7e3f15ee5691f162d0ed87dc19882f0 | Bin 0 -> 123 bytes .../82/76d2a29779af982c0afa976bdb793b52d442a8 | Bin 0 -> 38 bytes .../bc/e50ea8f203ee923d5a640d05208abf3206486e | Bin 0 -> 92 bytes .../d4/a41a0d4db4949e129bd22f871171ea988103ef | Bin 0 -> 123 bytes .../d7/ce0013ced38b0696dd2d68d69a5d8b652f7148 | Bin 0 -> 55 bytes .../df/d8105b264d304c49ed9f1d56bd90189ecdf833 | Bin 0 -> 75 bytes .../user2/lfs.git/refs/heads/master | 1 + tests/integration/lfs_view_test.go | 83 ++++++++++++++++++ tests/test_utils.go | 28 ++++++ 25 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 models/fixtures/lfs_meta_object.yml create mode 100644 tests/gitea-lfs-meta/0b/8d/8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351 create mode 100644 tests/gitea-lfs-meta/2e/cc/db43825d2a49d99d542daa20075cff1d97d9d2349a8977efe9c03661737c create mode 100644 tests/gitea-lfs-meta/7b/6b/2c88dba9f760a1a58469b67fee2b698ef7e9399c4ca4f34a14ccbe39f623 create mode 100644 tests/gitea-lfs-meta/9d/17/2e5c64b4f0024b9901ec6afe9ea052f3c9b6ff9f4b07956d8c48c86fca82 create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/HEAD create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/config create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/15/2de0f78bc6815b58cd9f08aebe3f66fb0f172e create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/23/10e4a07f9314a1a92fdfbdcd3d2884f01e96ab create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/2b/6c6c4eaefa24b22f2092c3d54b263ff26feb58 create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/73/cf03db6ece34e12bf91e8853dc58f678f2f82d create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/74/21a018a7e3f15ee5691f162d0ed87dc19882f0 create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/82/76d2a29779af982c0afa976bdb793b52d442a8 create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/bc/e50ea8f203ee923d5a640d05208abf3206486e create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/d4/a41a0d4db4949e129bd22f871171ea988103ef create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/d7/ce0013ced38b0696dd2d68d69a5d8b652f7148 create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/objects/df/d8105b264d304c49ed9f1d56bd90189ecdf833 create mode 100644 tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master create mode 100644 tests/integration/lfs_view_test.go diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69363c415e..bd5672643a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -190,6 +190,8 @@ To maintain understandable code and avoid circular dependencies it is important - **templates:** Golang templates for generating the html output. - **tests/e2e:** End to end tests - **tests/integration:** Integration tests +- **tests/gitea-repositories-meta:** Sample repos used in integration tests. Adding a new repo requires editing `models/fixtures/repositories.yml` and `models/fixtures/repo_unit.yml` to match. +- **tests/gitea-lfs-meta:** Sample LFS objects used in integration tests. Adding a new object requires editing `models/fixtures/lfs_meta_object.yml` to match. - **vendor:** External code that Gitea depends on. ## Documentation diff --git a/models/db/iterate_test.go b/models/db/iterate_test.go index 57b1bd3cd1..63487afa49 100644 --- a/models/db/iterate_test.go +++ b/models/db/iterate_test.go @@ -25,7 +25,7 @@ func TestIterate(t *testing.T) { return nil }) assert.NoError(t, err) - assert.EqualValues(t, 80, repoCnt) + assert.EqualValues(t, 81, repoCnt) err = db.Iterate(db.DefaultContext, nil, func(ctx context.Context, repoUnit *repo_model.RepoUnit) error { reopUnit2 := repo_model.RepoUnit{ID: repoUnit.ID} diff --git a/models/fixtures/lfs_meta_object.yml b/models/fixtures/lfs_meta_object.yml new file mode 100644 index 0000000000..1c29e02d44 --- /dev/null +++ b/models/fixtures/lfs_meta_object.yml @@ -0,0 +1,32 @@ +# These are the LFS objects in user2/lfs.git +- + + id: 1 + oid: 0b8d8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351 + size: 107 + repository_id: 54 + created_unix: 1671607299 + +- + + id: 2 + oid: 2eccdb43825d2a49d99d542daa20075cff1d97d9d2349a8977efe9c03661737c + size: 107 + repository_id: 54 + created_unix: 1671607299 + +- + + id: 3 + oid: 7b6b2c88dba9f760a1a58469b67fee2b698ef7e9399c4ca4f34a14ccbe39f623 + size: 27 + repository_id: 54 + created_unix: 1671607299 + +- + + id: 4 + oid: 9d172e5c64b4f0024b9901ec6afe9ea052f3c9b6ff9f4b07956d8c48c86fca82 + size: 25 + repository_id: 54 + created_unix: 1671607299 diff --git a/models/fixtures/repo_unit.yml b/models/fixtures/repo_unit.yml index 73db47218b..8706717ad4 100644 --- a/models/fixtures/repo_unit.yml +++ b/models/fixtures/repo_unit.yml @@ -550,3 +550,9 @@ repo_id: 53 type: 1 created_unix: 946684810 + +- + id: 81 + repo_id: 54 + type: 1 + created_unix: 946684810 diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index a5a3dd0601..19b243fb4e 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -1585,3 +1585,14 @@ size: 0 is_fsck_enabled: true close_issues_via_commit_in_any_branch: false + +- + id: 54 + owner_id: 2 + owner_name: user2 + lower_name: lfs + name: lfs + is_empty: false + is_archived: false + is_private: true + status: 0 diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index 1b870e8999..3afed37df9 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -66,7 +66,7 @@ num_followers: 2 num_following: 1 num_stars: 2 - num_repos: 9 + num_repos: 10 num_teams: 0 num_members: 0 visibility: 0 diff --git a/tests/gitea-lfs-meta/0b/8d/8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351 b/tests/gitea-lfs-meta/0b/8d/8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351 new file mode 100644 index 0000000000000000000000000000000000000000..71911bf48766c7181518c1070911019fbb00b1fc GIT binary patch literal 107 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 literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/23/10e4a07f9314a1a92fdfbdcd3d2884f01e96ab b/tests/gitea-repositories-meta/user2/lfs.git/objects/23/10e4a07f9314a1a92fdfbdcd3d2884f01e96ab new file mode 100644 index 0000000000000000000000000000000000000000..16a791a4ab4294466079e8128b8cd267f3f2c775 GIT binary patch literal 123 zcmV->0EGW|0S(1L5`!QN0KlGo1s|wD3P}77iAiO~7DudyzP{bd($>g$m~NLGy|%Ym z&vWmywaM{8 dq>38IO&HUXIb_aBxnvl6{fdD&`~bC&DV%{iJfi>r literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/2b/6c6c4eaefa24b22f2092c3d54b263ff26feb58 b/tests/gitea-repositories-meta/user2/lfs.git/objects/2b/6c6c4eaefa24b22f2092c3d54b263ff26feb58 new file mode 100644 index 0000000000000000000000000000000000000000..d8d55b14fa1bc6ff5d781be1e48f53561c2304de GIT binary patch literal 122 zcmV-=0EPc}0S(1V62c%108rPQf(uyW(?EI~k_KU>N~hE=JiWfnqpg#+F5WIVM(b}~ z&vPG(G0%41w=$;x^+OZ)ml?aTxvc7K)uU!N!x9O|aY`#?ED;{r<~apGf>=Zx0VXL? c&?9o-9EuOw24)hE1)Nu-eMP&de#l8F*E@kWc>n+a literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/73/cf03db6ece34e12bf91e8853dc58f678f2f82d b/tests/gitea-repositories-meta/user2/lfs.git/objects/73/cf03db6ece34e12bf91e8853dc58f678f2f82d new file mode 100644 index 0000000000..5eee31d8aa --- /dev/null +++ b/tests/gitea-repositories-meta/user2/lfs.git/objects/73/cf03db6ece34e12bf91e8853dc58f678f2f82d @@ -0,0 +1,2 @@ +xQ +B!EvbƗAD70V¹'RrMY0Y";28:/AĜ&Z_6]g\dk9%ihXG?O]g@}97 \ No newline at end of file diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/74/21a018a7e3f15ee5691f162d0ed87dc19882f0 b/tests/gitea-repositories-meta/user2/lfs.git/objects/74/21a018a7e3f15ee5691f162d0ed87dc19882f0 new file mode 100644 index 0000000000000000000000000000000000000000..cbbde812d7aa0c8a42c6d0f2a0fe19abb9282a48 GIT binary patch literal 123 zcmV->0EGW|0S(1L62c%106@=u1s|{!5(4x$gn(tHN=IrBzFzmTymwZ{hTB!%qxF~C z&hr?n){l1H_d4eP+lS}epL!f6>&r~Ni5gq7j@E^P1a{T91ql$UfUW3^)CehO%ObH5 dc;JFQaHLQ$Cm|+656(=ZeTy=SpMKb_DPlJ|J6iw% literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/82/76d2a29779af982c0afa976bdb793b52d442a8 b/tests/gitea-repositories-meta/user2/lfs.git/objects/82/76d2a29779af982c0afa976bdb793b52d442a8 new file mode 100644 index 0000000000000000000000000000000000000000..cbee9fb5a0aba392bab4eb4459fb5255e7f883ac GIT binary patch literal 38 ucmb7IDb#L&E-<1+v?g%BeE literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/bc/e50ea8f203ee923d5a640d05208abf3206486e b/tests/gitea-repositories-meta/user2/lfs.git/objects/bc/e50ea8f203ee923d5a640d05208abf3206486e new file mode 100644 index 0000000000000000000000000000000000000000..83e8159975cb9efbb8f2dcc2e219cd6d1f23e5d7 GIT binary patch literal 92 zcmV-i0HgnS0V^p=O;s?rWH2-^Ff%bx&`ZxONh~QT%1kOPNiAl$evU!-+~sbzX?Jxq yuFZ<=PSr2;fT|2~b#(D{)yqv`P!@QypnkH*!j<~>_nx)YX!#&FZ8ZQo(IC?S&MR^N literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/d4/a41a0d4db4949e129bd22f871171ea988103ef b/tests/gitea-repositories-meta/user2/lfs.git/objects/d4/a41a0d4db4949e129bd22f871171ea988103ef new file mode 100644 index 0000000000000000000000000000000000000000..01f6e7bc630fa24e36852cac598a7b341456b6d3 GIT binary patch literal 123 zcmV->0EGW|0S(2$5yBu406^bVK?4RjAmq{w+<`C?B_o)J)$4vX9X&|{c)Rj@wEmKH z&U5TaJ=(keCoR;UYMhzWWkhc*M~&du9WoIoXE*Q+(IF$Ucfc`%*1=OLhA}WQ dSch@L5OT>#+ODe!Hjo(Yn3V+e9}bn$i7%S};8%giZBEwar?D^^I!OiKeZa#M@aQ^73V NlGKV4E&$$05(t)97Z?Bl literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/objects/df/d8105b264d304c49ed9f1d56bd90189ecdf833 b/tests/gitea-repositories-meta/user2/lfs.git/objects/df/d8105b264d304c49ed9f1d56bd90189ecdf833 new file mode 100644 index 0000000000000000000000000000000000000000..11940b8f795fe8dd75046c644ca8dce1db2e64a0 GIT binary patch literal 75 zcmV-R0JQ&j0ZYosPf{>6He+!1_X`Q~bP5ge^mEtCO;Je8%qdANvdu{=R!GTAO9L}< hQ;X75!7Sa9)QS==ExoLQbRtzIW#$p35&+pLF|PB9AgurZ literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master b/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master new file mode 100644 index 0000000000..8832a3e857 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/lfs.git/refs/heads/master @@ -0,0 +1 @@ +73cf03db6ece34e12bf91e8853dc58f678f2f82d diff --git a/tests/integration/lfs_view_test.go b/tests/integration/lfs_view_test.go new file mode 100644 index 0000000000..1775fa629f --- /dev/null +++ b/tests/integration/lfs_view_test.go @@ -0,0 +1,83 @@ +// Copyright 2022 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package integration + +import ( + "net/http" + "testing" + + "code.gitea.io/gitea/tests" + + "github.com/stretchr/testify/assert" +) + +// check that files stored in LFS render properly in the web UI +func TestLFSRender(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + session := loginUser(t, "user2") + + // check that a markup file is flagged with "Stored in Git LFS" and shows its text + t.Run("Markup", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/CONTRIBUTING.md") + resp := session.MakeRequest(t, req, http.StatusOK) + + doc := NewHTMLParser(t, resp.Body).doc + + fileInfo := doc.Find("div.file-info-entry").First().Text() + assert.Contains(t, fileInfo, "Stored with Git LFS") + + content := doc.Find("div.file-view").Text() + assert.Contains(t, content, "Testing documents in LFS") + }) + + // check that an image is flagged with "Stored in Git LFS" and renders inline + t.Run("Image", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/jpeg.jpg") + resp := session.MakeRequest(t, req, http.StatusOK) + + doc := NewHTMLParser(t, resp.Body).doc + + fileInfo := doc.Find("div.file-info-entry").First().Text() + assert.Contains(t, fileInfo, "Stored with Git LFS") + + src, exists := doc.Find(".file-view img").Attr("src") + assert.True(t, exists, "The image should be in an tag") + assert.Equal(t, "/user2/lfs/media/branch/master/jpeg.jpg", src, "The image should use the /media link because it's in LFS") + }) + + // check that a binary file is flagged with "Stored in Git LFS" and renders a /media/ link instead of a /raw/ link + t.Run("Binary", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/crypt.bin") + resp := session.MakeRequest(t, req, http.StatusOK) + + doc := NewHTMLParser(t, resp.Body).doc + + fileInfo := doc.Find("div.file-info-entry").First().Text() + assert.Contains(t, fileInfo, "Stored with Git LFS") + + rawLink, exists := doc.Find("div.file-view > div.view-raw > a").Attr("href") + assert.True(t, exists, "Download link should render instead of content because this is a binary file") + assert.Equal(t, "/user2/lfs/media/branch/master/crypt.bin", rawLink, "The download link should use the proper /media link because it's in LFS") + }) + + // check that a directory with a README file shows its text + t.Run("Readme", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/subdir") + resp := session.MakeRequest(t, req, http.StatusOK) + + doc := NewHTMLParser(t, resp.Body).doc + + content := doc.Find("div.file-view").Text() + assert.Contains(t, content, "Testing READMEs in LFS") + }) +} diff --git a/tests/test_utils.go b/tests/test_utils.go index b4bd4a011e..721edc86f8 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -167,7 +167,11 @@ func PrepareTestEnv(t testing.TB, skip ...int) func() { ourSkip += skip[0] } deferFn := PrintCurrentTest(t, ourSkip) + + // load database fixtures assert.NoError(t, unittest.LoadFixtures()) + + // load git repo fixtures assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath)) ownerDirs, err := os.ReadDir(setting.RepoRootPath) @@ -190,6 +194,16 @@ func PrepareTestEnv(t testing.TB, skip ...int) func() { } } + // load LFS object fixtures + // (LFS storage can be on any of several backends, including remote servers, so we init it with the storage API) + lfsFixtures, err := storage.NewStorage("", storage.LocalStorageConfig{Path: path.Join(filepath.Dir(setting.AppPath), "tests/gitea-lfs-meta")}) + assert.NoError(t, err) + assert.NoError(t, storage.Clean(storage.LFS)) + assert.NoError(t, lfsFixtures.IterateObjects(func(path string, _ storage.Object) error { + _, err := storage.Copy(storage.LFS, path, lfsFixtures, path) + return err + })) + return deferFn } @@ -198,7 +212,11 @@ func PrepareTestEnv(t testing.TB, skip ...int) func() { // within a single test this is required func ResetFixtures(t *testing.T) { assert.NoError(t, queue.GetManager().FlushAll(context.Background(), -1)) + + // load database fixtures assert.NoError(t, unittest.LoadFixtures()) + + // load git repo fixtures assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath)) ownerDirs, err := os.ReadDir(setting.RepoRootPath) @@ -220,4 +238,14 @@ func ResetFixtures(t *testing.T) { _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0o755) } } + + // load LFS object fixtures + // (LFS storage can be on any of several backends, including remote servers, so we init it with the storage API) + lfsFixtures, err := storage.NewStorage("", storage.LocalStorageConfig{Path: path.Join(filepath.Dir(setting.AppPath), "tests/gitea-lfs-meta")}) + assert.NoError(t, err) + assert.NoError(t, storage.Clean(storage.LFS)) + assert.NoError(t, lfsFixtures.IterateObjects(func(path string, _ storage.Object) error { + _, err := storage.Copy(storage.LFS, path, lfsFixtures, path) + return err + })) }