From 99d8e7f6364396ad619092416f1e8aa45da7e7f8 Mon Sep 17 00:00:00 2001 From: Lionheart Zhang Date: Thu, 5 May 2022 20:05:25 +0800 Subject: [PATCH 1/3] add branchName for template --- lib/plugin/GitBase.js | 2 ++ lib/plugin/git/Git.js | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/plugin/GitBase.js b/lib/plugin/GitBase.js index 0ac217ea..39d9134f 100644 --- a/lib/plugin/GitBase.js +++ b/lib/plugin/GitBase.js @@ -15,6 +15,8 @@ class GitBase extends Plugin { const tagTemplate = this.options.tagName || ((latestTag || '').match(/^v/) ? 'v${version}' : '${version}'); this.setContext({ repo }); this.config.setContext({ tagTemplate, latestTag, secondLatestTag }); + const branchName = await this.getBranchName(); + this.setContext({ branchName }); } getName() { diff --git a/lib/plugin/git/Git.js b/lib/plugin/git/Git.js index b06915c2..3dde8f3a 100644 --- a/lib/plugin/git/Git.js +++ b/lib/plugin/git/Git.js @@ -49,6 +49,7 @@ class Git extends GitBase { throw e(`There are no commits since the latest tag.`, docs); } this.config.setContext({ repo: this.getContext('repo') }); + this.config.setContext({ branchName: this.getContext('branchName') }); } rollback() { From a37b6217d22f03692c3cd744fb58905d444fed27 Mon Sep 17 00:00:00 2001 From: Lionheart Zhang Date: Fri, 6 May 2022 22:16:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3getLatestTagName?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugin/GitBase.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugin/GitBase.js b/lib/plugin/GitBase.js index 39d9134f..c935b333 100644 --- a/lib/plugin/GitBase.js +++ b/lib/plugin/GitBase.js @@ -9,14 +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 }); - const branchName = await this.getBranchName(); - this.setContext({ branchName }); } getName() { From 3c9e7f3f1c125a341fd54a28b1851c06313e231c Mon Sep 17 00:00:00 2001 From: Lionheart Zhang Date: Fri, 6 May 2022 23:15:37 +0800 Subject: [PATCH 3/3] Just modify GitBase.js --- lib/plugin/GitBase.js | 2 +- lib/plugin/git/Git.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/plugin/GitBase.js b/lib/plugin/GitBase.js index c935b333..072772e1 100644 --- a/lib/plugin/GitBase.js +++ b/lib/plugin/GitBase.js @@ -16,7 +16,7 @@ class GitBase extends Plugin { 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() { diff --git a/lib/plugin/git/Git.js b/lib/plugin/git/Git.js index 3dde8f3a..b06915c2 100644 --- a/lib/plugin/git/Git.js +++ b/lib/plugin/git/Git.js @@ -49,7 +49,6 @@ class Git extends GitBase { throw e(`There are no commits since the latest tag.`, docs); } this.config.setContext({ repo: this.getContext('repo') }); - this.config.setContext({ branchName: this.getContext('branchName') }); } rollback() {