Skip to content

Commit 7329f24

Browse files
authored
Merge pull request #81 from beNative/codex/add-svnswitch-step-to-task-workflow
Add SVN switch task step support
2 parents 6f292a7 + bfdcbe4 commit 7329f24

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

components/modals/RepoFormModal.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const STEP_DEFINITIONS: Record<TaskStepType, { label: string; icon: React.Compon
7878
[TaskStepType.GitCheckout]: { label: 'Git Checkout', icon: ArrowRightOnRectangleIcon, description: 'Switch to a specific branch.' },
7979
[TaskStepType.GitStash]: { label: 'Git Stash', icon: ArchiveBoxIcon, description: 'Stash uncommitted local changes.' },
8080
[TaskStepType.SvnUpdate]: { label: 'SVN Update', icon: ArrowDownTrayIcon, description: 'Update working copy to latest revision.' },
81+
[TaskStepType.SvnSwitch]: { label: 'SVN Switch', icon: ArrowRightOnRectangleIcon, description: 'Switch working copy to a different branch or URL.' },
8182
[TaskStepType.RunCommand]: { label: 'Run Command', icon: CodeBracketIcon, description: 'Execute a custom shell command.' },
8283
// Delphi
8384
[TaskStepType.DelphiBuild]: { label: 'Delphi Build', icon: BeakerIcon, description: 'Build, rebuild, or clean a Delphi project.' },
@@ -133,7 +134,7 @@ const STEP_DEFINITIONS: Record<TaskStepType, { label: string; icon: React.Compon
133134
const STEP_CATEGORIES = [
134135
{ name: 'General', types: [TaskStepType.RunCommand] },
135136
{ name: 'Git', types: [TaskStepType.GitPull, TaskStepType.GitFetch, TaskStepType.GitCheckout, TaskStepType.GitStash] },
136-
{ name: 'SVN', types: [TaskStepType.SvnUpdate] },
137+
{ name: 'SVN', types: [TaskStepType.SvnUpdate, TaskStepType.SvnSwitch] },
137138
{ name: 'Node.js', types: [TaskStepType.NODE_INSTALL_DEPS, TaskStepType.NODE_RUN_BUILD, TaskStepType.NODE_RUN_TESTS, TaskStepType.NODE_RUN_LINT, TaskStepType.NODE_RUN_FORMAT, TaskStepType.NODE_RUN_TYPECHECK] },
138139
{ name: 'Go', types: [TaskStepType.GO_MOD_TIDY, TaskStepType.GO_FMT, TaskStepType.GO_TEST, TaskStepType.GO_BUILD] },
139140
{ name: 'Rust', types: [TaskStepType.RUST_CARGO_FMT, TaskStepType.RUST_CARGO_CLIPPY, TaskStepType.RUST_CARGO_CHECK, TaskStepType.RUST_CARGO_TEST, TaskStepType.RUST_CARGO_BUILD] },
@@ -341,10 +342,19 @@ const TaskStepItem: React.FC<{
341342
<button type="button" onClick={() => onRemoveStep(step.id)} className="p-1.5 text-red-500 hover:bg-red-100 dark:hover:bg-red-900/50 rounded-full"><TrashIcon className="h-4 w-4" /></button>
342343
</div>
343344
</div>
344-
{step.type === TaskStepType.GitCheckout && (
345+
{(step.type === TaskStepType.GitCheckout || step.type === TaskStepType.SvnSwitch) && (
345346
<div>
346-
<label className="text-xs font-medium text-gray-500 dark:text-gray-400">Branch Name</label>
347-
<input type="text" placeholder="e.g., main" value={step.branch || ''} onChange={(e) => onStepChange(step.id, { branch: e.target.value })} required className={formInputStyle} />
347+
<label className="text-xs font-medium text-gray-500 dark:text-gray-400">
348+
{step.type === TaskStepType.GitCheckout ? 'Branch Name' : 'Switch Target'}
349+
</label>
350+
<input
351+
type="text"
352+
placeholder={step.type === TaskStepType.GitCheckout ? 'e.g., main' : 'e.g., ^/branches/release/1.2'}
353+
value={step.branch || ''}
354+
onChange={(e) => onStepChange(step.id, { branch: e.target.value })}
355+
required
356+
className={formInputStyle}
357+
/>
348358
</div>
349359
)}
350360
{step.type === TaskStepType.DelphiBuild && (
@@ -1339,6 +1349,7 @@ const TaskStepsEditor: React.FC<{
13391349
const newStep: TaskStep = { id: `step_${Date.now()}`, type, enabled: true };
13401350
if (type === TaskStepType.RunCommand) newStep.command = suggestions.length > 0 ? suggestions[0].value : 'npm run build';
13411351
if (type === TaskStepType.GitCheckout) newStep.branch = 'main';
1352+
if (type === TaskStepType.SvnSwitch) newStep.branch = 'trunk';
13421353
setTask({ ...task, steps: [...task.steps, newStep] });
13431354
setIsAddingStep(false);
13441355
};

electron/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,9 @@ ipcMain.on('run-task-step', async (event, { repo, step, settings, executionId, t
21972197
case TaskStepType.GitStash: await run(`${gitCmd} stash`); break;
21982198
// SVN Steps
21992199
case TaskStepType.SvnUpdate: await run(`${svnCmd} update`); break;
2200+
case TaskStepType.SvnSwitch:
2201+
if (!step.branch) { sendLog('Skipping SVN switch: no target specified.', LogLevel.Warn); sendEnd(0); return; }
2202+
await run(`${svnCmd} switch ${step.branch}`); break;
22002203
// Common Steps
22012204
case TaskStepType.RunCommand:
22022205
if (!step.command) { sendLog('Skipping empty command.', LogLevel.Warn); sendEnd(0); return; }

hooks/useRepositoryManager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ const runSimulationStep = async (
280280
randomFail(0.1, 'Simulated SVN conflict.');
281281
addLogEntry(repoId, 'Successfully updated working copy.', LogLevel.Success);
282282
break;
283+
case TaskStepType.SvnSwitch:
284+
if (!step.branch) {
285+
addLogEntry(repoId, 'Skipping SVN switch: no target specified.', LogLevel.Warn);
286+
break;
287+
}
288+
addLogEntry(repoId, `svn switch ${step.branch}`, LogLevel.Command);
289+
await simulateDelay(1200);
290+
randomFail(0.1, 'Simulated SVN switch failure.');
291+
addLogEntry(repoId, `Switched working copy to '${step.branch}'.`, LogLevel.Success);
292+
break;
283293
case TaskStepType.GitFetch:
284294
addLogEntry(repoId, `git fetch`, LogLevel.Command);
285295
await simulateDelay(1000);

types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export enum TaskStepType {
8080
GitCheckout = 'GIT_CHECKOUT',
8181
GitStash = 'GIT_STASH',
8282
SvnUpdate = 'SVN_UPDATE',
83+
SvnSwitch = 'SVN_SWITCH',
8384
RunCommand = 'RUN_COMMAND',
8485
// Delphi
8586
DelphiBuild = 'DELPHI_BUILD',
@@ -195,7 +196,7 @@ export interface TaskStep {
195196
id: string;
196197
type: TaskStepType;
197198
enabled: boolean;
198-
branch?: string; // for GitCheckout
199+
branch?: string; // for GitCheckout / SvnSwitch target
199200
command?: string; // for RunCommand
200201
// Delphi
201202
delphiProjectFile?: string;

0 commit comments

Comments
 (0)