Customize ShortSha length in templates [master] #5839

Open
opened 2025-11-02 06:37:48 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @gabyx on GitHub (Aug 7, 2020).

It would be nice if we could somehow customize the length of the ShortSha in the templates over app.ini or somehow else:

Such that all GUI related SHA hashes have some predefined length. In our setting, we need a length of 12.

The relevant code is here.
0e24af6951/modules/base/tool.go (L57)

Templates use

{{ShortSha .LatestCommit.ID.String}}
Originally created by @gabyx on GitHub (Aug 7, 2020). It would be nice if we could somehow customize the length of the ShortSha in the templates over `app.ini` or somehow else: Such that all GUI related SHA hashes have some predefined length. In our setting, we need a length of `12`. The relevant code is here. https://github.com/go-gitea/gitea/blob/0e24af6951fa65d5094ab6da0f182697aab2a6f0/modules/base/tool.go#L57 Templates use ```html {{ShortSha .LatestCommit.ID.String}} ```
GiteaMirror added the type/enhancementtype/proposal labels 2025-11-02 06:37:48 -06:00
Author
Owner

@bagasme commented on GitHub (Aug 7, 2020):

@gabyx why did you need 12-length shortsha? 100k+ commits?

@bagasme commented on GitHub (Aug 7, 2020): @gabyx why did you need 12-length shortsha? 100k+ commits?
Author
Owner

@6543 commented on GitHub (Aug 7, 2020):

I think the easyest way to go is with app.ini setting

@6543 commented on GitHub (Aug 7, 2020): I think the easyest way to go is with `app.ini` setting
Author
Owner

@zeripath commented on GitHub (Aug 7, 2020):

it'd be good if we could somehow just have this as a per repo setting - or even have git do this I guess the question is how expensive is it to generate these shortsha lengths?

@zeripath commented on GitHub (Aug 7, 2020): it'd be good if we could somehow just have this as a per repo setting - or even have git do this I guess the question is how expensive is it to generate these shortsha lengths?
Author
Owner

@stale[bot] commented on GitHub (Oct 12, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Oct 12, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@gabyx commented on GitHub (Oct 12, 2020):

Method without git config:

  • Just store the option somewhere global app.ini or per repo .gitea/....

Method git config:

First good solution would be to read git config core.abbrev and use this to shorten the commit sha. However you dont want to read this config value for every conversion. Also its unsafe, since we dont know if gitea relies on this setting for parsing stuff from the log or so...

So the user can define on the server a git config --global core.abbrev.
Later solution could be to add this to the app.ini for a global invocation of git config --set --global core.abbrev XXX at startup.

@gabyx commented on GitHub (Oct 12, 2020): ### Method without git config: - Just store the option somewhere global `app.ini` or per repo `.gitea/....` ### Method git config: First good solution would be to read `git config core.abbrev` and use this to shorten the commit sha. However you dont want to read this config value for every conversion. Also its unsafe, since we dont know if gitea relies on this setting for parsing stuff from the log or so... So the user can define on the server a `git config --global core.abbrev`. Later solution could be to add this to the app.ini for a global invocation of `git config --set --global core.abbrev XXX` at startup.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5839