native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #113 from supabitapp/fix-worktree-remove-spinner

Fix detached worktree removal

authored by

khoi and committed by
GitHub
2f0494f0 0b7f8d6c

+20 -13
+7 -2
Resources/git-wt/wt
··· 643 643 json) 644 644 printf '[' 645 645 local first=1 646 - while IFS=$'\t' read -r branch path head; do 647 - [ -n "$branch" ] || continue 646 + while IFS= read -r line || [ -n "$line" ]; do 647 + [ -n "$line" ] || continue 648 + local branch path head rest 649 + branch=${line%%$'\t'*} 650 + rest=${line#*$'\t'} 651 + path=${rest%%$'\t'*} 652 + head=${rest#*$'\t'} 648 653 if [ "$first" -eq 0 ]; then 649 654 printf ',' 650 655 fi
+12 -11
supacode/Clients/Git/GitClient.swift
··· 9 9 case worktreeRemove = "worktree_remove" 10 10 case branchNames = "branch_names" 11 11 case branchRename = "branch_rename" 12 + case branchDelete = "branch_delete" 12 13 case dirtyCheck = "dirty_check" 13 14 case lineChanges = "line_changes" 14 15 } ··· 67 68 let entries = try JSONDecoder().decode([GitWtWorktreeEntry].self, from: data) 68 69 let worktreeEntries = entries.enumerated().map { index, entry in 69 70 let worktreeURL = URL(fileURLWithPath: entry.path).standardizedFileURL 71 + let name = entry.branch.isEmpty ? worktreeURL.lastPathComponent : entry.branch 70 72 let detail = Self.relativePath(from: repositoryRootURL, to: worktreeURL) 71 73 let id = worktreeURL.path(percentEncoded: false) 72 74 let resourceValues = try? worktreeURL.resourceValues(forKeys: [ ··· 77 79 return WorktreeSortEntry( 78 80 worktree: Worktree( 79 81 id: id, 80 - name: entry.branch, 82 + name: name, 81 83 detail: detail, 82 84 workingDirectory: worktreeURL, 83 85 repositoryRootURL: repositoryRootURL ··· 233 235 } 234 236 235 237 nonisolated func removeWorktree(_ worktree: Worktree) async throws -> URL { 236 - if !worktree.name.isEmpty { 237 - let wtURL = try wtScriptURL() 238 - _ = try await runLoginShellProcess( 239 - operation: .worktreeRemove, 240 - executableURL: wtURL, 241 - arguments: ["rm", "-f", worktree.name], 242 - currentDirectoryURL: worktree.repositoryRootURL 243 - ) 244 - return worktree.workingDirectory 245 - } 246 238 let rootPath = worktree.repositoryRootURL.path(percentEncoded: false) 247 239 let worktreePath = worktree.workingDirectory.path(percentEncoded: false) 248 240 _ = try await runGit( ··· 256 248 worktreePath, 257 249 ] 258 250 ) 251 + if !worktree.name.isEmpty { 252 + let names = try await localBranchNames(for: worktree.repositoryRootURL) 253 + if names.contains(worktree.name.lowercased()) { 254 + _ = try await runGit( 255 + operation: .branchDelete, 256 + arguments: ["-C", rootPath, "branch", "-D", worktree.name] 257 + ) 258 + } 259 + } 259 260 return worktree.workingDirectory 260 261 } 261 262
+1
supacode/Features/Repositories/Reducer/RepositoriesFeature.swift
··· 520 520 let selectionWasRemoved, 521 521 let nextSelection 522 522 ): 523 + state.deletingWorktreeIDs.remove(worktreeID) 523 524 state.pendingSetupScriptWorktreeIDs.remove(worktreeID) 524 525 state.pendingTerminalFocusWorktreeIDs.remove(worktreeID) 525 526 let roots = state.repositories.map(\.rootURL)