Skip to content

Commit 024aeb0

Browse files
tsvetomirgyoshev
authored andcommitted
fix: fallback to last official tag for gitHead
1 parent 1ed3b6a commit 024aeb0

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

generateNotes.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
const changelog = require('conventional-changelog')
22
const parseUrl = require('github-url-from-git')
3-
const execSync = require('child_process').execSync;
4-
5-
const lastTag = () => execSync(
6-
'git describe --tags --match "v[0-9]*" --exclude="*dev*" --abbrev=0 origin/master',
7-
{ encoding: 'utf8' }
8-
).trim();
3+
const lastTag = require('./lastTag');
94

105
module.exports = function (pluginConfig, {pkg}, cb) {
116
const repository = pkg.repository ? parseUrl(pkg.repository.url) : null

getLastRelease.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const defaultLastRelease = require('@semantic-release/last-release-npm');
2+
const lastTag = require('./lastTag');
23

34
module.exports = function (pluginConfig, config, cb) {
45
let branch;
@@ -20,7 +21,7 @@ module.exports = function (pluginConfig, config, cb) {
2021

2122
return defaultLastRelease(pluginConfig, config, function(err, res) {
2223
if (!res.gitHead) {
23-
res.gitHead = 'origin/master';
24+
res.gitHead = lastTag();
2425
}
2526

2627
if (distTag) {

lastTag.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const execSync = require('child_process').execSync;
2+
3+
const lastTag = () => execSync(
4+
'git describe --tags --match "v[0-9]*" --exclude="*dev*" --abbrev=0 origin/master',
5+
{ encoding: 'utf8' }
6+
).trim();
7+
8+
module.exports = lastTag;

0 commit comments

Comments
 (0)