| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f0b29f5 commit aa88424
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1553,7 +1553,7 @@ | |||
| 1553 | 1553 | ], | |
| 1554 | 1554 | "functions": { | |
| 1555 | 1555 | "git_status_byindex": { | |
| 1556 | - "ignore": true | ||
| 1556 | + "isAsync": false | ||
| 1557 | 1557 | }, | |
| 1558 | 1558 | "git_status_foreach": { | |
| 1559 | 1559 | "isAsync": true, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -187,6 +187,25 @@ | |||
| 187 | 187 | ] | |
| 188 | 188 | } | |
| 189 | 189 | ], | |
| 190 | + [ | ||
| 191 | + "git_status_entry", | ||
| 192 | + { | ||
| 193 | + "fields": [ | ||
| 194 | + { | ||
| 195 | + "type": "git_status_t", | ||
| 196 | + "name": "status" | ||
| 197 | + }, | ||
| 198 | + { | ||
| 199 | + "type": "git_diff_delta *", | ||
| 200 | + "name": "head_to_index" | ||
| 201 | + }, | ||
| 202 | + { | ||
| 203 | + "type": "git_diff_delta *", | ||
| 204 | + "name": "index_to_workdir" | ||
| 205 | + } | ||
| 206 | + ] | ||
| 207 | + } | ||
| 208 | + ], | ||
| 190 | 209 | [ | |
| 191 | 210 | "git_diff_perfdata", | |
| 192 | 211 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,13 @@ | |||
| 1 | + var NodeGit = require("../"); | ||
| 2 | + var normalizeOptions = require("./util/normalize_options"); | ||
| 3 | + | ||
| 4 | + var StatusList = NodeGit.StatusList; | ||
| 5 | + | ||
| 6 | + // Override StatusList.create to normalize opts | ||
| 7 | + var create = StatusList.create; | ||
| 8 | + StatusList.create = function(repo, opts) { | ||
| 9 | + opts = normalizeOptions(opts, NodeGit.StatusOptions); | ||
| 10 | + return create(repo, opts); | ||
| 11 | + }; | ||
| 12 | + | ||
| 13 | + module.exports = StatusList; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,60 @@ | |||
| 1 | + var assert = require("assert"); | ||
| 2 | + var path = require("path"); | ||
| 3 | + var promisify = require("promisify-node"); | ||
| 4 | + var Promise = require("nodegit-promise"); | ||
| 5 | + var fse = promisify(require("fs-extra")); | ||
| 6 | + var local = path.join.bind(path, __dirname); | ||
| 7 | + var exec = promisify(function(command, opts, callback) { | ||
| 8 | + return require("child_process").exec(command, opts, callback); | ||
| 9 | + }); | ||
| 10 | + | ||
| 11 | + describe.only("StatusList", function() { | ||
| 12 | + var Status = require(local("../../lib/status")); | ||
| 13 | + var StatusList = require(local("../../lib/status_list")); | ||
| 14 | + var Repository = require(local("../../lib/repository")); | ||
| 15 | + | ||
| 16 | + var reposPath = local("../repos/workdir/.git"); | ||
| 17 | + | ||
| 18 | + before(function() { | ||
| 19 | + var test = this; | ||
| 20 | + return Repository.open(reposPath) | ||
| 21 | + .then(function(repository) { | ||
| 22 | + test.repository = repository; | ||
| 23 | + }); | ||
| 24 | + }); | ||
| 25 | + | ||
| 26 | + it("gets status with deltas", function() { | ||
| 27 | + var fileName = "my-new-file-that-shouldnt-exist.file"; | ||
| 28 | + var fileContent = "new file from status tests"; | ||
| 29 | + var repo = this.repository; | ||
| 30 | + var filePath = path.join(repo.workdir(), fileName); | ||
| 31 | + return exec("git clean -xdf", {cwd: local("../repos/workdir")}) | ||
| 32 | + .then(function() { | ||
| 33 | + return fse.writeFile(filePath, fileContent); | ||
| 34 | + }) | ||
| 35 | + .then(function() { | ||
| 36 | + var opts = { | ||
| 37 | + flags: Status.OPT.INCLUDE_UNTRACKED + | ||
| 38 | + Status.OPT.RECURSE_UNTRACKED_DIRS | ||
| 39 | + }; | ||
| 40 | + | ||
| 41 | + var list = StatusList.create(repo, opts); | ||
| 42 | + assert.equal(list.entrycount(), 1); | ||
| 43 | + | ||
| 44 | + for (var i = 0; i < list.entrycount(); i++) { | ||
| 45 | + var entry = Status.byIndex(list, i); | ||
| 46 | + assert.equal(entry.indexToWorkdir().newFile().path(), fileName); | ||
| 47 | + } | ||
| 48 | + }) | ||
| 49 | + .then(function() { | ||
| 50 | + return fse.remove(filePath); | ||
| 51 | + }) | ||
| 52 | + .catch(function(e) { | ||
| 53 | + return fse.remove(filePath) | ||
| 54 | + .then(function() { | ||
| 55 | + return Promise.reject(e); | ||
| 56 | + }); | ||
| 57 | + | ||
| 58 | + }); | ||
| 59 | + }); | ||
| 60 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments