-
Notifications
You must be signed in to change notification settings - Fork 7
Parse conflict #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse conflict #161
Conversation
This commit introduces a new test case, `testUnmergedAndUnstagedDiffInit`, which validates the parsing of unmerged and unstaged diffs. The test ensures that the file diffs for conflicting files are accurately captured and displayed.
- Updated fromFilePath and toFilePath computed properties to properly handle cases where the header has fewer than 3 components. - Simplified handling of the file paths when the components count is exactly 3. This ensures correct parsing of file paths from the diff headers.
…iles - Introduced `GitStatusTests` to ensure correct parsing of Git status output for untracked and unmerged files. - Modified the `GitStatus` struct to include a new property for unmerged files and updated the parsing logic to extract unmerged files from the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends git parsing and diff processing to support unmerged file information while updating related tests and UI behaviors.
- Added unmergedFiles property and updated GitStatus parsing logic
- Updated UI components and tests to conditionally disable staging when unmerged files are detected
- Refactored diff filtering and file path parsing to accommodate the new unmergedFiles data
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
GitClientTests/GitStatusTests.swift | Adds tests for parsing git status with unmerged file support |
GitClientTests/DiffTests.swift | Introduces tests validating diff initialization with unmerged/unstaged changes |
GitClient/Views/Folder/CommitGraphView.swift | Updates UI initializers to include unmergedFiles in status |
GitClient/Views/Commit/StageFileDiffView.swift | Disables the select chunk button when no handler is provided |
GitClient/Views/Commit/CommitCreateView.swift | Conditionally disables staging actions when unmerged files exist |
GitClient/Models/Status.swift | Adds the unmergedFiles property to the Status model |
GitClient/Models/Diff.swift | Filters out unmerged diff entries and adjusts file path extraction logic |
GitClient/Models/Commands/GitStatusShort.swift | Enhances parsing for unmerged file detection in git status output |
GitClient.xcodeproj/project.pbxproj | Registers the new GitStatusTests.swift file in the project |
let untrackedLines = lines.filter { $0.hasPrefix("?? ") } | ||
return .init(untrackedFiles: untrackedLines.map { String($0.dropFirst(3)) }) | ||
let unmergedLines = lines.filter { $0.hasPrefix("U") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider refining the filter for unmerged lines to match the expected git short status format (e.g., verifying against 'UU') to avoid false positives.
let unmergedLines = lines.filter { $0.hasPrefix("U") } | |
let unmergedLines = lines.filter { $0.hasPrefix("UU ") } |
Copilot uses AI. Check for mistakes.
@@ -78,7 +78,7 @@ struct CommitCreateView: View { | |||
restorePatch(newDiff) | |||
} | |||
}, | |||
onSelectChunk: { fileDiff, chunk in | |||
onSelectChunk: status?.unmergedFiles.isEmpty == false ? nil : { fileDiff, chunk in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extract the condition 'status?.unmergedFiles.isEmpty == false' into a clearly named Boolean variable to improve readability.
onSelectChunk: status?.unmergedFiles.isEmpty == false ? nil : { fileDiff, chunk in | |
onSelectChunk: hasUnmergedFiles ? nil : { fileDiff, chunk in |
Copilot uses AI. Check for mistakes.
@@ -96,7 +96,7 @@ struct CommitCreateView: View { | |||
addPatch(newDiff) | |||
} | |||
}, | |||
onSelectChunk: { fileDiff, chunk in | |||
onSelectChunk: status?.unmergedFiles.isEmpty == false ? nil : { fileDiff, chunk in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extract the condition 'status?.unmergedFiles.isEmpty == false' into a variable to enhance code clarity and reduce duplication.
onSelectChunk: status?.unmergedFiles.isEmpty == false ? nil : { fileDiff, chunk in | |
onSelectChunk: hasUnmergedFiles ? nil : { fileDiff, chunk in |
Copilot uses AI. Check for mistakes.
Resolves #156