* Goes through a rebase's rebase operations and commits them if there are * no merge conflicts * * @param {Repository} repository The repository that the rebase is being * performed in * @param {Rebase} rebase The current rebase being performed
( repository, rebase, signature, beforeNextFn, beforeFinishFn )
| 211 | * a rebase with conflicts |
| 212 | */ |
| 213 | function performRebase( |
| 214 | repository, |
| 215 | rebase, |
| 216 | signature, |
| 217 | beforeNextFn, |
| 218 | beforeFinishFn |
| 219 | ) { |
| 220 | var beforeNextFnResult; |
| 221 | |
| 222 | /* In the case of FF merges and a beforeFinishFn, this will fail |
| 223 | * when looking for 'rewritten' so we need to handle that case. |
| 224 | */ |
| 225 | function readRebaseMetadataFile(fileName, continueOnError) { |
| 226 | return fse.readFile( |
| 227 | path.join(repository.path(), "rebase-merge", fileName), |
| 228 | { encoding: "utf8" } |
| 229 | ) |
| 230 | .then(fp.trim) |
| 231 | .catch(function(err) { |
| 232 | if (continueOnError) { |
| 233 | return null; |
| 234 | } |
| 235 | throw err; |
| 236 | }); |
| 237 | } |
| 238 | |
| 239 | function calcHeadName(input) { |
| 240 | return input.replace(/refs\/heads\/(.*)/, "$1"); |
| 241 | } |
| 242 | |
| 243 | function getPromise() { |
| 244 | return rebase.next() |
| 245 | .then(function() { |
| 246 | return repository.refreshIndex(); |
| 247 | }) |
| 248 | .then(function(index) { |
| 249 | if (index.hasConflicts()) { |
| 250 | throw index; |
| 251 | } |
| 252 | |
| 253 | return rebase.commit(null, signature); |
| 254 | }) |
| 255 | .then(function() { |
| 256 | |
| 257 | return performRebase( |
| 258 | repository, |
| 259 | rebase, |
| 260 | signature, |
| 261 | beforeNextFn, |
| 262 | beforeFinishFn |
| 263 | ); |
| 264 | }) |
| 265 | .catch(function(error) { |
| 266 | if (error && error.errno === NodeGit.Error.CODE.ITEROVER) { |
| 267 | const calcRewritten = fp.cond([ |
| 268 | [fp.isEmpty, fp.constant(null)], |
| 269 | [fp.stubTrue, fp.flow([ |
| 270 | fp.split("\n"), |
no test coverage detected
searching dependent graphs…