Skip to content

Conversation

tarampampam
Copy link
Owner

Adds --keep-original-file option to preserve the original file with a .orig extension alongside the compressed version. This allows users to retain the original files for archival or other purposes.

Related issue: #103

Adds `--keep-original-file` option to preserve the original file
with a `.orig` extension alongside the compressed version. This
allows users to retain the original files for archival or other
purposes.
@tarampampam tarampampam requested a review from Copilot July 23, 2025 10:28
Copilot

This comment was marked as outdated.

Configured the `wsl_v5` linter in `.golangci.yml` to enforce whitespace rules.
Also, fixed whitespace issues reported by the linter in `main.go` and `app.go`.
The configuration allows first-in-block and sets branch-max-lines to 2.
Renamed `wsl` to `wsl_v5` in `.golangci.yml`.
Refactors the `replaceFiles` function to improve error handling when the `KeepOriginalFile` option is enabled. Wraps the file copying logic in a closure to ensure deferred `Close()` calls are executed, even if an error occurs during the copying process. This prevents potential resource leaks and ensures proper cleanup.
@tarampampam tarampampam requested a review from Copilot July 23, 2025 10:41
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 a new --keep-original-file option that preserves the original image file with a .orig extension alongside the compressed version, allowing users to retain original files for archival purposes. The implementation also includes updates to linter configuration and some code formatting improvements.

  • Adds KeepOriginalFile option to CLI with corresponding flag and environment variable support
  • Implements file copying logic in the compression workflow to create .orig backup files
  • Updates linter configuration from wsl to wsl_v5 with new settings

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/cli/options.go Adds KeepOriginalFile boolean field to options struct with default value
internal/cli/app.go Implements CLI flag definition and file copying logic in replaceFiles method
README.md Documents the new --keep-original-file option in usage instructions
.golangci.yml Updates linter configuration from wsl to wsl_v5 with new settings
cmd/tinifier/main.go Updates linter directive from wsl to wsl_v5
pkg/tinypng/client_test.go Adds blank line (formatting change)
internal/errgroup/errgroup_test.go Removes blank line (formatting change)
internal/cli/cmd/tools_for_test.go Adds blank lines around loop (formatting change)

Repository owner deleted a comment from Copilot AI Jul 23, 2025
Repository owner deleted a comment from Copilot AI Jul 23, 2025
Repository owner deleted a comment from Copilot AI Jul 23, 2025
Repository owner deleted a comment from Copilot AI Jul 23, 2025
Repository owner deleted a comment from Copilot AI Jul 23, 2025
@tarampampam tarampampam merged commit 5b04c1c into master Jul 23, 2025
9 checks passed
@tarampampam tarampampam deleted the feat/keep-original-file branch July 23, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant