tvdstaaij / node-git-describe

Git describe information at runtime, with semver support
36 stars 5 forks source link

nice to have: add "--always" to customArguments by default #1

Closed james-hu closed 9 years ago

james-hu commented 9 years ago

When people use git describe in the code, normally they expect to have a string returned even if there is no tag in the repository at all. Therefore, it makes sense to add "--always" to customArguments by default.

tvdstaaij commented 9 years ago

I hadn't considered this because in my use case the existence of at least one tag can be assumed. But you're absolutely right, treating this as an error condition is poor behavior.

The library will now use --always internally and produce something like this when no tags exist:

{ dirty: false,
  raw: '11953a8',
  hash: '11953a8',
  distance: null,
  tag: null,
  semver: null,
  suffix: '11953a8',
  semverString: null }

This also works with dirty repository states:

{ dirty: true,
  raw: '11953a8-dirty',
  hash: '11953a8',
  distance: null,
  tag: null,
  semver: null,
  suffix: '11953a8-dirty',
  semverString: null }