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

Function stagingTest

test/tests/stage.js:27–168  ·  view source on GitHub ↗
(isUnstaged, newFileContent, discarding)

Source from the content-addressed store, hash-verified

25 });
26
27 function stagingTest(isUnstaged, newFileContent, discarding) {
28 var fileContent = newFileContent ||
29 "One line of text\n" +
30 "Two lines of text\n"+
31 "Three lines of text\n"+
32 "Four lines of text\n"+
33 "Five lines of text\n"+
34 "Six lines of text\n"+
35 "Seven lines of text\n"+
36 "Eight lines of text\n"+
37 "Nine lines of text\n"+
38 "Ten lines of text\n"+
39 "Eleven lines of text\n"+
40 "Twelve lines of text\n"+
41 "Thirteen lines of text\n"+
42 "Fourteen lines of text\n"+
43 "Fifteen lines of text\n"+
44 "Sixteen lines of text\n"+
45 "Seventeen lines of text\n"+
46 "Eighteen lines of text\n"+
47 "Nineteen lines of text\n"+
48 "Twenty lines of text\n";
49 var fileName = "stagedLinesTest.txt";
50 var expectedContent;
51 var workingDirFile;
52 var getDiffFunction;
53
54 if (!isUnstaged || discarding) {
55 expectedContent = fileContent.replace("Three", "Changed three")
56 .replace("Seventeen", "Changed seventeen");
57 workingDirFile = expectedContent.replace("Fifteen", "Changed fifteen");
58 }
59 else {
60 expectedContent = fileContent.replace("Fifteen", "Changed fifteen");
61 workingDirFile = expectedContent.replace("Three", "Changed three")
62 .replace("Seventeen", "Changed seventeen");
63 }
64
65 if (isUnstaged) {
66 getDiffFunction = function() {
67 return test.repository.refreshIndex()
68 .then(function(index) {
69 return NodeGit.Diff.indexToWorkdir(
70 test.repository,
71 index,
72 {
73 flags:
74 NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT |
75 NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS
76 }
77 );
78 });
79 };
80 }
81 else {
82 getDiffFunction = function() {
83 return RepoUtils.addFileToIndex(test.repository, fileName)
84 .then(function() {

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…