mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 13:42:21 +00:00
plan: add archive tag 2
This commit is contained in:
@@ -118,6 +118,8 @@ export interface CloseSessionResult {
|
||||
cleanupPerformed?: boolean;
|
||||
worktreesRemoved?: string[];
|
||||
branchesDeleted?: string[];
|
||||
tagsCreated?: string[];
|
||||
warnings?: string[];
|
||||
}
|
||||
```
|
||||
|
||||
@@ -298,6 +300,8 @@ async function promptUser(question: string): Promise<string> {
|
||||
export async function closeMultiModel(options: CloseSessionOptions): Promise<CloseSessionResult> {
|
||||
const worktreesRemoved: string[] = [];
|
||||
const branchesDeleted: string[] = [];
|
||||
const tagsCreated: string[] = [];
|
||||
const warnings: string[] = [];
|
||||
|
||||
try {
|
||||
// Check if session exists
|
||||
@@ -337,8 +341,17 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
|
||||
worktreesRemoved.push(worktree.path);
|
||||
|
||||
// Create an archive tag before deleting the branch for safe recovery
|
||||
const archiveTag = `archive/${worktree.branch}`;
|
||||
await runCommand(["git", "tag", archiveTag, worktree.branch]);
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const archiveTag = `archive/${worktree.branch}-${timestamp}`;
|
||||
const tagResult = await runCommand(["git", "tag", archiveTag, worktree.branch]);
|
||||
|
||||
if (tagResult.ok) {
|
||||
tagsCreated.push(archiveTag);
|
||||
} else {
|
||||
const warningMsg = `Failed to create tag ${archiveTag} for branch ${worktree.branch}.`;
|
||||
warnings.push(warningMsg);
|
||||
console.warn(`Warning: ${warningMsg}`);
|
||||
}
|
||||
|
||||
await runCommand(["git", "branch", "-D", worktree.branch]);
|
||||
branchesDeleted.push(worktree.branch);
|
||||
@@ -363,7 +376,9 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
|
||||
sessionName: options.sessionName,
|
||||
cleanupPerformed,
|
||||
worktreesRemoved,
|
||||
branchesDeleted
|
||||
branchesDeleted,
|
||||
tagsCreated,
|
||||
warnings
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
@@ -371,7 +386,9 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
|
||||
sessionName: options.sessionName,
|
||||
error: String(error),
|
||||
worktreesRemoved,
|
||||
branchesDeleted
|
||||
branchesDeleted,
|
||||
tagsCreated,
|
||||
warnings
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -455,6 +472,12 @@ export const closeTool = tool({
|
||||
let details = "";
|
||||
if (result.cleanupPerformed) {
|
||||
details += ` Removed ${result.worktreesRemoved?.length || 0} worktrees.`;
|
||||
if (result.tagsCreated && result.tagsCreated.length > 0) {
|
||||
details += ` Created backup tags: ${result.tagsCreated.join(", ")}.`;
|
||||
}
|
||||
if (result.warnings && result.warnings.length > 0) {
|
||||
details += ` Warnings: ${result.warnings.join("; ")}.`;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -553,6 +576,12 @@ program
|
||||
console.log(`✓ Closed session: ${result.sessionName}`);
|
||||
if (result.cleanupPerformed) {
|
||||
console.log(` Removed ${result.worktreesRemoved?.length || 0} worktrees`);
|
||||
if (result.tagsCreated && result.tagsCreated.length > 0) {
|
||||
console.log(` Created backup tags: ${result.tagsCreated.join(", ")}`);
|
||||
}
|
||||
if (result.warnings && result.warnings.length > 0) {
|
||||
console.log(` Warnings: ${result.warnings.join("; ")}`);
|
||||
}
|
||||
if (result.branchesDeleted && result.branchesDeleted.length > 0) {
|
||||
console.log(` Deleted ${result.branchesDeleted.length} branches`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user