Skip to content

Commit 275d7cf

Browse files
Fix broken spec/commands/ log test
1 parent 8af63d6 commit 275d7cf

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

lib/git/objects.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ var Objects = {
130130
}
131131

132132
var parseAuthor = function(line) {
133-
var match = /^(.*) <(.*)> (\d+) [\+\-]\d\d\d\d$/.exec(line)
133+
var match = /^(.*) <(.*)> (\d+) ([\+\-]\d\d\d\d)$/.exec(line)
134134
var result = {}
135135
result.name = match[1]
136136
result.email = match[2]
137137
result.timestamp = parseInt(match[3])
138+
result.offset = (1000*60* parseInt(match[4].slice(-2), 10) +
139+
1000*60*60* parseInt(match[4].slice(-4, 3), 10)) *
140+
match[4].charAt(0) === '+' ? 1 : -1
141+
result.stroffset = match[4]
142+
138143
result.date = new Date(result.timestamp*1000)
139144
return result
140145
}
@@ -153,7 +158,7 @@ var Objects = {
153158
this.toString = function() {
154159
var str = "commit " + sha + "\n"
155160
str += "Author: " + this.author.name + " <" + this.author.email + ">\n"
156-
str += "Date: " + this.author.date +"\n"
161+
str += "Date: " + (new Date(+this.author.date + this.author.offset)).toUTCString().slice(0, -4) + ' ' + this.author.stroffset +"\n"
157162
str += "\n"
158163
str += this.message
159164
return str

spec/commands/log-command-spec.js

+20-7
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,51 @@ describe("git log", function() {
2525
packedRepo = new Repo(path.join(__dirname, "../../test/fixtures/test-repo1-packed/.git"))
2626
})
2727

28-
var expectLogOutput =
28+
var expectPackedLogOutput =
2929
"commit 9f00c2ee854534a785ff01115a94a50c9961610d\n" +
3030
"Author: Daniel Lucraft <[email protected]>\n" +
31-
"Date: Mon Jan 03 2011 07:22:59 GMT+0000 (GMT)\n" +
31+
"Date: Mon, 03 Jan 2011 07:22:59 +0000\n" +
3232
"\n" +
3333
"Modifiying master\n" +
3434
"\n" +
3535
"commit d0a9e5b650718445b53cd1cab40d21fb3891c98a\n" +
3636
"Author: Daniel Lucraft <[email protected]>\n" +
37-
"Date: Mon Jan 03 2011 07:14:11 GMT+0000 (GMT)\n" +
37+
"Date: Mon, 03 Jan 2011 07:14:11 +0000\n" +
3838
"\n" +
3939
"Modify README\n" +
4040
"\n" +
4141
"commit b3453be87b70a0c5dea28aacd49cf34ddb91a8c5\n" +
4242
"Author: Daniel Lucraft <[email protected]>\n" +
43-
"Date: Mon Dec 27 2010 12:59:13 GMT+0000 (GMT)\n" +
43+
"Date: Mon, 27 Dec 2010 12:59:13 +0000\n" +
4444
"\n" +
4545
"Add sample files"
46-
46+
47+
var expectLooseLogOutput =
48+
'commit 8e8b973cde2e6470626dedfc5d82716d1450dcda\n'+
49+
'Author: Daniel Lucraft <[email protected]>\n'+
50+
'Date: Mon, 03 Jan 2011 07:08:07 +0000\n'+
51+
'\n'+
52+
'Thoroughly modified the README\n'+
53+
'\n'+
54+
'commit b3453be87b70a0c5dea28aacd49cf34ddb91a8c5\n'+
55+
'Author: Daniel Lucraft <[email protected]>\n'+
56+
'Date: Mon, 27 Dec 2010 12:59:12 +0000\n'+
57+
'\n'+
58+
'Add sample files'
59+
4760
it("should show a list of branches, with the current highlighted (loose)", function() {
4861
var cmd = new LogCommand(looseRepo, [])
4962

5063
expectOutput(cmd, function(output) {
51-
expect(output).toEqual(expectLogOutput)
64+
expect(output).toEqual(expectLooseLogOutput)
5265
})
5366
})
5467

5568
it("should show a list of branches, with the current highlighted (packed)", function() {
5669
var cmd = new LogCommand(packedRepo, [])
5770

5871
expectOutput(cmd, function(output) {
59-
expect(output).toEqual(expectLogOutput)
72+
expect(output).toEqual(expectPackedLogOutput)
6073
})
6174
})
6275
})

0 commit comments

Comments
 (0)