From 9aa9a5d805952d833e31c3e9a63840a7d9c3d283 Mon Sep 17 00:00:00 2001 From: Lionheart Zhang Date: Tue, 9 Aug 2022 19:46:22 +0800 Subject: [PATCH] add branchName for template (#897) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add branchName for template * fix: 修正getLatestTagName报错问题 * Just modify GitBase.js Co-authored-by: Lionheart Zhang --- lib/plugin/GitBase.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/plugin/GitBase.js b/lib/plugin/GitBase.js index 0ac217ea..072772e1 100644 --- a/lib/plugin/GitBase.js +++ b/lib/plugin/GitBase.js @@ -9,12 +9,14 @@ class GitBase extends Plugin { async init() { this.remoteUrl = await this.getRemoteUrl(); await this.fetch(); + const branchName = await this.getBranchName(); + this.setContext({ branchName }); const repo = parseGitUrl(this.remoteUrl); const latestTag = await this.getLatestTagName(repo); const secondLatestTag = !this.config.isIncrement ? await this.getSecondLatestTagName(latestTag) : null; const tagTemplate = this.options.tagName || ((latestTag || '').match(/^v/) ? 'v${version}' : '${version}'); this.setContext({ repo }); - this.config.setContext({ tagTemplate, latestTag, secondLatestTag }); + this.config.setContext({ tagTemplate, latestTag, secondLatestTag, branchName }); } getName() {