Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Option | Default | Description
`long` | `true` | Always adds commit distance and hash to `raw`, `suffix` and `.toString()` (matches the behaviour of git describe's `--long`)
`longSemver` | `false` | Always adds commit distance and hash to `semverString` (similar to git describe's `--long`, but for semver).
`requireAnnotated` | `false` | Uses `--tags` if false, so that simple git tags are allowed.
`match` | `'v[0-9]*'` | Uses `--match` to filter tag names. By default only tags resembling a version number are considered.
`match` | `'v[0-9]*'` | Uses `--match` to filter tag names. By default only tags resembling a version number are considered. Can be an array to use many `--match`.
`customArguments` | `[]` | Array of additional arguments to pass to `git describe`. Not all arguments are useful and some may even break the library, but things like `--abbrev` and `--candidates` should be safe to add.

[1]: https://git-scm.com/docs/git-describe
Expand Down
4 changes: 4 additions & 0 deletions lib/git-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ function createExecArgs(directory, options) {
execArgs.push('--tags');
if (_.isString(options.match))
execArgs = execArgs.concat(['--match', options.match]);
if (_.isArray(options.match))
options.match.forEach( match =>
execArgs = execArgs.concat(['--match', match])
);
if (_.isArray(options.customArguments))
execArgs = execArgs.concat(options.customArguments);
return execArgs;
Expand Down
7 changes: 7 additions & 0 deletions test/git-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ describe('gitDescribe', function() {
});
});

it('should accept an array for match', function() {
return gitDescribe(repoDir, {match: [ '*3' ] })
.then(function(gitInfo) {
gitInfo.tag.should.equal('v1.2.3');
});
});

it('should recognize dirty state', function() {
repo.changeData();
return gitDescribe(repoDir)
Expand Down