forked from conventional-changelog/standard-version
-
Notifications
You must be signed in to change notification settings - Fork 43
Only bump and create changelog if there ir a breaking change, feature or fix #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hazzo
wants to merge
4
commits into
absolute-version:master
Choose a base branch
from
hazzo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0ceea0c
feat: skip version bumping if no commits
4785715
feat: simplified not bumping version by copying whatBump function and…
8c9c5ce
fix: _whatBump also check for fix types to avoid upgrading if there a…
e936987
chore: added config flag and linted files. Missing tests
hazzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -12,8 +12,45 @@ const runLifecycleScript = require('../run-lifecycle-script') | |||||||
const semver = require('semver') | ||||||||
const writeFile = require('../write-file') | ||||||||
const { resolveUpdaterObjectFromArgument } = require('../updaters') | ||||||||
const addBangNotes = require('conventional-changelog-conventionalcommits/add-bang-notes') | ||||||||
let configsToUpdate = {} | ||||||||
|
||||||||
function _whatBump(config, commits) { | ||||||||
let level = 2 | ||||||||
let breakings = 0 | ||||||||
let features = 0 | ||||||||
let fix = 0 | ||||||||
|
||||||||
commits.forEach(commit => { | ||||||||
addBangNotes(commit) | ||||||||
if (commit.notes.length > 0) { | ||||||||
breakings += commit.notes.length | ||||||||
level = 0 | ||||||||
} else if (commit.type === 'feat' || commit.type === 'feature') { | ||||||||
features += 1 | ||||||||
if (level === 2) { | ||||||||
level = 1 | ||||||||
} | ||||||||
} | ||||||||
if(commit.type === 'fix') { | ||||||||
fix += 1 | ||||||||
} | ||||||||
}) | ||||||||
|
||||||||
if (config.preMajor && level < 2) { | ||||||||
level++ | ||||||||
} | ||||||||
|
||||||||
if(!breakings && !features && !fix) return {} | ||||||||
|
||||||||
return { | ||||||||
level: level, | ||||||||
reason: breakings === 1 | ||||||||
? `There is ${breakings} BREAKING CHANGE and ${features} features` | ||||||||
: `There are ${breakings} BREAKING CHANGES and ${features} features` | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
async function Bump (args, version) { | ||||||||
// reset the cache of updated config files each | ||||||||
// time we perform the version bump step. | ||||||||
|
@@ -25,6 +62,14 @@ async function Bump (args, version) { | |||||||
const stdout = await runLifecycleScript(args, 'prebump') | ||||||||
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim() | ||||||||
const release = await bumpVersion(args.releaseAs, version, args) | ||||||||
if (!Object.keys(release).length) { | ||||||||
checkpoint( | ||||||||
args, | ||||||||
'no commits found, so not bumping version', | ||||||||
[] | ||||||||
) | ||||||||
return null | ||||||||
} | ||||||||
if (!args.firstRelease) { | ||||||||
const releaseType = getReleaseType(args.prerelease, release.releaseType, version) | ||||||||
const releaseTypeAsVersion = releaseType === 'pre' + release.releaseType ? semver.valid(release.releaseType + '-' + args.prerelease + '.0') : semver.valid(releaseType) | ||||||||
|
@@ -107,8 +152,9 @@ function getTypePriority (type) { | |||||||
return TypeList.indexOf(type) | ||||||||
} | ||||||||
|
||||||||
function bumpVersion (releaseAs, currentVersion, args) { | ||||||||
return new Promise((resolve, reject) => { | ||||||||
function bumpVersion(releaseAs, currentVersion, args) { | ||||||||
// eslint-disable-next-line no-async-promise-executor | ||||||||
return new Promise(async (resolve, reject) => { | ||||||||
Comment on lines
+156
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Unless I'm missing something, you don't need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I'll remove it it's from an old implementation. |
||||||||
if (releaseAs) { | ||||||||
return resolve({ | ||||||||
releaseType: releaseAs | ||||||||
|
@@ -123,7 +169,8 @@ function bumpVersion (releaseAs, currentVersion, args) { | |||||||
preset: presetOptions, | ||||||||
path: args.path, | ||||||||
tagPrefix: args.tagPrefix, | ||||||||
lernaPackage: args.lernaPackage | ||||||||
lernaPackage: args.lernaPackage, | ||||||||
whatBump(commits) { return _whatBump(presetOptions, commits) } | ||||||||
}, args.parserOpts, function (err, release) { | ||||||||
if (err) return reject(err) | ||||||||
else return resolve(release) | ||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.