Skip to content

Commit

Permalink
feature: finish command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji Sang Seo committed Feb 11, 2024
1 parent 8c5fadb commit d7e3000
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/git.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function pull() {
}

export async function fetch() {
const result = git("fetch");
const result = git("fetch", "--prune");

if (result.status !== 0) {
throw new Error("Failed to fetch prune");
Expand Down
2 changes: 1 addition & 1 deletion src/task/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function create(
await git.create(taskBranch, baseBranch);
await git.checkout(taskBranch);
await git.push(true);
task.select(TASK_STATUS.WORKING);
task.select();

console.log(`Successfully Selected Task ${chalk.blueBright(taskKey)}`);
console.log(
Expand Down
10 changes: 9 additions & 1 deletion src/task/finish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ export async function finish() {
const seperatorIdx = task.baseBranch.indexOf("/");
const localBaseBranch = task.baseBranch.slice(seperatorIdx + 1);

const baseTask = Object.values(taskCollection).find(
let baseTask = Object.values(taskCollection).find(
(task) => localBaseBranch === git.toBranchName(task.title)
);

if (baseTask) {
baseTask = Task.build(baseTask);
baseTask.select();

const branchToCheckout = git.toBranchName(baseTask.title);
await git.checkout(branchToCheckout);

await git.fetch();
await git.pull();
} 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.
Expand Down

0 comments on commit d7e3000

Please sign in to comment.