Skip to content

Change how identities are shown in commit page #24087

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

Closed
wants to merge 11 commits into from

Conversation

n0toose
Copy link
Contributor

@n0toose n0toose commented Apr 12, 2023

The username is now always shown next to full names. The commit
information should use the full name associated with the commit and the
signature information should use the full name associated with the
profile, provided that it exists.

This should remove any confusion if the author decides to use different
names under the same account at a later point in time.

In some cases, the full names shown in specific fields may differ from
the profile's full name, as some other metadata may be preferred
instead.

@n0toose
Copy link
Contributor Author

n0toose commented Apr 12, 2023

I was going to just send this to Forgejo, but it'd end up here eventually, so. I am linking the previous PR as it shows some additional context regarding the decision as to how I chose how the names are going to be displayed to the user. I hope that this looks visually better / more informational than in other forges.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 12, 2023
@jolheiser
Copy link
Member

The following is an image reference using my actual settings as I have them on various instances.
(It really drives home who the author of that commit is 😂)

honk


I can see where this could be beneficial, but it almost seems like there should be a check on whether the names match, in which case it could just use one. i.e. jolheiser (jolheiser) doesn't look more clear, it just looks duplicated, however the GPG signature does look a bit nicer because my full name is shown with my handle next to it.
I can imagine that's also more helpful when people use less obvious handles than mine.

@silverwind
Copy link
Member

silverwind commented Apr 12, 2023

We should unify the way author name is display. Sometimes it's username, sometimes it's full name, sometimes it's both. I'd say always display full name if present. If full name and username match, display only full name. A custom render function will be needed.

@yardenshoham yardenshoham added the topic/ui Change the appearance of the Gitea UI label Apr 12, 2023
@n0toose
Copy link
Contributor Author

n0toose commented Apr 12, 2023

I tried to consider the following behind my design:

  • commits are snapshots of the past, the name can be changed at a later point in time (marriage, trans, etc.), it may not be worth showing all commit metadata as accurately as possible, which is why I use the Gitea profile's full name for commits. However, I insisted on being precise as far as PGP is concerned.
  • commit pages can (and perhaps should) be more detailed than the overviews
  • (extreme edge case) multiple people may be using the same account or identity
  • people shouldn't look at the avatar to compare whether the display name belongs to the same person

@n0toose
Copy link
Contributor Author

n0toose commented Apr 12, 2023

If full name and username match, display only full name.

ACK.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 13, 2023

The easier way is to use a template like: https://github.com/go-gitea/gitea/blob/main/templates/repo/search_name.tmpl

The "name displaying" logic usually is:

  • If DefaultShowFullName && FullName is not empty: $name ($fulllname)
  • Else: $name

At the moment the Gitea's name displaying is not clear / not consistent, that's a historical problem.

If you think search_name.tmpl could help, then it could be used here IMO (although the template name doesn't look good , or it's not usable due to its layout 🤣 )

If you prefer your current approach, it could also look good.

(I think I will do some "name displaying" refactoring in following PRs ....... 😄 )

@n0toose
Copy link
Contributor Author

n0toose commented Apr 13, 2023

Well, I also think that having way too many places with different ideas as to how a name should be shown is a bit cursed, but I think it'd make sense to get a bit more verbose in commit pages. The goal is to push the state of the UI towards a better direction (and not just introduce more edge cases and confusing inconsistencies) but I am not exactly sure what to do here without essentially having my hand held so as to fix this problem for good.

There's also the name of the owner of the key that a commit was signed with, which is not really shown everywhere.

@n0toose
Copy link
Contributor Author

n0toose commented Apr 13, 2023

I am also not sure how to deal with the committer case.

https://github.com/go-gitea/gitea/blob/62b0716205c658c20864767ea0fce8408663e536/templates/repo/commit_page.tmpl#L168

Can their username be discovered somehow?

@wxiaoguang
Copy link
Contributor

Can their username be discovered somehow?

I haven't understood the question "discover the username".

If I understand correctly, if the .Verification.CommittingUser and .Commit.Committer are User models, then the .Name is the username?

@n0toose
Copy link
Contributor Author

n0toose commented Apr 14, 2023

If I understand correctly, if the .Verification.CommittingUser and .Commit.Committer are User models, then the .Name is the username?

This is the part that has managed to confuse me very much, .Name seems to be the full name (as presented in their profile).

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 15, 2023

I think I somewhat understand these variables now. The details are in routers/web/repo/commit.go, func Diff(ctx *context.Context):

  • Author: it is a User model
  • Commit.Author: it is modules/git/Commit and modules/git/Signature:
    • Name string // Name represents a person name. It is an arbitrary string. It's the name from git commit
    • In case Gitea can't find a matched user in its database for this commit
  • Verification.SigningUser: it is modules/git/CommitVerification and User model

@n0toose
Copy link
Contributor Author

