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

The hash is not prefixed with g #30

Open
agross opened this issue Mar 16, 2023 · 1 comment
Open

The hash is not prefixed with g #30

agross opened this issue Mar 16, 2023 · 1 comment

Comments

@agross
Copy link

agross commented Mar 16, 2023

Contrary to what the documentation states the hash value is not (always?) prefixed with a g.

In #6 (comment) it was discussed that git describe (the command) prepends g to the hash, but this is actually not the case.

$ git log --oneline -1
d4ec867 (HEAD -> pact, origin/pact) ...

$ git describe --always
d4ec867

git describe (the command) will only prepend the g if a tag was found and HEAD does not point to the nearest tag.

I'm reporting here because of absolute-version/absolute-version-js#3

@TimothyJones
Copy link
Collaborator

TimothyJones commented Mar 16, 2023

Thanks for this.

A clarification: I can't see in the documentation for node-git-describe where it says that the hash value always has a g prefix - are you saying that the example implies that this is the case, or have I missed a part in the documentation?

Anyway, I think the problem here is that because --always is always used (heh), it's not always a wrapper for the <describeOutput> format you linked, which says:

Output from git describe; i.e. a closest tag, optionally followed by a dash and a number of commits, followed by a dash, a g, and an abbreviated object name.

However, the output from git-describe doesn't always match that format - the documentation for --always says:

Show uniquely abbreviated commit object as fallback.

which would not include the g, of course.

I'm not sure what the right fix here is. I like the rationale in #6 where node-git-describe just repeats the git-describe output. But with --always, we're no longer getting <describeOutput> output if there aren't any tags. I think the two options are:

  1. Add a g if it is missing (this is the option that prioritises a consistent format for the hash field, but would be a breaking change), or
  2. Add a clarification in the README explaining that --always is used for the git-describe call, and so g may or may not be present (this is the option that prioritises matching the output from git-describe as close as possible).

I have a slight preference for option 2, as it fits with the rationale in #6 where this package just wraps git-describe (which I agree with).

What do you think?

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

No branches or pull requests

2 participants