Skip to content

Commit 9e12009

Browse files
gregorybessonrvagg
authored andcommitted
adding authorDate and commitDate to the object stream (#2)
1 parent 2c044b3 commit 9e12009

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Commit object properties:
3737
* `author`: an object representing the author of the commit
3838
- `name`: the name of the committer
3939
- `email`: the email of the committer
40+
* `authorDate`: a string representing the date of the original commit by the author (never change)
41+
* `commitDate`: a string representing the date of the last change of the commit
4042
* `summary`: the one-line summary of the commit
4143
* `description`: the free-form text content of the summary, minus specific metadata lines
4244
* `reviewers`: an array containing objects with `name` and `email` properties if the commit metadata contains reviewers in a `Reviewed-By: Foo Bar <baz@boom>` format.

commit-stream.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,22 @@ function commitStream (ghUser, ghProject) {
2323
commit = {
2424
sha: line.split(' ')[1]
2525
}
26+
} else if (m = line.match(/^CommitDate: (.*)$/)) {
27+
if (!commit)
28+
throw new Error('wut?')
29+
commit.commitDate = m[1].trim()
2630
} else if (m = line.match(/^Author: ([^<]+) <([^>]+)>$/)) {
2731
if (!commit)
2832
throw new Error('wut?')
2933
commit.author = { name: m[1], email: m[2] }
34+
} else if (m = line.match(/^AuthorDate: (.*)$/)) {
35+
if (!commit)
36+
throw new Error('wut?')
37+
commit.authorDate = m[1].trim()
38+
} else if (m = line.match(/^Date: (.*)$/)) {
39+
if (!commit)
40+
throw new Error('wut?')
41+
commit.authorDate = m[1].trim()
3042
} else if (m = line.match(/^\s+Reviewed[- ]?By:?\s*([^<]+) <([^>]+)>\s*$/i)) {
3143
if (!commit.reviewers)
3244
commit.reviewers = []

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ test('current plain commit log', function (t) {
2020

2121
t.deepEqual(list[list.length - 9], {
2222
author : { email: 'ralphtheninja@riseup.net', name: 'Lars-Magnus Skog' }
23+
, authorDate : 'Tue Feb 9 15:46:46 2016 +0100'
2324
, description : [
2425
'Fixes: https://github.com/rvagg/changelog-maker/issues/35'
2526
]
@@ -34,19 +35,22 @@ test('current plain commit log', function (t) {
3435

3536
t.deepEqual(list[list.length - 4], {
3637
author: { email: 'rod@vagg.org', name: 'Rod Vagg' }
38+
, authorDate: 'Fri Apr 17 11:16:51 2015 +1000'
3739
, sha: 'f92b93c3c7175b07f847dd45058b121cea6b3a20'
3840
, summary: 'deleted package.json line'
3941
}, 'got correct fourth commit')
4042

4143
t.deepEqual(list[list.length - 3], {
4244
author: { email: 'rod@vagg.org', name: 'Rod Vagg' }
45+
, authorDate: 'Fri Apr 17 11:13:06 2015 +1000'
4346
, description: [ 'comment', 'Reviewed-By: Nobody' ]
4447
, sha: 'db34ce2af09a6a9fb70241d43965a2bc48b90b4c'
4548
, summary: 'squished package.json'
4649
}, 'got correct third commit')
4750

4851
t.deepEqual(list[list.length - 2], {
4952
author : { email: 'rod@vagg.org', name: 'Rod Vagg' }
53+
, authorDate: 'Fri Apr 17 10:52:16 2015 +1000'
5054
, description : [
5155
'Some extra summary information here'
5256
, 'newline'
@@ -63,6 +67,7 @@ test('current plain commit log', function (t) {
6367

6468
t.deepEqual(list[list.length - 1], {
6569
sha : 'd94841274e2979e7758413a0f48fa37560d0dde6'
70+
, authorDate: 'Thu Apr 16 20:49:21 2015 +1000'
6671
, author : { name: 'Rod Vagg', email: 'rod@vagg.org' }
6772
, summary: 'make it so'
6873
}, 'got correct first commit')

0 commit comments

Comments
 (0)