Skip to content

snaggle --inplace#62

Merged
MusicalNinjaDad merged 13 commits into
mainfrom
directory
Oct 27, 2025
Merged

snaggle --inplace#62
MusicalNinjaDad merged 13 commits into
mainfrom
directory

Conversation

@MusicalNinjaDad

@MusicalNinjaDad MusicalNinjaDad commented Oct 27, 2025

Copy link
Copy Markdown
Owner

closes #57

Summary by Sourcery

Support an inplace snaggling mode that skips linking the original ELF by adding an --inplace flag and programmatic Inplace() option, and update code and tests to validate both default and inplace behaviors

New Features:

  • Introduce an --inplace CLI flag and corresponding Inplace() option to only snag dependencies and interpreter without linking the main binary

Enhancements:

  • Refactor Snaggle() to accept variadic options via an option pattern and extend ExpectedOutput helper to handle inplace mode

Tests:

  • Extend CLI and library tests to run both default and inplace scenarios with updated expected outputs
  • Add AssertDirectoryContents helper to verify target directory contents in tests

@MusicalNinjaDad MusicalNinjaDad linked an issue Oct 27, 2025 that may be closed by this pull request
@sourcery-ai

sourcery-ai Bot commented Oct 27, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR adds a new "inplace" mode to Snaggle—skipping linkage of the base ELF—by refactoring the API to accept variadic options, wiring the new flag through the CLI, updating tests to cover both default and inplace modes, and introducing directory‐contents assertions to validate outputs.

Sequence diagram for Snaggle CLI execution with and without --inplace

sequenceDiagram
    actor User
    participant CLI
    participant Snaggle
    User->>CLI: Run 'snaggle <file> <root>'
    CLI->>Snaggle: Snaggle(path, root)
    Snaggle->>Snaggle: Link base ELF, dependencies, interpreter
    User->>CLI: Run 'snaggle <file> <root> --inplace'
    CLI->>Snaggle: Snaggle(path, root, Inplace())
    Snaggle->>Snaggle: Only link dependencies and interpreter
Loading

Class diagram for new options and option pattern in Snaggle

classDiagram
    class options {
      +bool inplace
    }
    class option {
      <<function>>
      +apply(*options)
    }
    class Snaggle {
      +Snaggle(path string, root string, opts ...option) error
    }
    class Inplace {
      <<function>>
      +Inplace() option
    }
    Snaggle --> options
    option --> options
    Inplace --> option
Loading

File-Level Changes

Change Details Files
Introduce and implement the “inplace” option in the Snaggle API and CLI
  • Refactored Snaggle signature to accept variadic option functions
  • Added options struct and Inplace() helper to control behavior
  • Wired a new --inplace flag in main.go and passed it to Snaggle.Snaggle
snaggle.go
main.go
Refactor test suites to run in both default and inplace modes
  • Wrapped existing test loops to iterate over flags false/true
  • Appended --inplace to exec.Command or passed Inplace() to API calls when flagged
  • Updated ExpectedOutput helper to adjust expected links based on inplace
snaggle/cli_test.go
snaggle_test.go
internal/testing/testdata.go
Add directory‐contents validation for snaggled outputs
  • Introduced AssertDirectoryContents to comparisons.go
  • Invoked the new assertion in both CLI and API tests to ensure correct files
internal/comparisons.go
snaggle/cli_test.go
snaggle_test.go

Assessment against linked issues

Issue Objective Addressed Explanation
#57 Add a --inplace option to the CLI that, when specified, prevents copying the main DIRECTORY contents (i.e., does not copy the main ELF file, only dependencies and interpreter).
#57 Update code and tests to support and verify the behavior of the --inplace option.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Oct 27, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.17949% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.05%. Comparing base (853728b) to head (4b16190).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
snaggle/main.go 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
+ Coverage   74.35%   75.05%   +0.70%     
==========================================
  Files           8        8              
  Lines         425      449      +24     
==========================================
+ Hits          316      337      +21     
- Misses         77       80       +3     
  Partials       32       32              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MusicalNinjaDad MusicalNinjaDad merged commit 355fef9 into main Oct 27, 2025
12 checks passed
@MusicalNinjaDad MusicalNinjaDad deleted the directory branch October 27, 2025 12:20
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.

Add --inplace option (to not copy DIRECTORY contents)

1 participant