From e33a24c6aa74856cdfdcf7c974eec13cf8059c16 Mon Sep 17 00:00:00 2001 From: Tumay Ceber Date: Tue, 7 Sep 2021 16:35:10 +0300 Subject: [PATCH] feat: lightweight tags is added as option --- README.md | 7 +++++++ command.js | 5 +++++ defaults.js | 1 + lib/lifecycles/tag.js | 16 ++++++++++------ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f924f6073..b5120abdf 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,13 @@ standard-version --no-verify If you have your GPG key set up, add the `--sign` or `-s` flag to your `standard-version` command. +### Using Lightweight Tags + +This is basically the commit checksum stored in a file -- no other information is kept. +It's useful for tagging beta, alpha etc. versions without increasing your git repository size. +Add the `--lightweight-tag` to your `standard-version` command. +See [lightweight tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_lightweight_tags) for more information. + ### Lifecycle Scripts `standard-version` supports lifecycle scripts. These allow you to execute your diff --git a/command.js b/command.js index d65d5ea06..0f468d9cc 100755 --- a/command.js +++ b/command.js @@ -45,6 +45,11 @@ const yargs = require('yargs') type: 'boolean', default: defaults.sign }) + .option('lightweight-tag', { + describe: 'Should the git tag be lightweight? \nThis is basically the commit checksum stored in a file, no other information is kept.', + type: 'boolean', + default: defaults.lightweightTag + }) .option('no-verify', { alias: 'n', describe: 'Bypass pre-commit or commit-msg git hooks during the commit phase', diff --git a/defaults.js b/defaults.js index 614c453e4..34db9e9d0 100644 --- a/defaults.js +++ b/defaults.js @@ -4,6 +4,7 @@ const defaults = { infile: 'CHANGELOG.md', firstRelease: false, sign: false, + lightweightTag: false, noVerify: false, commitAll: false, silent: false, diff --git a/lib/lifecycles/tag.js b/lib/lifecycles/tag.js index ec1b88e53..a8b146349 100644 --- a/lib/lifecycles/tag.js +++ b/lib/lifecycles/tag.js @@ -14,14 +14,18 @@ module.exports = async function (newVersion, pkgPrivate, args) { } async function execTag (newVersion, pkgPrivate, args) { - let tagOption - if (args.sign) { - tagOption = '-s' + checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion]) + if (args.lightweightTag) { + await runExecFile(args, 'git', ['tag', args.tagPrefix + newVersion]) } else { - tagOption = '-a' + let tagOption + if (args.sign) { + tagOption = '-s' + } else { + tagOption = '-a' + } + await runExecFile(args, 'git', ['tag', tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`]) } - checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion]) - await runExecFile(args, 'git', ['tag', tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`]) const currentBranch = await runExecFile('', 'git', ['rev-parse', '--abbrev-ref', 'HEAD']) let message = 'git push --follow-tags origin ' + currentBranch.trim() if (pkgPrivate !== true && bump.getUpdatedConfigs()['package.json']) {