|
| 1 | +var assert = require("assert"); |
| 2 | +var path = require("path"); |
| 3 | + |
| 4 | +describe("Revwalk", function() { |
| 5 | + var reposPath = path.resolve("test/repos/workdir/.git"); |
| 6 | + |
| 7 | + var Repository = require("../../lib/repository"); |
| 8 | + var Revwalk = require("../../lib/revwalk"); |
| 9 | + var Oid = require("../../lib/oid"); |
| 10 | + |
| 11 | + before(function() { |
| 12 | + var test = this; |
| 13 | + |
| 14 | + return Repository.open(reposPath).then(function(repository) { |
| 15 | + test.repository = repository; |
| 16 | + test.walker = repository.createRevWalk(); |
| 17 | + |
| 18 | + return test.repository.getMaster().then(function(master) { |
| 19 | + test.master = master; |
| 20 | + test.walker.push(test.master.id()); |
| 21 | + }); |
| 22 | + }); |
| 23 | + }); |
| 24 | + |
| 25 | + it("can create a walker", function() { |
| 26 | + assert.ok(this.walker instanceof Revwalk); |
| 27 | + }); |
| 28 | + |
| 29 | + it("can push an object", function() { |
| 30 | + var sha = this.master.sha(); |
| 31 | + |
| 32 | + return this.walker.next().then(function(commit) { |
| 33 | + assert.equal(sha, commit); |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + it("can hide an object", function() { |
| 38 | + var test = this; |
| 39 | + |
| 40 | + this.walker.hide(Oid.fromstr("a03e044fcb45c654d4e15a4e495a6a0c6e632854")); |
| 41 | + |
| 42 | + return test.walker.next().then(function(commit) { |
| 43 | + return test.walker.next().then(function(commit) { |
| 44 | + assert.equal(commit, "1efa3354299ede235f90880383176fb5d48aaa89"); |
| 45 | + }); |
| 46 | + }); |
| 47 | + }); |
| 48 | + |
| 49 | + it("can simplify to first parent", function() { |
| 50 | + var test = this; |
| 51 | + |
| 52 | + test.walker.simplifyFirstParent(); |
| 53 | + |
| 54 | + return test.walker.next().then(function(commit) { |
| 55 | + return test.walker.next().then(function(commit) { |
| 56 | + assert.equal(commit, "231c550f3ec28874b4c426fc9eebad9a742e1332"); |
| 57 | + }); |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
0 commit comments