n0toose commented Apr 15, 2023

I just glanced over the code, thank you for the hints and the help here. So, just to be sure, is it true that we can't correlate committers and their respective on-platform usernames as things are right now?

@wxiaoguang
Copy link
Contributor

is it true that we can't correlate committers and their respective on-platform usernames as things are right now?

If the commit user can be found in Gitea's database (hmm, many more details, eg: by email, by key) as a site user, then these two "names" are correlated. Otherwise, not correlated because no clue to correlate them.

@n0toose
Copy link
Contributor Author

n0toose commented Apr 21, 2023

If the commit user can be found in Gitea's database (hmm, many more details, eg: by email, by key) as a site user, then these two "names" are correlated.

Hi, I am not sure if I can implement all that by myself because of a personal lack of experience and a hesitance of dealing with PII like this...

Small edit: I am still unsure how "exposing" variables in a template, I think this is beyond my current skill level.

@wxiaoguang
Copy link
Contributor

I think this PR could help you: Add a helper function dumpVar to help debugging and development #24262 (at least, we can know what variable type it is)

n0toose added 4 commits April 22, 2023 01:59
The username is now always shown next to full names. The commit
information should use the full name associated with the commit and the
signature information should use the full name associated with the
profile, provided that it exists.

This should remove any confusion if the author decides to use different
names under the same account at a later point in time.
@n0toose
Copy link
Contributor Author

n0toose commented Apr 22, 2023

Most of the things I typed out earlier regarding "committers being completely ignored" were wrong. .Verification.CommittingUser made me think that this parameter had something to do with PGP signatures, which was not the case.

I managed to figure out how the template works in greater detail by playing around with the code, breaking things, then undoing those things only to realize that the features that I described as "missing" existed in the first place. Anyways, this latest push is on top of the latest revision of the tree and ensures that Committers will follow the same format: Full Name As Stored In Examined Resource (Username) (excluding PGP key name, which uses Forgejo profile name instead)

The matching name + username case was considered in this case too.

@n0toose
Copy link
Contributor Author

n0toose commented Apr 22, 2023

image

@n0toose n0toose requested a review from jolheiser April 22, 2023 22:01
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Generally L-G-T-M.

Could we have some inline comments about the types of each variable? eg:


{{/* .Author: User model */}}

{{/* .Commit.Author:  modules/git/Commit, modules/git/Signature */}}

{{/* .Verification.SigningUser:  modules/git/CommitVerification, User model */}}

It would help future developers a lot.

@n0toose n0toose requested a review from wxiaoguang June 4, 2023 18:04
@n0toose
Copy link
Contributor Author

n0toose commented Jul 28, 2023

@wxiaoguang Apart from the comment that I haven't addressed at all yet (the logic behind this PR is extremely hard to follow if you haven't extensively worked with it over the past 24 hours to me), do you have any suggestions as to how my approach could be done in a cleaner manner?

@wxiaoguang
Copy link
Contributor

do you have any suggestions as to how my approach could be done in a cleaner manner?

Sorry I have no idea at the moment (I haven't got enough time and I haven't had enough understanding for this problem yet). I might take a look in the future if I have enough time but I can't guarantee at the moment.

So I hide my reviews. If other reviewers have ideas or approve, feel free to continue. Thank you.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 29, 2023

I tried to read the code again, I think it could be like this: fix name display n0toose#1

@n0toose
Copy link
Contributor Author

n0toose commented Jul 29, 2023

Blindly merged for now, I'll get back to this at a later point (this is still on my radar).

@pull-request-size pull-request-size bot added size/M and removed size/S labels Jul 29, 2023
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 29, 2023

Found some problems in my code, so added a new commit to fix them, and added some comments, I think the "user name" will be rendered in the following formats now:

  • If ShowFulName== false:
    • CommitterName // if the CommitterName == UserName
    • CommitterName (UserName) // if the CommitterName != UserName
  • If ShowFulName== true:
    • CommitterName // if the CommitterName == UserName and no FullName
    • CommitterName (FullName) // if the CommitterName == UserName and FullName exists
    • CommtiterName (UserName) // if the CommitterName != UserName and no FullName
    • CommitterName (UserName / FullName) // if the CommitterName != UserName and FullName exists

@n0toose
Copy link
Contributor Author

n0toose commented Aug 18, 2023

Really sorry for taking up your time with this earlier (thank you nevertheless!), but I think that I lack the time and concentration to actually solve this problem properly right now. I think that a better approach would be modifying the GetDisplayName() function properly instead of relying on a lot of conditionals in the web UI itself, which increases the overhead and is plain confusing.

If I am to pick this up again (which I remain interested in, just not interested enough to do this right now), I will do so in a new PR (maybe with a much more limited scope for starters). For now, I'll leave the space for someone else to do this, just in case this person appears.

@n0toose n0toose closed this Aug 18, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants