finish end
This commit is contained in:
@@ -25,7 +25,7 @@ function toPromise(dp) {
|
||||
}
|
||||
|
||||
function echo(dp) {
|
||||
console.log(JSON.stringify(dp));
|
||||
console.log(JSON.stringify(dp, null, 2));
|
||||
return dp;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ lib = {
|
||||
parse,
|
||||
featureName,
|
||||
prefix,
|
||||
start
|
||||
start,
|
||||
echo
|
||||
};
|
||||
|
||||
module.exports = lib;
|
||||
|
||||
28
js/git.js
28
js/git.js
@@ -22,9 +22,35 @@ function setFeatureBranch(dp) {
|
||||
return immutable.set(dp, "branch.feature", fb);
|
||||
}
|
||||
|
||||
function parseCurrentBranch(dp) {
|
||||
const parts = dp.branch.current.split("-");
|
||||
return immutable.set(dp, "branch.parts", parts);
|
||||
}
|
||||
|
||||
function setStandardBranch(dp) {
|
||||
const parts = _.get(dp, "branch.parts", []);
|
||||
return immutable.set(dp, "branch.standard", parts[1]);
|
||||
}
|
||||
|
||||
function isBranchRemote(dp) {
|
||||
const branch = _.get(dp, "branch.current");
|
||||
const cmd = `git branch -r|grep origin|grep -v 'HEAD'|grep ${branch}`;
|
||||
return shell
|
||||
.capture(cmd)
|
||||
.then(x => x.trim())
|
||||
.then(x =>
|
||||
x === ""
|
||||
? immutable.set(dp, "branch.remote", false)
|
||||
: immutable.set(dp, "branch.remote", branch)
|
||||
);
|
||||
}
|
||||
|
||||
lib = {
|
||||
setCurrentBranch,
|
||||
setFeatureBranch
|
||||
setFeatureBranch,
|
||||
setStandardBranch,
|
||||
parseCurrentBranch,
|
||||
isBranchRemote
|
||||
};
|
||||
|
||||
module.exports = lib;
|
||||
|
||||
@@ -28,6 +28,23 @@ function featureIsNotStandardBranch(dp) {
|
||||
}
|
||||
}
|
||||
|
||||
lib = { currentIsStandardBranch, featureIsNotStandardBranch };
|
||||
function mustBeFeatureBranch(dp) {
|
||||
const parts = dp.branch.parts;
|
||||
if (
|
||||
parts.length > 2 &&
|
||||
commander.prefix() === parts[0] &&
|
||||
branch.isStandard(parts[1])
|
||||
) {
|
||||
return dp;
|
||||
} else {
|
||||
throw `ERROR: ${dp.branch.current} is not a feature branch`;
|
||||
}
|
||||
}
|
||||
|
||||
lib = {
|
||||
currentIsStandardBranch,
|
||||
mustBeFeatureBranch,
|
||||
featureIsNotStandardBranch
|
||||
};
|
||||
|
||||
module.exports = lib;
|
||||
|
||||
Reference in New Issue
Block a user