oa助手类工具
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.
 
 

44 lines
1.3 KiB

function checkoutLocalBranch(simpleGit, branches, title, cb) {
if (!branches[title]) {
simpleGit.checkoutLocalBranch(title, function (e) {
if (e) console.log(e)
if (!e && cb) cb()
})
} else {
simpleGit.checkout(title, function (e) {
if (e) console.log(e)
if (!e && cb) cb()
})
}
}
exports.autoCheckoutLocalBranch = function (simpleGit, title, cb, errcb) {
simpleGit.checkIsRepo(function (err, ok) {
if (ok) {
simpleGit.branchLocal(function (err, branchSummary) {
if (!err) {
if (branchSummary.current == "master") {
checkoutLocalBranch(simpleGit, branchSummary.branches, title, function () {
cb()
})
} else {
simpleGit.checkout("master", function () {
checkoutLocalBranch(simpleGit, branchSummary.branches, title, function () {
cb()
})
})
}
console.log(branchSummary)
} else {
console.log(err)
}
})
} else {
if (errcb) errcb(err)
}
})
}