(repo, index, filePath, isStaged, additionalDiffOptions)
| 127 | } |
| 128 | |
| 129 | function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) { |
| 130 | var diffOptions = additionalDiffOptions ? { |
| 131 | flags: additionalDiffOptions |
| 132 | } : undefined; |
| 133 | |
| 134 | return Promise.resolve() |
| 135 | .then(function() { |
| 136 | if (isStaged) { |
| 137 | return repo.getHeadCommit() |
| 138 | .then(function getTreeFromCommit(commit) { |
| 139 | return commit.getTree(); |
| 140 | }) |
| 141 | .then(function getDiffFromTree(tree) { |
| 142 | return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); |
| 143 | }); |
| 144 | } |
| 145 | |
| 146 | return NodeGit.Diff.indexToWorkdir(repo, index, { |
| 147 | flags: |
| 148 | NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | |
| 149 | NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | |
| 150 | (additionalDiffOptions || 0) |
| 151 | }); |
| 152 | }) |
| 153 | .then(function(diff) { |
| 154 | return NodeGit.Status.file(repo, filePath) |
| 155 | .then(function(status) { |
| 156 | if (!(status & NodeGit.Status.STATUS.WT_MODIFIED) && |
| 157 | !(status & NodeGit.Status.STATUS.INDEX_MODIFIED)) { |
| 158 | return Promise.reject |
| 159 | ("Selected staging is only available on modified files."); |
| 160 | } |
| 161 | return diff.patches(); |
| 162 | }); |
| 163 | }) |
| 164 | .then(function(patches) { |
| 165 | var pathPatch = patches.filter(function(patch) { |
| 166 | return patch.newFile().path() === filePath; |
| 167 | }); |
| 168 | |
| 169 | if (pathPatch.length !== 1) { |
| 170 | return Promise.reject("No differences found for this file."); |
| 171 | } |
| 172 | |
| 173 | return pathPatch[0].hunks(); |
| 174 | }); |
| 175 | } |
| 176 | |
| 177 | function getReflogMessageForCommit(commit) { |
| 178 | var parentCount = commit.parentcount(); |
no outgoing calls
no test coverage detected
searching dependent graphs…