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

Fix profile render when the README.md size is larger than 1024 bytes #25131

Merged
merged 13 commits into from
Jun 13, 2023

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Jun 8, 2023

Fixes #25094

GetBlobContent will only get the first 1024 bytes, if the README.md size is larger than 1024 bytes,
We can not render the rest of them.
After this fix, we should provide the limited size to read when call GetBlobContent.

After:
image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 8, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 8, 2023
@silverwind
Copy link
Member

silverwind commented Jun 8, 2023

I think we should instead add a limit parameter to GetBlobContent that defaults to 0 (no limit) and is passed as 1024 for the existing use cases of it (if it makes sense there). No need to duplicate and leave this deceiving function in-place imho.

@lunny
Copy link
Member

lunny commented Jun 8, 2023

Yes, that function should be changed, at least the name.

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 8, 2023
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 8, 2023
@silverwind
Copy link
Member

Are we certain we can change the previous use cases from 1024 to 0? I imagine this might have been done for performance reasons in cases where the exact content was not needed.

@@ -203,7 +203,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
} else if entry.IsLink() {
contentsResponse.Type = string(ContentTypeLink)
// The target of a symlink file is the content of the file
targetFromContent, err := entry.Blob().GetBlobContent()
targetFromContent, err := entry.Blob().GetBlobContent(1024)
Copy link
Member

@silverwind silverwind Jun 8, 2023

Choose a reason for hiding this comment

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

Should investigate closer what this does, but does not have to be in this PR. It might be that this is another undiscovered bug and it should actually use 0 here.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 8, 2023
modules/git/blob.go Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 13, 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 Jun 13, 2023
@lunny lunny added type/bug backport/v1.20 This PR should be backported to Gitea 1.20 labels Jun 13, 2023
@lunny lunny added this to the 1.21.0 milestone Jun 13, 2023
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Jun 13, 2023
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 13, 2023
modules/git/blob.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Jun 13, 2023
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 13, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 13, 2023
@lunny lunny enabled auto-merge (squash) June 13, 2023 07:14
@lunny lunny merged commit 22a39bb into go-gitea:main Jun 13, 2023
@GiteaBot
Copy link
Contributor

I was unable to create a backport for 1.20. @yp05327, please send one manually. 🍵

go run ./contrib/backport 25131
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added backport/manual No power to the bots! Create your backport yourself! and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Jun 13, 2023
@lunny lunny added the backport/done All backports for this PR have been created label Jun 15, 2023
@yp05327 yp05327 deleted the fix-profile-render branch June 15, 2023 00:42
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jun 15, 2023
* upstream/main: (31 commits)
  Show OAuth2 errors to end users (go-gitea#25261)
  [skip ci] Updated translations via Crowdin
  Fix index generation parallelly failure (go-gitea#25235)
  Fix variable in template (go-gitea#25267)
  Add template linting via djlint (go-gitea#25212)
  Fix edit OAuth application width (go-gitea#25262)
  Use flex to align SVG and text (go-gitea#25163)
  GitHub Actions enhancements for frontend (go-gitea#25150)
  Add missing `v` in migrations.go (go-gitea#25252)
  Change form actions to fetch for submit review box (go-gitea#25219)
  Fix panic when migrating a repo from GitHub with issues (go-gitea#25246)
  Fix description of drop custom_labels migration (go-gitea#25243)
  Fix all possible setting error related storages and added some tests (go-gitea#23911)
  [skip ci] Updated translations via Crowdin
  Revert overflow: overlay (revert go-gitea#21850) (go-gitea#25231)
  Support changing labels of Actions runner without re-registration (go-gitea#24806)
  Improve AJAX link and modal confirm dialog (go-gitea#25210)
  Use inline SVG for built-in OAuth providers (go-gitea#25171)
  Disable `Create column` button while the column name is empty  (go-gitea#25192)
  Fix profile render when the README.md size is larger than 1024 bytes (go-gitea#25131)
  ...
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.20 This PR should be backported to Gitea 1.20 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It's inconsistent between README rendering and user profile rendering
5 participants