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

Provide cleaner merge commit message template

Write simplified message to .git/MERGE_MSG after merge
instead of verbose default merge message

+12 -7
+12 -7
ZipMerge/FileComparer.swift
··· 48 48 try copyContents(from: extractedRoot, to: projectDirectory) 49 49 50 50 // Stage all changes 51 - try runGitCommand(["add", "-A"], at: projectDirectory) 51 + _ = try runGitCommand(["add", "-A"], at: projectDirectory) 52 52 53 53 // Commit the changes 54 54 let commitMessage = "Import from zip: \(zipURL.lastPathComponent)" 55 - try runGitCommand(["commit", "-m", commitMessage], at: projectDirectory) 55 + _ = try runGitCommand(["commit", "-m", commitMessage], at: projectDirectory) 56 56 57 57 // Switch back to original branch 58 - try runGitCommand(["checkout", originalBranch], at: projectDirectory) 58 + _ = try runGitCommand(["checkout", originalBranch], at: projectDirectory) 59 59 60 60 // Initiate merge without committing (allows selective staging) 61 61 let mergeOutput = try? runGitCommand(["merge", "--no-commit", "--no-ff", branchName], at: projectDirectory) 62 62 let hasConflicts = mergeOutput?.contains("CONFLICT") ?? false 63 63 64 64 // Unstage all changes so user can selectively stage with git add -p 65 - try? runGitCommand(["reset"], at: projectDirectory) 65 + _ = try? runGitCommand(["reset"], at: projectDirectory) 66 + 67 + // Write a cleaner commit message template 68 + let cleanMessage = "Merge changes from \(zipURL.deletingPathExtension().lastPathComponent)" 69 + let mergeMessagePath = projectDirectory.appendingPathComponent(".git/MERGE_MSG") 70 + try? cleanMessage.write(to: mergeMessagePath, atomically: true, encoding: .utf8) 66 71 67 72 return GitMergeResult( 68 73 branchName: branchName, ··· 71 76 ) 72 77 } catch { 73 78 // Cleanup: try to switch back to original branch if something went wrong 74 - try? runGitCommand(["checkout", originalBranch], at: projectDirectory) 75 - try? runGitCommand(["branch", "-D", branchName], at: projectDirectory) 79 + _ = try? runGitCommand(["checkout", originalBranch], at: projectDirectory) 80 + _ = try? runGitCommand(["branch", "-D", branchName], at: projectDirectory) 76 81 throw error 77 82 } 78 83 } 79 84 80 85 static func cleanupGitMerge(branchName: String, projectDirectory: URL) throws { 81 86 // Delete the temporary branch 82 - try runGitCommand(["branch", "-D", branchName], at: projectDirectory) 87 + _ = try runGitCommand(["branch", "-D", branchName], at: projectDirectory) 83 88 } 84 89 85 90 private static func runGitCommand(_ arguments: [String], at directory: URL) throws -> String {