Skip to content

refactor: adopt github.com/mroth/porcelain/statusv1 for status parsing#100

Merged
mroth merged 1 commit intomasterfrom
porcelainlib
Jul 17, 2025
Merged

refactor: adopt github.com/mroth/porcelain/statusv1 for status parsing#100
mroth merged 1 commit intomasterfrom
porcelainlib

Conversation

@mroth
Copy link
Owner

@mroth mroth commented Jul 16, 2025

This is a minimal set of changes to slap my experimental git status parsing module in to the existing code. This externalizes git status parsing for separation of concerns

Additionally, it is highly likely we would want to switch to using porcelain=v2 in the near future as enabled by github.com/mroth/porcelain, but a phased approach is the plan here.

@mroth mroth force-pushed the porcelainlib branch 4 times, most recently from e957b2f to 612848c Compare July 17, 2025 20:53
@mroth mroth marked this pull request as ready for review July 17, 2025 21:11
@mroth mroth requested a review from Copilot July 17, 2025 21:13
Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mroth mroth requested a review from Copilot July 17, 2025 21:13

This comment was marked as outdated.

@mroth mroth requested a review from Copilot July 17, 2025 21:21
Copy link

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 refactoring replaces the existing custom git status parsing logic with an external library github.com/mroth/porcelain/statusv1 to improve separation of concerns and maintainability.

  • Adopts external porcelain/statusv1 library for parsing git status output
  • Removes internal parsing logic and test code for file path extraction
  • Updates test cases to focus on change type extraction rather than full chunk processing

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
go.mod Adds the new porcelain dependency
internal/gitstatus/porcelainv1/process.go Replaces custom parsing with external library, simplifies processing logic
internal/gitstatus/porcelainv1/process_test.go Updates tests to match new API, removes file path extraction tests
internal/commands/status/status.go Improves error handling with more informative error messages
Comments suppressed due to low confidence (1)

internal/gitstatus/porcelainv1/process_test.go:126

  • This test case appears to test malformed input but doesn't verify that the malformed part is handled correctly. Consider adding assertions to verify the behavior with malformed headers.
			// malformed header, missing LF and containing trailing entry

This is the minimum set of changes to slap my experimental git status
parsing module in to the existing code. This externalizes git status
parsing for separation of concerns

Additionally, it is likely we would want to switch to using porcelainv2
in the near future as enabled by github.com/mroth.porcelain, but a
phased approach is the plan here.
@mroth mroth added the refactor label Jul 17, 2025
@mroth mroth merged commit 7263e09 into master Jul 17, 2025
15 checks passed
@mroth mroth deleted the porcelainlib branch July 17, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants