Skip to content

Commit

Permalink
Make full context available for git.tagName (closes #708)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 7, 2020
1 parent 229ed75 commit f942573
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/plugin/GitBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class GitBase extends Plugin {

bump(version) {
const { tagTemplate } = this.getContext();
const tagName = format(tagTemplate, { version }) || version;
const context = Object.assign(this.config.getContext(), { version });
const tagName = format(tagTemplate, context) || version;
this.setContext({ version, tagName });
this.config.setContext({ tagName });
}
Expand Down
5 changes: 3 additions & 2 deletions test/git.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ test.serial('should detect and exclude version prefix (configured)', async t =>
});

test.serial('should honor custom tagName configuration', async t => {
const gitClient = factory(Git, { options: { git: { tagName: 'TAGNAME-v${version}' } } });
const gitClient = factory(Git, { options: { git: { tagName: 'TAGNAME-${repo.project}-v${version}' } } });
sh.exec('git tag 1.0.0');
await gitClient.init();
await gitClient.bump('1.0.1');
t.is(gitClient.getContext('tagName'), 'TAGNAME-v1.0.1');
const { project } = gitClient.getContext('repo');
t.is(gitClient.getContext('tagName'), `TAGNAME-${project}-v1.0.1`);
});

test.serial('should get the latest tag after fetch', async t => {
Expand Down

0 comments on commit f942573

Please sign in to comment.