Skip to content

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

Merged
merged 8 commits into from
Jun 12, 2025
Merged

Parse conflict #161

merged 8 commits into from
Jun 12, 2025

Conversation

maoyama
Copy link
Owner

@maoyama maoyama commented Jun 11, 2025

Resolves #156

maoyama added 8 commits June 2, 2025 11:30
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.
@maoyama maoyama requested a review from Copilot June 11, 2025 23:35
Copy link
Contributor

@Copilot Copilot AI left a 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") }
Copy link
Preview

Copilot AI Jun 11, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jun 11, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jun 11, 2025

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.

Suggested change
onSelectChunk: status?.unmergedFiles.isEmpty == false ? nil : { fileDiff, chunk in
onSelectChunk: hasUnmergedFiles ? nil : { fileDiff, chunk in

Copilot uses AI. Check for mistakes.

@maoyama maoyama merged commit f832825 into main Jun 12, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse conflict
1 participant