Skip to content

refactor: replace acarl005/stripansi with inline regex#676

Merged
skevetter merged 1 commit intomainfrom
sk/dep-replace-stripansi
Apr 6, 2026
Merged

refactor: replace acarl005/stripansi with inline regex#676
skevetter merged 1 commit intomainfrom
sk/dep-replace-stripansi

Conversation

@skevetter
Copy link
Copy Markdown
Owner

@skevetter skevetter commented Apr 4, 2026

Summary

acarl005/stripansi was used in a single file (pkg/pty/ptytest/ptytest.go) for two log-stripping calls. Inlines the same regex pattern from the upstream source to eliminate the direct dependency.

Note: acarl005/stripansi remains an indirect dependency via github.com/skevetter/log.

Changes

  • pkg/pty/ptytest/ptytest.go: removed stripansi import, added package-level ansiEscape regexp, replaced two stripansi.Strip(x) calls with ansiEscape.ReplaceAllString(x, "")
  • go.mod: acarl005/stripansi demoted from direct to indirect

Summary by CodeRabbit

  • Chores

    • Optimized dependency management by reorganizing module dependencies.
  • Refactor

    • Improved internal ANSI escape sequence handling for better maintainability.

The package was used in one file (pkg/pty/ptytest/ptytest.go) for two
log-stripping calls. Inline the same regex pattern from the upstream
source to eliminate the direct dependency.

acarl005/stripansi remains an indirect dep via skevetter/log.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d43086b8-741e-4409-8b2b-af6d5110e375

📥 Commits

Reviewing files that changed from the base of the PR and between 4a7835c and 5d1fca0.

📒 Files selected for processing (2)
  • go.mod
  • pkg/pty/ptytest/ptytest.go

📝 Walkthrough

Walkthrough

This PR removes the external stripansi dependency and replaces its ANSI escape sequence stripping functionality with a locally-defined regex pattern. The go.mod file reclassifies the dependency as indirect, and ptytest.go implements inline ANSI stripping using a compiled regex expression.

Changes

Cohort / File(s) Summary
Dependency Removal
go.mod
Moved github.com/acarl005/stripansi from direct to indirect dependency in the require block.
ANSI Stripping Refactoring
pkg/pty/ptytest/ptytest.go
Replaced stripansi.Strip() calls with locally-defined ansiEscape regex pattern. Updated drainLog and (*outExpecter).ExpectNoMatchBefore methods to use inline ANSI sequence removal.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: removing a direct dependency on acarl005/stripansi and replacing it with an inline regex implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sk/dep-replace-stripansi

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the size/s label Apr 4, 2026
@skevetter skevetter marked this pull request as ready for review April 6, 2026 00:37
@skevetter skevetter merged commit bc7aeaa into main Apr 6, 2026
41 checks passed
@skevetter skevetter deleted the sk/dep-replace-stripansi branch April 6, 2026 01:01
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.

1 participant