文档管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
798 B

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();
};