Skip to content

Commit 8d64291

Browse files
committed
test changes and README updates for PR6
1 parent 1b65c8f commit 8d64291

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,15 @@ git.getLastCommit(function(err, commit) {
4343
// read commit object properties
4444
console.log(commit);
4545
}, {dst: 'some/other/path'});
46-
```
46+
```
47+
48+
Function uses comma as the format separator for the `git log` command output. You can customise this by providing another character using `splitChar` option:
49+
50+
```javascript
51+
var git = require('git-last-commit');
52+
53+
git.getLastCommit(function(err, commit) {
54+
// read commit object properties
55+
console.log(commit);
56+
}, {splitChar: '|'});
57+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "git-last-commit",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "Read details of the last commit including tags",
55
"main": "./source/index.js",
66
"scripts": {

source/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function _command(command, callback) {
1515
return;
1616
}
1717

18-
if (stderr) {
18+
if (stderr) {
1919
callback(stderr);
2020
return;
2121
}
@@ -26,9 +26,9 @@ function _command(command, callback) {
2626

2727
var prettyFormat = ["%h", "%H", "%s", "%f", "%b", "%at", "%ct", "%an", "%ae", "%cn", "%ce", "%N"];
2828

29-
var command =
30-
'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) +'"' +
31-
' && git rev-parse --abbrev-ref HEAD' +
29+
var command =
30+
'git log -1 --pretty=format:"' + prettyFormat.join(splitCharacter) +'"' +
31+
' && git rev-parse --abbrev-ref HEAD' +
3232
' && git tag --contains HEAD';
3333

3434
module.exports = {
@@ -44,7 +44,7 @@ module.exports = {
4444
callback(err);
4545
return;
4646
}
47-
47+
4848
var a = res.split(splitCharacter);
4949

5050
var tags = [];

test/integration.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ describe('feature: git-last-commit to return last commit info', function() {
1313
expect(commit.hash).to.have.length(40);
1414
expect(commit.subject).to.match(/.+/);
1515
expect(commit.sanitizedSubject).to.match(/.+/);
16-
expect(commit.body).to.be.empty;
16+
expect(commit.body).to.match(/.*/);
1717
expect(commit.authoredOn).to.match(/\d{10}/);
1818
expect(commit.committedOn).to.match(/\d{10}/);
1919
expect(commit.author.name).to.match(/.+/);
2020
expect(commit.author.email).to.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/);
2121
expect(commit.committer.name).to.match(/.+/);
2222
expect(commit.committer.email).to.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/);
23-
expect(commit.branch).to.match(/.+/);
23+
expect(commit.branch).to.match(/.*/);
2424
expect(commit.tags).to.be.instanceOf(Array);
2525

2626
done();
2727
});
2828
});
29-
});
29+
});

0 commit comments

Comments
 (0)