| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f9e6ae6 commit 876aafa
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,10 +6,8 @@ var fse = promisify(require("fs-extra")); | |||
| 6 | 6 | var local = path.join.bind(path, __dirname); | |
| 7 | 7 | ||
| 8 | 8 | describe("Diff", function() { | |
| 9 | - var NodeGit = require("../../"); | ||
| 10 | 9 | var Repository = require(local("../../lib/repository")); | |
| 11 | 10 | var Diff = require(local("../../lib/diff")); | |
| 12 | - var normalizeOptions = require(local("../../lib/util/normalize_options")); | ||
| 13 | 11 | ||
| 14 | 12 | var reposPath = local("../repos/workdir/.git"); | |
| 15 | 13 | var oid = "fce88902e66c72b5b93e75bdb5ae717038b221f6"; | |
@@ -22,7 +20,12 @@ describe("Diff", function() { | |||
| 22 | 20 | return Repository.open(reposPath).then(function(repository) { | |
| 23 | 21 | test.repository = repository; | |
| 24 | 22 | ||
| 25 | - return repository.getBranchCommit("master"); | ||
| 23 | + return repository.openIndex(); | ||
| 24 | + }) | ||
| 25 | + .then(function(index) { | ||
| 26 | + test.index = index; | ||
| 27 | + | ||
| 28 | + return test.repository.getBranchCommit("master"); | ||
| 26 | 29 | }) | |
| 27 | 30 | .then(function(masterCommit) { | |
| 28 | 31 | return masterCommit.getTree(); | |
@@ -46,14 +49,20 @@ describe("Diff", function() { | |||
| 46 | 49 | return Diff.treeToWorkdirWithIndex( | |
| 47 | 50 | test.repository, | |
| 48 | 51 | test.masterCommitTree, | |
| 49 | - normalizeOptions({ | ||
| 50 | - flags: Diff.OPTION.INCLUDE_UNTRACKED | ||
| 51 | - }, NodeGit.DiffOptions) | ||
| 52 | + { flags: Diff.OPTION.INCLUDE_UNTRACKED } | ||
| 52 | 53 | ); | |
| 53 | 54 | }) | |
| 54 | 55 | .then(function(workdirDiff) { | |
| 55 | 56 | test.workdirDiff = workdirDiff; | |
| 56 | 57 | }) | |
| 58 | + .then(function() { | ||
| 59 | + var opts = { flags: Diff.OPTION.INCLUDE_UNTRACKED }; | ||
| 60 | + | ||
| 61 | + return Diff.indexToWorkdir(test.repository, test.index, opts); | ||
| 62 | + }) | ||
| 63 | + .then(function(diff) { | ||
| 64 | + test.indexToWorkdirDiff = diff; | ||
| 65 | + }) | ||
| 57 | 66 | .then(function() { | |
| 58 | 67 | return fse.remove(diffFilepath); | |
| 59 | 68 | }) | |
@@ -129,4 +138,19 @@ describe("Diff", function() { | |||
| 129 | 138 | assert.equal(diffs[0].patches().length, 8); | |
| 130 | 139 | }); | |
| 131 | 140 | }); | |
| 141 | + | ||
| 142 | + it("can diff tree to index", function() { | ||
| 143 | + var repo = this.repository; | ||
| 144 | + var tree = this.masterCommitTree; | ||
| 145 | + var index = this.index; | ||
| 146 | + var opts = { flags: Diff.OPTION.INCLUDE_UNTRACKED }; | ||
| 147 | + | ||
| 148 | + return Diff.treeToIndex(repo, tree, index, opts).then(function(diff) { | ||
| 149 | + assert.equal(diff.patches().length, 0); | ||
| 150 | + }); | ||
| 151 | + }); | ||
| 152 | + | ||
| 153 | + it("can diff index to workdir", function() { | ||
| 154 | + assert.equal(this.indexToWorkdirDiff.patches().length, 1); | ||
| 155 | + }); | ||
| 132 | 156 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments