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

Customize ShortSha length in templates [master] #12451

Open
gabyx opened this issue Aug 7, 2020 · 5 comments
Open

Customize ShortSha length in templates [master] #12451

gabyx opened this issue Aug 7, 2020 · 5 comments
Labels
type/enhancement An improvement of existing functionality type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@gabyx
Copy link

gabyx commented 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.

return TruncateString(sha1, 10)

Templates use

{{ShortSha .LatestCommit.ID.String}}
@gabyx gabyx changed the title Customize ShortSha [master] customize ShortSha length in templates [master] Aug 7, 2020
@gabyx gabyx changed the title customize ShortSha length in templates [master] Customize ShortSha length in templates [master] Aug 7, 2020
@bagasme
Copy link
Contributor

bagasme commented Aug 7, 2020

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

@6543
Copy link
Member

6543 commented Aug 7, 2020

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

@zeripath
Copy link
Contributor

zeripath commented 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?

@stale
Copy link

stale bot commented 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 stale bot added the issue/stale label Oct 12, 2020
@gabyx
Copy link
Author

gabyx commented 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.

@stale stale bot removed the issue/stale label Oct 12, 2020
@denyskon denyskon added type/enhancement An improvement of existing functionality type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement An improvement of existing functionality type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

5 participants