diffx.Stat skips changed lines whose text starts with "++" or "--"

Đang mở Phù hợp với người mới
#195 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
87/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
backend, testing-qa

Hướng nghiên cứu

Đọc internal/diffx/diffx.go quanh Stat và hành vi tạo diff được mô tả trong issue; sau đó chạy các bài kiểm thử diffx và bổ sung các trường hợp cho dòng -- bị xóa, dòng ++ được thêm và tiêu đề tệp. Cập nhật Stat để đếm các dòng đã thay đổi bên trong hunk, đồng thời bỏ qua tiêu đề tệp. Công việc hoàn tất khi các tiêu chí chấp nhận được đáp ứng và make test-short chạy thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug good first issue severity: low

Summary

Stat treats every line starting with +++ or --- as a file header, so an added line whose text starts with ++ and a removed line whose text starts with -- are not counted. The 400-line limit on a model-written patch is computed from this count.

Where

  • internal/diffx/diffx.go:103-110 (Stat)
  • internal/agent/fixcheck.go:44, :194 (added + removed against maxPatchLines = 400)

Details

unified writes an added line as "+" + text and a removed one as "-" + text. An added ++i; becomes +++i;; a removed SQL, Lua or Haskell comment -- note, a YAML --- separator or a --flag \ continuation line becomes --- note. Both match the header case and are skipped.

Impact

The size of a fix is undercounted, so the patch size limit does not hold for such lines; a patch that removes or adds many of them can be far over the limit and still be accepted.

Steps to reproduce

  1. Call diffx.Stat(diffx.Unified("a.sql", "-- one\n-- two\nSELECT 1;\n", "SELECT 1;\n")).
  2. It returns (0, 0); the diff removes two lines.

Suggested fix

Count by position, not by prefix alone: skip --- / +++ only for the two lines that follow a diff --git line (or its mode line) and precede the first @@; inside a hunk count every + and - line.

Acceptance criteria

  • Stat(Unified("a.sql", "-- one\n-- two\nSELECT 1;\n", "SELECT 1;\n")) returns 0 added, 2 removed
  • An added ++i; line counts as 1 added
  • File headers are still not counted

Getting started

  • Relevant files: internal/agent/fixcheck.go, internal/diffx/diffx.go
  • How to run tests: make test-short (Unix) or .\make.ps1 test-short (Windows PowerShell); make lint before you call it done
  • Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 50e92ec. Severity: low. Effort: S. audit-key: bug|internal/diffx/diffx.go|Stat

Ngôn ngữ chính
Go
Star
0
Fork
1
Merge trung bình
8 giờ 14 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/Spackle

Tất cả issue của TMHSDigital/Spackle

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.