jgitver-maven-plugin icon indicating copy to clipboard operation
jgitver-maven-plugin copied to clipboard

Change gitCommitIdLength lower bound to 7

Open Brixomatic opened this issue 4 years ago • 1 comments

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.

Brixomatic avatar Mar 07 '22 18:03 Brixomatic

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 https://github.com/jgitver/jgitver/issues/142.

McFoggy avatar Mar 07 '22 21:03 McFoggy