From 0629f3cd8af8068a0f6daedc1312c37d1936d87f Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Fri, 13 Sep 2019 14:46:30 -0400 Subject: [PATCH] revert: feat: create annotated tags This reverts commit 4d581fc140dda99065542872d125cf27fb24798f. --- index.js | 4 ++-- lib/definitions/constants.js | 3 --- lib/git.js | 14 +++++--------- test/git.test.js | 6 +++--- test/helpers/git-utils.js | 2 +- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 985c9159..4116759c 100644 --- a/index.js +++ b/index.js @@ -106,7 +106,7 @@ async function run(context, plugins) { nextRelease.notes = await plugins.generateNotes({...context, commits, lastRelease, nextRelease}); logger.log('Create tag %s', nextRelease.gitTag); - await tag(nextRelease, {cwd, env}); + await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env}); await push(options.repositoryUrl, {cwd, env}); context.branch.tags.push({ version: nextRelease.version, @@ -170,7 +170,7 @@ async function run(context, plugins) { logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`); } else { // Create the tag before calling the publish plugins as some require the tag to exists - await tag(nextRelease, {cwd, env}); + await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env}); await push(options.repositoryUrl, {cwd, env}); logger.success(`Created tag ${nextRelease.gitTag}`); } diff --git a/lib/definitions/constants.js b/lib/definitions/constants.js index 9de9d957..491a1a71 100644 --- a/lib/definitions/constants.js +++ b/lib/definitions/constants.js @@ -14,8 +14,6 @@ const SECRET_REPLACEMENT = '[secure]'; const SECRET_MIN_SIZE = 5; -const TAG_MESSAGE_FORMAT = `release \${version}`; - module.exports = { RELEASE_TYPE, FIRST_RELEASE, @@ -25,5 +23,4 @@ module.exports = { RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT, SECRET_MIN_SIZE, - TAG_MESSAGE_FORMAT, }; diff --git a/lib/git.js b/lib/git.js index ef7ac9e2..4f53ed78 100644 --- a/lib/git.js +++ b/lib/git.js @@ -1,9 +1,8 @@ -const {matches, pick, memoize, template} = require('lodash'); +const {matches, pick, memoize} = require('lodash'); const gitLogParser = require('git-log-parser'); const getStream = require('get-stream'); const execa = require('execa'); const debug = require('debug')('semantic-release:git'); -const {TAG_MESSAGE_FORMAT} = require('./definitions/constants'); Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}}); @@ -223,17 +222,14 @@ async function verifyAuth(repositoryUrl, branch, execaOpts) { /** * Tag the commit head on the local repository. * - * @param {Object} release The release associated with the tag. + * @param {String} tagName The name of the tag. + * @param {String} ref The Git reference to tag. * @param {Object} [execaOpts] Options to pass to `execa`. * * @throws {Error} if the tag creation failed. */ -async function tag(release, execaOpts) { - await execa( - 'git', - ['tag', release.gitTag, release.gitHead, '-a', '-m', template(TAG_MESSAGE_FORMAT)(release)], - execaOpts - ); +async function tag(tagName, ref, execaOpts) { + await execa('git', ['tag', tagName, ref], execaOpts); } /** diff --git a/test/git.test.js b/test/git.test.js index 994a68dc..d804966d 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -183,7 +183,7 @@ test('Add tag on head commit', async t => { const {cwd} = await gitRepo(); const commits = await gitCommits(['Test commit'], {cwd}); - await tag({gitTag: 'tag_name', gitHead: 'HEAD', version: '1.0.0'}, {cwd}); + await tag('tag_name', 'HEAD', {cwd}); await t.is(await gitCommitTag(commits[0].hash, {cwd}), 'tag_name'); }); @@ -193,7 +193,7 @@ test('Push tag to remote repository', async t => { const {cwd, repositoryUrl} = await gitRepo(true); const commits = await gitCommits(['Test commit'], {cwd}); - await tag({gitTag: 'tag_name', gitHead: 'HEAD', version: '1.0.0'}, {cwd}); + await tag('tag_name', 'HEAD', {cwd}); await push(repositoryUrl, {cwd}); t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash); @@ -207,7 +207,7 @@ test('Push tag to remote repository with remote branch ahead', async t => { await gitCommits(['Second'], {cwd: tmpRepo}); await gitPush('origin', 'master', {cwd: tmpRepo}); - await tag({gitTag: 'tag_name', gitHead: 'HEAD', version: '1.0.0'}, {cwd}); + await tag('tag_name', 'HEAD', {cwd}); await push(repositoryUrl, {cwd}); t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash); diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index ba367358..7240fe1d 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -195,7 +195,7 @@ export function gitTagHead(tagName, execaOpts) { * @return {String} The sha of the commit associated with `tagName` on the remote repository. */ export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { - return (await execa.stdout('git', ['ls-remote', repositoryUrl, `${tagName}^{}`], execaOpts)) + return (await execa.stdout('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts)) .split('\n') .filter(tag => Boolean(tag)) .map(tag => tag.match(/^(\S+)/)[1])[0];