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 trace log to show value instead of pointers #18926

Merged
merged 9 commits into from
Feb 27, 2022

Conversation

Gusted
Copy link
Contributor

@Gusted Gusted commented Feb 27, 2022

  • Fixes a issue with a trace of repo.Units whereby it would show the pointers.

Before:
image

After:
image

- Add a `String` method for the `RepoUnit`, such as you print it, it
will show the repoUnit's type and not the whole struct(if passed as
value).
- Fixes a issue with a trace of repo.Units whereby it would show the pointers.
@Gusted Gusted added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Feb 27, 2022
@Gusted Gusted added this to the 1.17.0 milestone Feb 27, 2022
@Gusted Gusted added type/bug and removed type/refactoring Existing code has been cleaned up. There should be no new functionality. labels Feb 27, 2022
@Gusted
Copy link
Contributor Author

Gusted commented Feb 27, 2022

Might need to be backported, as this could be important for debugging when trace level is enabled.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 27, 2022
@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 Feb 27, 2022
models/repo/repo_unit.go Outdated Show resolved Hide resolved
models/repo/repo_unit.go Outdated Show resolved Hide resolved
@lunny
Copy link
Member

lunny commented Feb 27, 2022

You have to also change all places in the templates which use RepoUnit as function parameters, otherwise it will result in 500.
OK. This is different from Unit which is a int value when used in template it will be converted to string if it implemented Stringer.

@Gusted
Copy link
Contributor Author

Gusted commented Feb 27, 2022

Why? Will golang call the String function if passed as function argument?

@Gusted
Copy link
Contributor Author

Gusted commented Feb 27, 2022

OK. This is different from Unit which is a int value when used in template it will be converted to string if it implemented Stringer.

From what I see, the templates which are using the Units still function correctly... So it should be good?

models/repo/repo_unit.go Outdated Show resolved Hide resolved
@Gusted
Copy link
Contributor Author

Gusted commented Feb 27, 2022

Updated PR to instead fix-up the trace call(to avoid any issue when String() is being used accidental or not and doesn't give the full picture)

@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 Feb 27, 2022
models/repo/repo.go Outdated Show resolved Hide resolved
@delvh delvh self-requested a review February 27, 2022 14:40
models/repo/repo.go Outdated Show resolved Hide resolved
@zeripath
Copy link
Contributor

When I've done this before I've always been caught out with templates which are expecting to test against numbers - we need to double check these.

@Gusted Gusted changed the title Add String method for RepoUnit Fix trace log to show value instead of pointers Feb 27, 2022
@zeripath zeripath merged commit f56bba1 into go-gitea:main Feb 27, 2022
@Gusted Gusted deleted the string-repo-unit branch February 27, 2022 15:50
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 28, 2022
* giteaofficial/main:
  Adjust error for already locked db and prevent level db lock on malformed connstr (go-gitea#18923)
  Avoid database lookups for `DescriptionHTML` (go-gitea#18924)
  Update go-org to v1.6.1 (go-gitea#18932)
  Fix trace log to show value instead of pointers (go-gitea#18926)
  Add announcement steps to release-howto (go-gitea#18896)
  Fix `<strong>` html in translation (go-gitea#18929)
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
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/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants