|
| 1 | +var assert = require("assert"); |
| 2 | +var rimraf = require("rimraf"); |
| 3 | +var path = require("path"); |
| 4 | +var fs = require( "fs" ); |
| 5 | + |
| 6 | +var nodegit = require("../../"); |
| 7 | +var Repository = nodegit.Repository; |
| 8 | + |
| 9 | +describe("Commit", function() { |
| 10 | + var historyCountKnownSHA = "fce88902e66c72b5b93e75bdb5ae717038b221f6"; |
| 11 | + var reposPath = path.resolve("test/repos/workdir/.git"); |
| 12 | + |
| 13 | + var Commit = require("./commit"); |
| 14 | + |
| 15 | + describe("when fetched", function() { |
| 16 | + |
| 17 | + it("makes its message available", function(done) { |
| 18 | + Repository.open(reposPath, function(error, repository) { |
| 19 | + repository.getCommit(historyCountKnownSHA, function(error, commit) { |
| 20 | + var message = commit.message(); |
| 21 | + |
| 22 | + assert.equal(error, null); |
| 23 | + assert.equal(message, "Update README.md"); |
| 24 | + |
| 25 | + done(); |
| 26 | + }); |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + it("makes its sha available", function(done) { |
| 31 | + Repository.open(reposPath, function(error, repository) { |
| 32 | + repository.getCommit(historyCountKnownSHA, function(error, commit) { |
| 33 | + var sha = commit.sha(); |
| 34 | + |
| 35 | + assert.equal(error, null); |
| 36 | + assert.equal(sha, historyCountKnownSHA); |
| 37 | + |
| 38 | + done(); |
| 39 | + }); |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + it("makes its time available", function(done) { |
| 44 | + Repository.open(reposPath, function(error, repository) { |
| 45 | + repository.getCommit(historyCountKnownSHA, function(error, commit) { |
| 46 | + var time = commit.timeMs(); |
| 47 | + |
| 48 | + assert.equal(error, null); |
| 49 | + assert.equal(time, 1362012884000); |
| 50 | + |
| 51 | + done(); |
| 52 | + }); |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | + it("makes its date available", function(done) { |
| 57 | + Repository.open(reposPath, function(error, repository) { |
| 58 | + repository.getCommit(historyCountKnownSHA, function(error, commit) { |
| 59 | + var date = commit.date(); |
| 60 | + |
| 61 | + assert.equal(error, null); |
| 62 | + assert.equal(date.getTime(), 1362012884000); |
| 63 | + |
| 64 | + done(); |
| 65 | + }); |
| 66 | + }); |
| 67 | + }); |
| 68 | + |
| 69 | + it("makes its offset available", function(done) { |
| 70 | + Repository.open(reposPath, function(error, repository) { |
| 71 | + repository.getCommit(historyCountKnownSHA, function(error, commit) { |
| 72 | + var offset = commit.offset(); |
| 73 | + |
| 74 | + assert.equal(error, null); |
| 75 | + assert.equal(offset, 780); |
| 76 | + |
| 77 | + done(); |
| 78 | + }); |
| 79 | + }); |
| 80 | + }); |
| 81 | + |
| 82 | + }); |
| 83 | +}); |
0 commit comments