-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ji Sang Seo
committed
Feb 11, 2024
1 parent
c221bc3
commit 8c5fadb
Showing
5 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env node | ||
|
||
import { Command } from "commander"; | ||
import { finish } from "../src/task/finish.mjs"; | ||
|
||
async function finishCommand() { | ||
const program = new Command(); | ||
program | ||
.name("oh-my-task-end") | ||
.description( | ||
"Finish Task and checkout to base branch. This command is use to end Task life cycle" | ||
); | ||
|
||
program.parse(); | ||
|
||
await finish(); | ||
} | ||
|
||
await finishCommand().catch((error) => console.error(error)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as context from "../context.mjs"; | ||
import * as git from "../git.mjs"; | ||
import { TASK_STATUS, TASK_STATUS_TEXT } from "../status.mjs"; | ||
import { Task } from "../task/Task.mjs"; | ||
|
||
export async function finish() { | ||
let taskCollection = await context.manifest.getHistory(); | ||
|
||
const currentBranchName = git.getCurrentBranchName(); | ||
|
||
let task = Object.values(taskCollection).find( | ||
(task) => git.toBranchName(task.title) === currentBranchName | ||
); | ||
|
||
task = Task.build(task); | ||
// set status to complete | ||
task.finish(); | ||
await context.manifest.setHistory(task.key, task.objectify()); | ||
|
||
// git actions start | ||
|
||
//get branch which to checkout | ||
const seperatorIdx = task.baseBranch.indexOf("/"); | ||
const localBaseBranch = task.baseBranch.slice(seperatorIdx + 1); | ||
|
||
const baseTask = Object.values(taskCollection).find( | ||
(task) => localBaseBranch === git.toBranchName(task.title) | ||
); | ||
|
||
if (baseTask) { | ||
} else { | ||
// probably, base task is original branch made by git or something which user manually created. | ||
// just set task status -> complete and let user to select which branch to move on. | ||
const branchToCheckout = await git.selectBranch( | ||
"Select Branch to checkout:", | ||
false | ||
); | ||
await git.checkout(branchToCheckout); | ||
return; | ||
} | ||
let baseBranch = task.baseBranch; | ||
} |