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

Change gitCommitIdLength lower bound to 7 #173

Open
Brixomatic opened this issue Mar 7, 2022 · 1 comment
Open

Change gitCommitIdLength lower bound to 7 #173

Brixomatic opened this issue Mar 7, 2022 · 1 comment

Comments

@Brixomatic
Copy link

Issue

version: 1.9.0

usage context: any

Problem description:

Docs for settings say:

<gitCommitIdLength>integer</gitCommitIdLength>  <!-- between [8,40] -->

In Github all short commit IDs usually have 7 digits length, like in this project: c14645a.
If the Git commit ID from jgitver is used to create docker containers, for example, it is useful to have their tag correspond to a commit ID on Github. This is not possible, if the lower bound for the gitCommitIdLength is 8 instead of 7.

@McFoggy
Copy link
Contributor

McFoggy commented Mar 7, 2022

thanks for your interest and report,

concerning you're feedback: the sha1 that you are pointing on 7 chars c14645a is exactly the same if you use 8 characters c14645a1 or even 40 c14645a1900b47ac92c516319a987e6173e93006 so really I see no concern in using 7 or 8 characters to denote a commit id until it uniquely identifies a commit. And you will admit that with 8 characters you have less chances to collide than with 7.

then as you have seen in jgitver the short id is set to 8 characters (length hardcoded) here.

you're asking for 7 but based on git documentation the number of characters should be upper than 4 and controlled by the config option core.abbrev with a default value computed depending on the repository hashes (introduced in git 2.11.0).
On other parts of the git documentation I found mention of a default value to 7 which was a default prior to git-2.11.0.

I think that if an evolution is done, prviding for example a new Metadatas.GIT_SHA1_SHORT for example, it will have to take into account as much as possible core.abbrev config.

I have reported the enhancement request on jgitver itself jgitver/jgitver#142.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants