MCPcopy Index your code
hub / github.com/nodegit/nodegit / compareFilemodes

Function compareFilemodes

test/tests/stage.js:241–274  ·  view source on GitHub ↗
(vsWorkdir, index, fileModeDifference)

Source from the content-addressed store, hash-verified

239 });
240
241 function compareFilemodes(vsWorkdir, index, fileModeDifference) {
242 //Takes diff of head commit vs Workdir (if vsWorkdir is set) or vs Index
243 //(if vsWorkdir is unset). Note: there's only one file in the filemode
244 //staging tests for which this helper fn was written.
245 //index - index to use (vsWorkdir is unset)
246 //fileModeDifference - expected (newfilemode) - (oldfilemode)
247 return test.repository.getHeadCommit()
248 .then(function(commit) {
249 return commit.getTree();
250 })
251 .then(function(tree) {
252 if (vsWorkdir) {
253 return NodeGit.Diff.treeToWorkdir(test.repository, tree);
254 } else {
255 return NodeGit.Diff.treeToIndex(test.repository, tree, index);
256 }
257 })
258 .then(function(diff) {
259 return diff.getDelta(0);
260 })
261 .then(function(delta) {
262 if (fileModeDifference === 0) {
263 if (!delta) {
264 return true;
265 } else {
266 throw ("File change when no file change expected.");
267 }
268 } else {
269 assert(delta.newFile().mode() - delta.oldFile().mode() ===
270 fileModeDifference);
271 }
272 return true;
273 });
274 }
275
276 function createAndCommitFiles(repo, filePaths, fileContent, afterWriteFn) {
277 filePaths = filePaths instanceof Array ? filePaths : [filePaths];

Callers 1

stage.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…