Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace repo.namedBlob by git.TreeEntry. #22898

Merged
merged 9 commits into from Mar 15, 2023

Conversation

kousu
Copy link
Contributor

@kousu kousu commented Feb 13, 2023

namedBlob turned out to be a poor imitation of a TreeEntry. Using the latter directly shortens this code.

This partially undoes #23152, which I found a merge conflict with, and also expands the test it added to cover the subtle README-in-a-subfolder case.

Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just asked myself if this cache type was implemented for performance reasons, but according to the method implementations, that is negligible…
Was that different previously?
Otherwise, I don't know how this could happen.

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 13, 2023
@kousu
Copy link
Contributor Author

kousu commented Feb 13, 2023

for performance reasons

And even if it was, it was only optimizing for README files. How heavy is that really?

Otherwise, I don't know how this could happen.

Thanks for the vote of confidence!

@zeripath
Copy link
Contributor

IIRC we needed the namedBlob at some point because we were passing round git.Blobs but we're able to get the TreeEntry just as easily now so it might be needed anymore

routers/web/repo/view.go Outdated Show resolved Hide resolved
routers/web/repo/view.go Outdated Show resolved Hide resolved
@kousu kousu marked this pull request as draft February 17, 2023 15:55
@kousu

This comment was marked as resolved.

@codecov-commenter

This comment was marked as off-topic.

@kousu kousu marked this pull request as ready for review March 9, 2023 01:33
`namedBlob` turned out to be a poor imitation of a `TreeEntry`.
Using the latter directly shorten this code.
@kousu
Copy link
Contributor Author

kousu commented Mar 10, 2023

The current CI failures are

Init storage failed: Put "http://minio:9000/gitea/": dial tcp: lookup minio on 127.0.0.11:53: no such host

and

=== Test_DeleteOrphanedIssueLabels (/drone/src/models/migrations/v1_14/v177_test.go:37)

LoadFixtures failed after retries: testfixtures: error inserting record: pq: column "exclusive" of relation "label" does not exist, on file: label.yml, index: 0, sql: INSERT INTO "label" ("num_closed_issues", "id", "repo_id", "org_id", "name", "color", "exclusive", "num_issues") VALUES ($1, $2, $3, $4, $5, $6, $7, $8), params: [0 1 1 0 label1 #abcdef false 2]

--- FAIL: Test_DeleteOrphanedIssueLabels (5.07s)

    v177_test.go:37: initializing fixtures from: /drone/src/models/migrations/fixtures/Test_DeleteOrphanedIssueLabels

    v177_test.go:37: error whilst loading fixtures from /drone/src/models/migrations/fixtures/Test_DeleteOrphanedIssueLabels: testfixtures: error inserting record: pq: column "exclusive" of relation "label" does not exist, on file: label.yml, index: 0, sql: INSERT INTO "label" ("num_closed_issues", "id", "repo_id", "org_id", "name", "color", "exclusive", "num_issues") VALUES ($1, $2, $3, $4, $5, $6, $7, $8), params: [0 1 1 0 label1 #abcdef false 2]

FAIL

FAIL	code.gitea.io/gitea/models/migrations/v1_14	6.460s

FAIL

These don't seem to be related to this patch. I'll restart and if it happens again I guess I'll try to reproduce locally.

EDIT: passing now; all I did was merge main: https://drone.gitea.io/go-gitea/gitea/69318

size: 7028
size: 7320
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had to change due to the test additions I did. I used the same test repo (user2/repo1.git) that #23152 did, but I don't know why that PR didn't force changing this number.

Metas: ctx.Repo.Repository.ComposeDocumentMetas(),
GitRepo: ctx.Repo.GitRepo,
}, rd)
if err != nil {
log.Error("Render failed for %s in %-v: %v Falling back to rendering source", readmeFile.name, ctx.Repo.Repository, err)
log.Error("Render failed for %s in %-v: %v Falling back to rendering source", readmeFile.Name(), ctx.Repo.Repository, err)
Copy link
Contributor Author

@kousu kousu Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps

Suggested change
log.Error("Render failed for %s in %-v: %v Falling back to rendering source", readmeFile.Name(), ctx.Repo.Repository, err)
log.Error("Render failed for %s in %-v: %v Falling back to rendering source", path.Join(subfolder, readmeFile.Name()), ctx.Repo.Repository, err)

?

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Mar 12, 2023
@lunny lunny added this to the 1.20.0 milestone Mar 12, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 15, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 15, 2023
@lunny
Copy link
Member

lunny commented Mar 15, 2023

Please update branch

@kousu
Copy link
Contributor Author

kousu commented Mar 15, 2023

Thank you @lunny, @delvh and @zeripath :)

@jolheiser jolheiser added the reviewed/prioritize-merge PR is in the merge queue. Merge as soon as possible, i.e. as edits by maintainers are not enabled label Mar 15, 2023
@jolheiser
Copy link
Member

@kousu
Please update again, I've added a label so we can get it merged hopefully without bugging you too many more times. 🙂

@kousu
Copy link
Contributor Author

kousu commented Mar 15, 2023

Of course! Here it comes around again.

I really appreciate getting this in. I've had my eye on this patch for a couple of months now.

Did I do something wrong btw? Did I miss clicking "Allow Edits from Maintainers" or something?

@jolheiser
Copy link
Member

Did I do something wrong btw? Did I miss clicking "Allow Edits from Maintainers" or something?

Nope, not your fault, I believe it's a GitHub thing that doesn't let us update it because it's from an org vs a user account.

@jolheiser jolheiser merged commit 6aef9e0 into go-gitea:main Mar 15, 2023
@jolheiser jolheiser removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. reviewed/prioritize-merge PR is in the merge queue. Merge as soon as possible, i.e. as edits by maintainers are not enabled labels Mar 15, 2023
@kousu kousu deleted the treeentry-findReadmeFile branch March 16, 2023 01:15
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 16, 2023
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Replace `repo.namedBlob` by `git.TreeEntry`. (go-gitea#22898)
  Fix theme-auto loading (go-gitea#23504)
  Update path to docs theme file (go-gitea#23502)
  Use arm image for arm runner (go-gitea#23503)
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants