This commit is contained in:
Yanick Champoux 2021-11-18 19:54:41 -05:00
parent 67c9964997
commit f497fde8ad
4 changed files with 86 additions and 78 deletions

17
TODO Normal file
View File

@ -0,0 +1,17 @@
- show icons for branches
👷 - U+1F477 - CONSTRUCTION WORKER
🤝
🙋 - U+1F64B - HAPPY PERSON RAISING ONE HAND
🍷 - U+1F377 - WINE GLASS
🍸 - U+1F378 - COCKTAIL GLASS
🔍 - U+1F50D - LEFT-POINTING MAGNIFYING GLASS
🔎 - U+1F50E - RIGHT-POINTING MAGNIFYING GLASS
🥃 - U+1F943 - TUMBLER GLASS
🥛 - U+1F95B - GLASS OF MILK
🥃 - U+1F943 - TUMBLER GLASS
✨ - U+02728 - SPARKLES
⛔ - U+026D4 - NO ENTRY
🚫 - U+1F6AB - NO ENTRY SIGN
- list branch in cyclic order

View File

@ -8,7 +8,7 @@ module.exports = async (yargs) => {
const current = await currentBranch(); const current = await currentBranch();
console.log(`marking branch '$current' as done`); console.log(`marking branch '${current}' as done`);
await Git().addConfig( `branch.${current}.mikado-done`, true ); await Git().addConfig( `branch.${current}.mikado-done`, true );

View File

@ -40,9 +40,7 @@ module.exports = async (yargs) => {
await checkWorkspaceClean(); await checkWorkspaceClean();
const branch = yargs.branch; const {branch,upstream} = yargs;
const upstream = await currentBranch();
const base = yargs.base ?? await getBaseBranch(upstream); const base = yargs.base ?? await getBaseBranch(upstream);

View File

@ -1,84 +1,77 @@
const yargs = require("yargs"); const yargs = require("yargs");
const new = require("./commands/new"); const newCommand = require("./commands/new");
const status = require("./commands/status"); const status = require("./commands/status");
const done = require("./commands/done"); const done = require("./commands/done");
const upstream = require("./commands/upstream"); const upstream = require("./commands/upstream");
const { currentBranch } = require('./utils'); const { currentBranch } = require("./utils");
currentBranch().then( currentBranch().then((currentBranch) => {
currentBranch => { yargs
.scriptName("git-mikado")
.showHelpOnFail(true)
yargs .command("status", "show status of all mikado branches", status)
.scriptName("git-mikado") .command(
.showHelpOnFail(true) "done [branch]",
.command( "set branch as done",
"status", (yargs) => {
"show status of all mikado branches", return yargs.positional("branch", {
status
)
.command(
"done [branch]",
"set branch as done",
(yargs) => {
return yargs
.positional("branch", {
describe: "branch to mark as done", describe: "branch to mark as done",
default: currentBranch
})
},
done
)
.command(
"upstream [upstream]",
"set branch as done",
(yargs) => {
return yargs
.positional("upstream", {
describe: "upstream branch to add",
})
.option("branch", {
alias: "b",
describe: "target branch",
default: currentBranch, default: currentBranch,
}) });
.demandOption(["upstream"]); },
}, done
upstream )
) .command(
.command( "upstream [upstream]",
"new [branch]", "set an upstream of the current branch",
"create new mikado branch", (yargs) => {
(yargs) => { return yargs
return yargs .positional("upstream", {
.positional("branch", { describe: "upstream branch to add",
describe: "name of the new branch", })
}) .option("branch", {
.option("base", { alias: "b",
alias: "b", describe: "target branch",
describe: "base branch", default: currentBranch,
}) })
.option("upstream", { .demandOption(["upstream"]);
alias: "u", },
describe: "branch that is dependent on the new branch", upstream
}) )
.demandOption(["branch"]); .command(
}, "new [branch]",
new "create new mikado branch",
) (yargs) => {
.fail((msg, err, yargs) => { return yargs
try { .positional("branch", {
const message = msg || err.message; describe: "name of the new branch",
console.error(message); })
process.exit(1); .option("base", {
} catch (e) { alias: "b",
yargs.showHelp(); describe: "base branch",
} })
}) .option("upstream", {
.help() alias: "u",
.demandCommand(1, "") default: currentBranch,
.strict().argv; describe:
"branch that is dependent on the new branch",
})
.demandOption(["branch"]);
},
newCommand
)
.fail((msg, err, yargs) => {
try {
const message = msg || err.message;
console.error(message);
process.exit(1);
} catch (e) {
yargs.showHelp();
}
})
.help()
.demandCommand(1, "")
.strict().argv;
}); });