FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added tests for Commit · nodegit/nodegit@f883e1d · GitHub

Repository navigation

Commit f883e1d

Browse files
committed
Added tests for Commit
lookupPrefix nthGenAncestor Signed-off-by: Remy Suen <remy.suen@gmail.com>
1 parent 86939c1 commit f883e1d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎test/tests/commit.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ var exec = require("../../utils/execPromise");
1313
describe("Commit", function() {
1414
var NodeGit = require("../../");
1515
var Repository = NodeGit.Repository;
16+
var Commit = NodeGit.Commit;
1617
var Diff = NodeGit.Diff;
18+
var Oid = NodeGit.Oid;
1719

1820
var reposPath = local("../repos/workdir");
1921
var oid = "fce88902e66c72b5b93e75bdb5ae717038b221f6";
@@ -604,6 +606,31 @@ describe("Commit", function() {
604606
});
605607
});
606608

609+
it("can lookup using a short id", function () {
610+
return NodeGit.Repository.open(reposPath)
611+
.then(function (repo) {
612+
return Commit.lookupPrefix(repo, Oid.fromString("bf1da765"), 8);
613+
})
614+
.then(function (commit) {
615+
assert.equal(commit.id().toString(),
616+
"bf1da765e357a9b936d6d511f2c7b78e0de53632");
617+
});
618+
});
619+
620+
it("can find nth gen ancestor", function () {
621+
return NodeGit.Repository.open(reposPath)
622+
.then(function (repo) {
623+
return repo.getCommit("b52067acaa755c3b3fc21b484ffed2bce4150f62");
624+
})
625+
.then(function (commit) {
626+
return commit.nthGenAncestor(3);
627+
})
628+
.then(function (commit) {
629+
assert.equal(commit.id().toString(),
630+
"9b2f3a37d46d47248d2704b6a46ec7e197bcd48c");
631+
});
632+
});
633+
607634
describe("Commit's Author", function() {
608635
before(function() {
609636
this.author = this.commit.author();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL