Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions packages/cli/src/commands/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { IterationConfig } from '../lib/iteration.js';
import { generateBranchName } from '../utils/branch-name.js';
import { request } from 'node:https';
import { spawn } from 'node:child_process';
import { launch, launchSync } from 'rover-common';
import { launchSync } from 'rover-common';
import { checkGitHubCLI } from '../utils/system.js';
import { showRoverBanner, showRoverChat, showTips } from '../utils/display.js';
import { userInfo } from 'node:os';
Expand Down Expand Up @@ -781,14 +781,16 @@ export const taskCommand = async (
fromGithub?: string;
follow?: boolean;
yes?: boolean;
branch?: string;
sourceBranch?: string;
targetBranch?: string;
json?: boolean;
debug?: boolean;
} = {}
) => {
const telemetry = getTelemetry();
// Extract options
const { follow, yes, json, fromGithub, debug, branch } = options;
const { follow, yes, json, fromGithub, debug, sourceBranch, targetBranch } =
options;

// Check if rover is initialized
const roverPath = join(process.cwd(), '.rover');
Expand Down Expand Up @@ -881,13 +883,13 @@ export const taskCommand = async (

// Validate branch option and check for uncommitted changes
const git = new Git();
let baseBranch = branch;
let baseBranch = sourceBranch;

if (branch) {
if (sourceBranch) {
// Validate specified branch exists
if (!git.branchExists(branch)) {
if (!git.branchExists(sourceBranch)) {
if (!json) {
console.log(colors.red(`✗ Branch '${branch}' does not exist`));
console.log(colors.red(`✗ Branch '${sourceBranch}' does not exist`));
}
process.exit(1);
}
Expand All @@ -905,20 +907,22 @@ export const taskCommand = async (
);
console.log(
colors.yellow(
' Consider using --branch option to specify a clean base branch or stash your changes'
' Consider using --source-branch option to specify a clean base branch or stash your changes'
)
);
const initialPrompt = description || initPrompt || '';

if (initialPrompt.length > 0) {
console.log(
colors.gray(` Example: `) +
colors.cyan(`rover task --branch main "${initialPrompt}"\n`)
colors.cyan(`rover task --source-branch main "${initialPrompt}"
`)
);
} else {
console.log(
colors.gray(` Example: `) +
colors.cyan(`rover task --branch main\n`)
colors.cyan(`rover task --source-branch main
`)
);
}
}
Expand Down Expand Up @@ -1126,7 +1130,7 @@ export const taskCommand = async (

// Setup git worktree and branch
const worktreePath = join(taskPath, 'workspace');
const branchName = generateBranchName(taskId);
const branchName = targetBranch || generateBranchName(taskId);

try {
git.createWorktree(worktreePath, branchName, baseBranch);
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ program
)
.option('-f, --follow', 'Follow execution logs in real-time')
.option('-y, --yes', 'Skip all confirmations and run non-interactively')
.option('--branch <branch>', 'Base branch for git worktree creation')
.option(
'-s, --source-branch <branch>',
'Base branch for git worktree creation'
)
.option('-t, --target-branch <branch>', 'Custom name for the worktree branch')
.option('--json', 'Output the result in JSON format')
.option('--debug', 'Show debug information like running commands')
.argument(
Expand Down
Loading