Skip to content

[V6] Add some report-status and send-pack tests #1536

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

Open
wants to merge 3 commits into
base: v6-transport
Choose a base branch
from

Conversation

aymanbagabas
Copy link
Member

This adds a new few tests for report-status during the SendPack routine. It also adds more informative pktline error messages, and typed report-status errors.

@aymanbagabas aymanbagabas requested review from Copilot and pjbgf and removed request for Copilot April 28, 2025 19:50
Copy link

@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 adds new tests for the report-status feature in the SendPack routine and improves error messaging in pktline parsing while introducing typed errors for report-status failures.

  • Added tests for buildUpdateRequests covering various capability combinations.
  • Introduced UnpackStatusErr and CommandStatusErr types for more informative error messages.
  • Updated error messages in pktline write/read functions and hex length parsing for clarity.

Reviewed Changes

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

Show a summary per file
File Description
plumbing/transport/build_update_requests_test.go New test cases to validate capabilities for report-status, progress, atomic, and agent.
plumbing/protocol/packp/sideband/demux.go Added check for empty pktline content with an explicit error.
plumbing/protocol/packp/report_status_test.go Extended tests to cover failed command status errors and unpack with failed commands.
plumbing/protocol/packp/report_status.go Refactored error message generation using new error types for unpack/command status errors.
plumbing/format/pktline/pktline.go Updated Writef and Read functions to leverage new fmt.Appendf syntax and improved error text.
plumbing/format/pktline/length.go Changed error messages for hex decoding related to pktline length.
plumbing/format/pktline/common.go Minimal change in import structure.
internal/transport/test/receive_pack.go Removed outdated test assertions tied to report-status in the SendPack tests.

if err == io.ErrUnexpectedEOF {
return Err, ErrInvalidPktLen
if errors.Is(err, io.ErrUnexpectedEOF) {
return Err, fmt.Errorf("%w: short pkt-line %q", ErrInvalidPktLen, len(p[:LenSize]))
Copy link
Preview

Copilot AI Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of %q to format an integer (the length) may be confusing. Consider using a format specifier appropriate for integers (e.g., %d or %04x) to improve clarity in the error message.

Suggested change
return Err, fmt.Errorf("%w: short pkt-line %q", ErrInvalidPktLen, len(p[:LenSize]))
return Err, fmt.Errorf("%w: short pkt-line %d", ErrInvalidPktLen, len(p[:LenSize]))

Copilot uses AI. Check for mistakes.

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.

1 participant