diff --git a/lib/src/Gren.js b/lib/src/Gren.js index 46a8e2d9..2e0fa155 100644 --- a/lib/src/Gren.js +++ b/lib/src/Gren.js @@ -7,6 +7,7 @@ import templateConfig from './templates.js'; import ObjectAssign from 'object-assign-deep'; import cmp from 'semver-compare'; import fs from 'fs'; +import { execSync } from 'child_process'; const defaults = { tags: [], @@ -46,6 +47,13 @@ class Gren { ignoreTagsWith } = this.options; + this.options.head = this.options.head || execSync('git symbolic-ref --short HEAD', { encoding: 'utf-8' }); + try { + execSync('git rev-parse --abbrev-ref --symbolic-full-name @{u}'); + } catch { + this.options.head = execSync("git remote show origin | grep 'HEAD branch' | cut -d' ' -f5", { encoding: 'utf-8' }); + } + this.options.head = this.options.head.trim(); this.options.tags = utils.convertStringToArray(tags); this.options.ignoreLabels = utils.convertStringToArray(ignoreLabels); this.options.ignoreIssuesWith = utils.convertStringToArray(ignoreIssuesWith); diff --git a/package.json b/package.json index 1e2f9508..c1b6091e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Create a release from a tag and uses issues or commits to creating the release notes. It also can generate a CHANGELOG.md file based on the release notes (or generate a brand new).", "main": "./github-release-notes.js", "scripts": { - "changelog": "node bin/gren.js changelog --override --generate --head master", + "changelog": "node bin/gren.js changelog --override --generate", "build": "gulp build", "prerelease": "git clean -xfd && npm ci && npm test && npm run build", "release": "release-it",