git-last-commit
Advanced tools
Comparing version 0.3.0 to 1.0.0
{ | ||
"name": "git-last-commit", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "Read details of the last commit including tags", | ||
"main": "./source/index.js", | ||
"scripts": { | ||
"test": "gulp test" | ||
"test": "node_modules/.bin/mocha", | ||
"lint": "node_modules/.bin/eslint source/**", | ||
"coverage": "node_modules/.bin/nyc npm run test" | ||
}, | ||
@@ -26,10 +28,8 @@ "repository": { | ||
"devDependencies": { | ||
"chai": "^3.2.0", | ||
"gulp": "^3.9.0", | ||
"gulp-istanbul": "^0.10.0", | ||
"gulp-jshint": "^1.11.2", | ||
"gulp-mocha": "^2.1.3", | ||
"jshint-stylish": "^2.0.1", | ||
"sinon": "^1.15.4" | ||
"chai": "^4", | ||
"mocha": "^6", | ||
"eslint": "^6", | ||
"nyc": "^14.1.1", | ||
"sinon": "^7" | ||
} | ||
} |
@@ -47,12 +47,1 @@ # git-last-commit | ||
``` | ||
Function uses comma as the format separator for the `git log` command output. You can customise this by providing another character using `splitChar` option: | ||
```javascript | ||
var git = require('git-last-commit'); | ||
git.getLastCommit(function(err, commit) { | ||
// read commit object properties | ||
console.log(commit); | ||
}, {splitChar: '|'}); | ||
``` |
@@ -1,77 +0,74 @@ | ||
var process = require('child_process'), | ||
options = {}, | ||
splitCharacter = ','; | ||
const process = require('child_process'), | ||
splitCharacter = '<##>' | ||
function _command(command, callback) { | ||
var dst = __dirname; | ||
const executeCommand = (command, options, callback) => { | ||
let dst = __dirname | ||
if(!!options && options.dst) { | ||
dst = options.dst; | ||
} | ||
if(!!options && options.dst) { | ||
dst = options.dst | ||
} | ||
process.exec(command, {cwd: dst}, function(err, stdout, stderr) { | ||
if (stdout === '') { | ||
callback('this does not look like a git repo'); | ||
return; | ||
} | ||
process.exec(command, {cwd: dst}, function(err, stdout, stderr) { | ||
if (stdout === '') { | ||
callback('this does not look like a git repo') | ||
return | ||
} | ||
if (stderr) { | ||
callback(stderr); | ||
return; | ||
} | ||
if (stderr) { | ||
callback(stderr) | ||
return | ||
} | ||
callback(null, stdout.split('\n').join(splitCharacter)); | ||
}); | ||
callback(null, stdout) | ||
}) | ||
} | ||
var prettyFormat = ["%h", "%H", "%s", "%f", "%b", "%at", "%ct", "%an", "%ae", "%cn", "%ce", "%N"]; | ||
const prettyFormat = ["%h", "%H", "%s", "%f", "%b", "%at", "%ct", "%an", "%ae", "%cn", "%ce", "%N", ""] | ||
var command = | ||
'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) +'"' + | ||
' && git rev-parse --abbrev-ref HEAD' + | ||
' && git tag --contains HEAD'; | ||
const getCommandString = splitCharacter => | ||
'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) +'"' + | ||
' && git rev-parse --abbrev-ref HEAD' + | ||
' && git tag --contains HEAD' | ||
module.exports = { | ||
getLastCommit : function(callback, _options) { | ||
options = _options; | ||
const getLastCommit = (callback, options) => { | ||
const command = getCommandString(splitCharacter) | ||
if (!!options && options.splitChar) { | ||
splitCharacter = options.splitChar; | ||
executeCommand(command, options, function(err, res) { | ||
if (err) { | ||
callback(err) | ||
return | ||
} | ||
_command(command, function(err, res) { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
var a = res.split(splitCharacter) | ||
var a = res.split(splitCharacter); | ||
// e.g. master\n or master\nv1.1\n or master\nv1.1\nv1.2\n | ||
var branchAndTags = a[a.length-1].split('\n').filter(n => n) | ||
var branch = branchAndTags[0] | ||
var tags = branchAndTags.slice(1) | ||
var tags = []; | ||
if (a[a.length-1] !== '') { | ||
tags = a.slice(13 - a.length); | ||
} | ||
callback(null, { | ||
shortHash: a[0], | ||
hash: a[1], | ||
subject: a[2], | ||
sanitizedSubject: a[3], | ||
body: a[4], | ||
authoredOn: a[5], | ||
committedOn: a[6], | ||
author: { | ||
name: a[7], | ||
email: a[8], | ||
}, | ||
committer: { | ||
name: a[9], | ||
email: a[10] | ||
}, | ||
notes: a[11], | ||
branch, | ||
tags | ||
}) | ||
}) | ||
} | ||
callback(null, { | ||
shortHash: a[0], | ||
hash: a[1], | ||
subject: a[2], | ||
sanitizedSubject: a[3], | ||
body: a[4], | ||
authoredOn: a[5], | ||
committedOn: a[6], | ||
author: { | ||
name: a[7], | ||
email: a[8], | ||
}, | ||
committer: { | ||
name: a[9], | ||
email: a[10] | ||
}, | ||
notes: a[11], | ||
branch: a[12], | ||
tags: tags | ||
}); | ||
}); | ||
} | ||
}; | ||
module.exports = { | ||
getLastCommit | ||
} |
386
test/unit.js
@@ -10,196 +10,248 @@ /*jshint expr: true*/ | ||
describe('feature: git-last-commit to return last commit info', function() { | ||
beforeEach(function() { | ||
processExecMethod = sinon.stub(process, 'exec'); | ||
}); | ||
let processExecMethod; | ||
afterEach(function() { | ||
processExecMethod.restore(); | ||
}); | ||
beforeEach(function() { | ||
processExecMethod = sinon.stub(process, 'exec'); | ||
}); | ||
it('should parse git commands fully', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,this is the body,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,note 1\nmaster\nR2\nR1'); | ||
afterEach(function() { | ||
processExecMethod.restore(); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('initial commit'); | ||
expect(commit.sanitizedSubject).to.be.equal('initial-commit'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R2', 'R1']); | ||
it('should parse git output fully', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##>this is the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject line'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject line'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R2', 'R1']); | ||
it('should parse git commands when commit has no notes', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,this is the body,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,\nmaster\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('initial commit'); | ||
expect(commit.sanitizedSubject).to.be.equal('initial-commit'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.empty; | ||
expect(commit.tags).to.have.members(['R2', 'R1']); | ||
it('should parse git output when commit has no notes', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##>this is the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##><##>master\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject line'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject line'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.empty; | ||
expect(commit.tags).to.have.members(['R2', 'R1']); | ||
it('should parse git commands when commit has no body', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,note 1\nmaster\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('initial commit'); | ||
expect(commit.sanitizedSubject).to.be.equal('initial-commit'); | ||
expect(commit.body).to.be.empty; | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R2', 'R1']); | ||
it('should parse git output when commit has no body', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##><##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject line'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject line'); | ||
expect(commit.body).to.be.empty; | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R2', 'R1']); | ||
it('should parse git commands when commit has no tags', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,this is the body,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,note 1\nmaster\n'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('initial commit'); | ||
expect(commit.sanitizedSubject).to.be.equal('initial-commit'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.be.empty; | ||
it('should parse git output when commit has no tags', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##>this is the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\n'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject line'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject line'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.be.empty; | ||
it('should parse git commands fully when commit has single tag', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,this is the body,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,note 1\nmaster\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('initial commit'); | ||
expect(commit.sanitizedSubject).to.be.equal('initial-commit'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R1']); | ||
it('should parse git output when commit body has newline', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject<##>sanitized subject<##>this is\nthe body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\n'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject'); | ||
expect(commit.body).to.be.equal('this is\nthe body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.be.empty; | ||
it('should parse git commands when a custom split character is specified', function(done) { | ||
processExecMethod.yields(null, '26e689d¬26e689d8769908329a145201be5081233c711663¬initial commit¬initial-commit¬this is the body¬1437984178¬1437984179¬Author1¬author@gmail.com¬Committer1¬committer@gmail.com¬note 1\nmaster\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('initial commit'); | ||
expect(commit.sanitizedSubject).to.be.equal('initial-commit'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R1']); | ||
it('should parse git output when commit body has comma', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject<##>sanitized subject<##>this is, the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\n'); | ||
done(); | ||
}, { splitChar: '¬' }); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject'); | ||
expect(commit.body).to.be.equal('this is, the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.be.empty; | ||
it('should run the git command on given destination', function(done) { | ||
processExecMethod.yields(null, '26e689d,26e689d8769908329a145201be5081233c711663,initial commit,initial-commit,this is the body,1437984178,1437984179,Author1,author@gmail.com,Committer1,committer@gmail.com,note 1\nmaster\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(processExecMethod.args[0][1].cwd).to.be.ok; | ||
expect(processExecMethod.args[0][1].cwd).to.be.equal('path/path/whatever'); | ||
it('should parse git output fully when commit has single tag', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##>this is the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\nR1'); | ||
done(); | ||
}, {dst: 'path/path/whatever'}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject line'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject line'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R1']); | ||
it('should handle error properly if this is not a git repo', function(done) { | ||
processExecMethod.yields(null, ''); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.not.null; | ||
expect(commit).to.be.undefined; | ||
expect(err).to.be.equal('this does not look like a git repo'); | ||
it('should parse git output fully when commit has multiple tags', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##>this is the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\nR1\nR2'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(commit.shortHash).to.be.equal('26e689d'); | ||
expect(commit.hash).to.be.equal('26e689d8769908329a145201be5081233c711663'); | ||
expect(commit.subject).to.be.equal('subject line'); | ||
expect(commit.sanitizedSubject).to.be.equal('sanitized subject line'); | ||
expect(commit.body).to.be.equal('this is the body'); | ||
expect(commit.authoredOn).to.be.equal('1437984178'); | ||
expect(commit.committedOn).to.be.equal('1437984179'); | ||
expect(commit.author.name).to.be.equal('Author1'); | ||
expect(commit.author.email).to.be.equal('author@gmail.com'); | ||
expect(commit.committer.name).to.be.equal('Committer1'); | ||
expect(commit.committer.email).to.be.equal('committer@gmail.com'); | ||
expect(commit.branch).to.be.equal('master'); | ||
expect(commit.notes).to.be.equal('note 1'); | ||
expect(commit.tags).to.have.members(['R1', 'R2']); | ||
it('should handle stderr coming from git commands', function(done) { | ||
processExecMethod.yields(null, null, 'command not found git'); | ||
done(); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.not.null; | ||
expect(commit).to.be.undefined; | ||
expect(err).to.be.equal('command not found git'); | ||
it('should run the git command on given destination', function(done) { | ||
processExecMethod.yields(null, '26e689d<##>26e689d8769908329a145201be5081233c711663<##>subject line<##>sanitized subject line<##>this is the body<##>1437984178<##>1437984179<##>Author1<##>author@gmail.com<##>Committer1<##>committer@gmail.com<##>note 1<##>master\nR2\nR1'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.null; | ||
expect(commit).to.be.ok; | ||
expect(processExecMethod.args[0][1].cwd).to.be.ok; | ||
expect(processExecMethod.args[0][1].cwd).to.be.equal('path/path/whatever'); | ||
done(); | ||
}, {dst: 'path/path/whatever'}); | ||
}); | ||
it('should handle error properly if this is not a git repo', function(done) { | ||
processExecMethod.yields(null, ''); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.not.null; | ||
expect(commit).to.be.undefined; | ||
expect(err).to.be.equal('this does not look like a git repo'); | ||
done(); | ||
}); | ||
}); | ||
it('should handle stderr coming from git output', function(done) { | ||
processExecMethod.yields(null, null, 'command not found git'); | ||
git.getLastCommit(function(err, commit) { | ||
expect(err).to.be.not.null; | ||
expect(commit).to.be.undefined; | ||
expect(err).to.be.equal('command not found git'); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
19398
5
10
350
0
47