module.exports = BranchDeletion; function BranchDeletion (branch, hash) { this.branch = branch; this.hash = hash; this.success = hash !== null; } BranchDeletion.deleteSuccessRegex = /(\S+)\s+\(\S+\s([^\)]+)\)/; BranchDeletion.deleteErrorRegex = /^error[^']+'([^']+)'/; BranchDeletion.parse = function (data, asArray) { var result; var branchDeletions = data.trim().split('\n').map(function (line) { if (result = BranchDeletion.deleteSuccessRegex.exec(line)) { return new BranchDeletion(result[1], result[2]); } else if (result = BranchDeletion.deleteErrorRegex.exec(line)) { return new BranchDeletion(result[1], null); } }) .filter(Boolean); return asArray ? branchDeletions : branchDeletions.pop(); };