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

Smaller commit hash like github? #55

Closed
nooblyf opened this issue Jul 26, 2024 · 11 comments
Closed

Smaller commit hash like github? #55

nooblyf opened this issue Jul 26, 2024 · 11 comments
Labels
enhancement New feature or request

Comments

@nooblyf
Copy link

nooblyf commented Jul 26, 2024

Describe the problem

Instead of using the full commit hash is there a setting to use just the first seven characters just for the text part? 🙂

Screenshot 2024-07-26 at 17 27 40

Describe the proposed solution

Like how GitHub does it, they are using the first 7 characters from commit hash

Screenshot 2024-07-26 at 17 27 49

For example, here's how it looks after using first 7 characters only

Screenshot 2024-07-26 at 17 34 42

Alternatives considered

Manually updating it when PR is created

Importance

nice to have

@nooblyf nooblyf added the enhancement New feature or request label Jul 26, 2024
@Hdoc1509
Copy link
Contributor

Hdoc1509 commented Oct 11, 2024

Hi, @nooblyf

After a deep dive through this PR changesets/changesets#1236, I found that this package just needs to:

Additional note

I tested locally and it works as expected.

I will add this changes to one of my projects and link it here in a few hours.

@nooblyf
Copy link
Author

nooblyf commented Oct 11, 2024

nvm, i was able to achieve it with a local script

@nooblyf nooblyf closed this as completed Oct 11, 2024
@dominikg
Copy link
Contributor

you should at least use a longer slice than 8, a collision can occur more likely with each char you cut

@Hdoc1509
Copy link
Contributor

you should at least use a longer slice than 8, a collision can occur more likely with each char you cut

Do you mean a collision in generated link?

Hdoc1509 added a commit to Hdoc1509/tree-sitter-hygen-template that referenced this issue Oct 11, 2024
until @svitejs/changesets-changelog-github-compact decides to update its
dependencies

svitejs/changesets-changelog-github-compact#55 (comment)
@dominikg
Copy link
Contributor

yes

@Hdoc1509
Copy link
Contributor

Well, that case is covered by @changesets/[email protected].

I made this implementation and used it for this CHANGELOG.md at v0.2.3.

Is this enough for publish a new version with these updates?

Thanks for reading n_n7

@nooblyf
Copy link
Author

nooblyf commented Oct 12, 2024

collision probability is very low even with 7 chars isn't it?

there are 36 possible chars (0-9a-z) in commit hash so 36^7 = ~78.4 Billion combinations. it would take ~40K IDs, in order to have a 1% probability of at least one collision

or am i missing something?

@dominikg
Copy link
Contributor

we had collisions with short hashes in vite-ecosystem-ci, better to use the short hash only in the label and full hash in the url. PR welcome. this repo is pretty low prio for me, ideally it's features found it's way back to changesets itself, feel free to raise your voice in their repo

@Hdoc1509
Copy link
Contributor

Yes. The short hash will only be used for label. Generated URL will remain intact.

@dominikg
Copy link
Contributor

released in 1.2.0, thanks!

@Hdoc1509
Copy link
Contributor

You're welcome. n_n7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants