Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

semantic-release

Package Overview
Dependencies
Maintainers
3
Versions
411
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semantic-release - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

52

dist/lib/commits.js

@@ -7,21 +7,53 @@ 'use strict';

var log = require('npmlog');
var SemanticReleaseError = require('@semantic-release/error');
module.exports = function (_ref, cb) {
var lastRelease = _ref.lastRelease;
var options = _ref.options;
var branch = options.branch;
var from = lastRelease.gitHead;
var range = (from ? from + '..' : '') + 'HEAD';
exec('git log -E --format=%H==SPLIT==%B==END== ' + range, function (err, stdout) {
if (!from) return extract();
exec('git branch --contains ' + from, function (err, stdout) {
if (err) return cb(err);
var inHistory = false;
cb(null, String(stdout).split('==END==\n').filter(function (raw) {
return !!raw.trim();
}).map(function (raw) {
var data = raw.split('==SPLIT==');
return {
hash: data[0],
message: data[1]
};
}));
var branches = stdout.split('\n').map(function (result) {
if (branch === result.replace('*', '').trim()) {
inHistory = true;
return null;
}
return result.trim();
}).filter(function (branch) {
return !!branch;
});
if (!inHistory) {
log.error('commits', 'The commit the last release of this package was derived from is no longer\nin the direct history of the "' + branch + '" branch.\nThis means semantic-release can not extract the commits between now and then.\nThis is usually caused by force pushing or releasing from an unrelated branch.\nYou can recover from this error by publishing manually or restoring\nthe commit "' + from + '".' + (branches.length ? '\nHere is a list of branches that still contain the commit in question: \n * ' + branches.join('\n * ') : ''));
return cb(new SemanticReleaseError('Commit not in history', 'ENOTINHISTORY'));
}
extract();
});
function extract() {
exec('git log -E --format=%H==SPLIT==%B==END== ' + range, function (err, stdout) {
if (err) return cb(err);
cb(null, String(stdout).split('==END==\n').filter(function (raw) {
return !!raw.trim();
}).map(function (raw) {
var data = raw.split('==SPLIT==');
return {
hash: data[0],
message: data[1]
};
}));
});
}
};

2

package.json

@@ -93,3 +93,3 @@ {

},
"version": "4.2.0"
"version": "4.2.1"
}

@@ -8,2 +8,6 @@ const rawCommits = [

exec: (command, cb) => {
if (/contains/.test(command)) {
return cb(null, `whatever\nmaster\n`)
}
cb(

@@ -10,0 +14,0 @@ null,

@@ -10,3 +10,3 @@ const test = require('tap').test

t.test('get all commits', (tt) => {
commits({lastRelease: {}}, (err, commits) => {
commits({lastRelease: {}, options: {branch: 'master'}}, (err, commits) => {
tt.error(err)

@@ -22,3 +22,3 @@ tt.is(commits.length, 2, 'all commits')

t.test('get commits since hash', (tt) => {
commits({lastRelease: {gitHead: 'hash'}}, (err, commits) => {
commits({lastRelease: {gitHead: 'hash'}, options: {branch: 'master'}}, (err, commits) => {
tt.error(err)

@@ -33,3 +33,11 @@ tt.is(commits.length, 1, 'specified commits')

t.test('get commits since hash', (tt) => {
commits({lastRelease: {gitHead: 'notinhistory'}, options: {branch: 'notmaster'}}, (err, commits) => {
tt.ok(err)
tt.is(err.code, 'ENOTINHISTORY')
tt.end()
})
})
t.end()
})

@@ -6,3 +6,5 @@ const test = require('tap').test

const pre = proxyquire('../../dist/pre', {
'child_process': require('../mocks/child-process')
'./lib/commits': proxyquire('../../dist/lib/commits', {
'child_process': require('../mocks/child-process')
})
})

@@ -18,3 +20,3 @@

getLastRelease: ({ pkg }, cb) => {
cb(null, { version: versions[pkg.name] || null, gitHead: 'HEAD' })
cb(null, {version: versions[pkg.name] || null, gitHead: 'HEAD'})
}

@@ -26,3 +28,2 @@ }

tag: 'latest'
}

@@ -35,2 +36,3 @@

pre({
options: {branch: 'master'},
npm,

@@ -50,2 +52,3 @@ pkg: {name: 'available'},

pre({
options: {branch: 'master'},
npm,

@@ -52,0 +55,0 @@ pkg: {name: 'unavailable'},

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc