Skip to content

Fix trace log to show value instead of pointers#18926

Merged
zeripath merged 9 commits into
go-gitea:mainfrom
Gusted:string-repo-unit
Feb 27, 2022
Merged

Fix trace log to show value instead of pointers#18926
zeripath merged 9 commits into
go-gitea:mainfrom
Gusted:string-repo-unit

Conversation

@Gusted

@Gusted Gusted commented Feb 27, 2022

Copy link
Copy Markdown
Contributor
  • 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

Gusted commented Feb 27, 2022

Copy link
Copy Markdown
Contributor Author

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
Comment thread models/repo/repo_unit.go Outdated
Comment thread models/repo/repo_unit.go Outdated
@lunny

lunny commented Feb 27, 2022

Copy link
Copy Markdown
Member

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

Gusted commented Feb 27, 2022

Copy link
Copy Markdown
Contributor Author

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

@Gusted

Gusted commented Feb 27, 2022

Copy link
Copy Markdown
Contributor Author

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?

Comment thread models/repo/repo_unit.go Outdated
@Gusted

Gusted commented Feb 27, 2022

Copy link
Copy Markdown
Contributor Author

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
Comment thread models/repo/repo.go Outdated
@delvh delvh self-requested a review February 27, 2022 14:40
Comment thread models/repo/repo.go Outdated
@zeripath

Copy link
Copy Markdown
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