Simple App to help @jaspermayone make it through COMP1050 with a professor who won't use version control.

Fix cleanup to properly discard git changes

- Abort merge if in progress
- Reset hard to discard uncommitted changes
- Clean untracked files
- Add warning in UI about cleanup discarding changes

+18
+5
ZipMerge/ContentView.swift
··· 151 151 .font(.caption) 152 152 .foregroundColor(.secondary) 153 153 .padding(.top, 8) 154 + 155 + Text("⚠️ Cleanup will discard any uncommitted changes and abort the merge.") 156 + .font(.caption) 157 + .foregroundColor(.orange) 158 + .padding(.top, 4) 154 159 } 155 160 .padding() 156 161 .background(Color(NSColor.controlBackgroundColor))
+13
ZipMerge/FileComparer.swift
··· 83 83 } 84 84 85 85 static func cleanupGitMerge(branchName: String, projectDirectory: URL) throws { 86 + // Check if a merge is in progress by looking for MERGE_HEAD 87 + let mergeHeadPath = projectDirectory.appendingPathComponent(".git/MERGE_HEAD") 88 + if FileManager.default.fileExists(atPath: mergeHeadPath.path) { 89 + // Abort the merge to clean up merge state 90 + _ = try? runGitCommand(["merge", "--abort"], at: projectDirectory) 91 + } 92 + 93 + // Discard any uncommitted changes 94 + _ = try? runGitCommand(["reset", "--hard"], at: projectDirectory) 95 + 96 + // Clean any untracked files (but preserve ignored files) 97 + _ = try? runGitCommand(["clean", "-fd"], at: projectDirectory) 98 + 86 99 // Delete the temporary branch 87 100 _ = try runGitCommand(["branch", "-D", branchName], at: projectDirectory) 88 101 }