Showing the changes to node_modules/simple-git/src/responses/BranchDeleteSummary.js (1 of 41 files). Show all
Unified · Split
| @@ -0,0 +1,26 @@ | ||
| 1 | + | |
| 2 | +module.exports = BranchDeletion; | |
| 3 | + | |
| 4 | +function BranchDeletion (branch, hash) { | |
| 5 | + this.branch = branch; | |
| 6 | + this.hash = hash; | |
| 7 | + this.success = hash !== null; | |
| 8 | +} | |
| 9 | + | |
| 10 | +BranchDeletion.deleteSuccessRegex = /(\S+)\s+\(\S+\s([^\)]+)\)/; | |
| 11 | +BranchDeletion.deleteErrorRegex = /^error[^']+'([^']+)'/; | |
| 12 | + | |
| 13 | +BranchDeletion.parse = function (data, asArray) { | |
| 14 | + var result; | |
| 15 | + var branchDeletions = data.trim().split('\n').map(function (line) { | |
| 16 | + if (result = BranchDeletion.deleteSuccessRegex.exec(line)) { | |
| 17 | + return new BranchDeletion(result[1], result[2]); | |
| 18 | + } | |
| 19 | + else if (result = BranchDeletion.deleteErrorRegex.exec(line)) { | |
| 20 | + return new BranchDeletion(result[1], null); | |
| 21 | + } | |
| 22 | + }) | |
| 23 | + .filter(Boolean); | |
| 24 | + | |
| 25 | + return asArray ? branchDeletions : branchDeletions.pop(); | |
| 26 | +}; | |