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

Function lastHunkStagedPromise

lib/repository.js:1889–1919  ·  view source on GitHub ↗
(result)

Source from the content-addressed store, hash-verified

1887 // stage the entire file so the file doesn't show as having unstaged changes
1888 // in `git status`. Also, check if there are no type changes.
1889 var lastHunkStagedPromise = function lastHunkStagedPromise(result) {
1890 return NodeGit.Diff.indexToWorkdir(repo, index, {
1891 flags:
1892 NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT |
1893 NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS |
1894 (additionalDiffOptions || 0)
1895 })
1896 .then(function(diff) {
1897 return diff.patches();
1898 })
1899 .then(function(patches) {
1900 var pathPatch = patches.filter(function(patch) {
1901 return patch.newFile().path() === filePath;
1902 });
1903 var emptyPatch = false;
1904 if (pathPatch.length > 0) {
1905 // No hunks, unchanged file mode, and no type changes.
1906 emptyPatch = pathPatch[0].size() === 0 &&
1907 pathPatch[0].oldFile().mode() === pathPatch[0].newFile().mode() &&
1908 !pathPatch[0].isTypeChange();
1909 }
1910 if (emptyPatch) {
1911 return index.addByPath(filePath)
1912 .then(function() {
1913 return index.write();
1914 });
1915 }
1916
1917 return result;
1918 });
1919 };
1920
1921 return repo.refreshIndex()
1922 .then(function(indexResult) {

Callers 1

repository.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…