Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: supitsdu/clipper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4.0
Choose a base ref
...
head repository: supitsdu/clipper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.0
Choose a head ref
  • 5 commits
  • 11 files changed
  • 2 contributors

Commits on Jun 25, 2024

  1. refact(tests): improves handling of cleanup func (#21)

    Handles cleanup using t.Cleanup() instead of manually calling defer
    after using replaceStdin.
    supitsdu authored Jun 25, 2024
    Configuration menu
    Copy the full SHA
    0951d39 View commit details
    Browse the repository at this point in the history

Commits on Jun 28, 2024

  1. refactor: updates Package Structure, Add Interfaces, and Enhance Test…

    …ing (#29)
    
    * refactor: remove main_test.go
    
    Removed main_test.go as its functionality is now integrated into more specific test files.
    
    * refactor: remove main.go
    
    Removed main.go file to migrate functionality to the more appropriately named cli/main.go.
    
    * feat: define options configuration struct
    
    Define a configuration struct for command line options to manage and parse command line arguments effectively.
    
    * feat: introduce content and clipboard interfaces
    
    Introduce interfaces for content reading and clipboard writing to enhance flexibility and testability.
    
    * refactor: restructure command line argument handling
    
    Refactor command line argument handling into a dedicated CLI package for improved organization and clarity.
    
    * feat: add ClipboardWriter as a parameter to Run
    
    - Modify the Run function to accept a ClipboardWriter as a parameter instead of creating a DefaultClipboardWriter directly. This would enable easier mocking of the clipboard for testing.
    
    * feat: update clipper.Run() with the default clipboard writer
    
    * test: add comprehensive unit tests for clipper package
    
    This commit introduces a new `tests/clipper_test.go` file, which includes comprehensive unit tests for the clipper package. The tests cover various components including:
    - FileContentReader: Reads content from a file.
    - StdinContentReader: Reads content from standard input.
    - DefaultClipboardWriter: Writes content to the clipboard.
    - ParseContent: Parses content from multiple sources, including direct text, files, and invalid inputs.
    
    Additionally, the tests use helper functions for creating temporary files and replacing stdin, improving readability and maintainability.
    
    * chore: bump release to 1.5.0
    
    * build: update build target to the cli folder
    
    * tests: skips DefaultClipboardWriter test on CI
    
    Skipping clipboard test in short mode. Helps avoid errors when on CI environments.
    
    * refactor: modify Run() to return (string, error) instead of printing and exiting
    
    - Refactored the `Run` function to return a `string` (representing the success message or version information) and an `error`.
    - This change allows the caller of `Run` to handle the output and errors gracefully, rather than relying on `Run` to print messages and exit directly.
    - Updated the error handling to use `fmt.Errorf` with error wrapping (%w) for better context.
    - This improvement enhances the flexibility and testability of the `clipper` tool.
    
    * refactor: update main function to handle Run's (string, error) return values
    
    - Modified the `main` function to call `clipper.Run` and handle both the returned message and error.
    - Prints the success message if no error occurred, or an error message if an error was encountered.
    - Exits with a status code of 0 for success or 1 for errors.
    - This change ensures that the `main` function gracefully handles the output and errors generated by the `Run` function.
    
    * refactor: extract GetReaders function to improve code organization
    
    - Introduced a new function `GetReaders` in `clipper.go` to handle the logic of creating `ContentReader` instances based on command-line arguments.
    - This refactoring improves the readability and maintainability of the `Run` function by separating out a specific task.
    - The `Run` function now calls `GetReaders` to obtain the necessary readers, making its logic more focused and concise.
    supitsdu authored Jun 28, 2024
    Configuration menu
    Copy the full SHA
    3301698 View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2024

  1. ci: Add golangci-lint configuration and fix initial linting errors (#32)

    * ci: add more rules
    
    * chore: format files and fix imports orders
    
    * chore: fix error reported by revive
    ccoVeille authored Jun 29, 2024
    Configuration menu
    Copy the full SHA
    eda2677 View commit details
    Browse the repository at this point in the history

Commits on Jun 30, 2024

  1. feat(clipper): Implement concurrent file reading and refactor project…

    … structure (#34)
    
    * feat(cli/reader): introduce `cli/reader/reader.go` package with goroutines and channels
    
    Added new package `cli/reader/reader.go` to handle file and stdin content reading using goroutines and channels. Includes `ReadContentConcurrently` function to improve performance when handling multiple files.
    
    Issue #23
    
    * refactor(cli/clipper): refactor to use `cli/reader/reader.go` for content reading
    
    Refactored `cli/clipper/clipper.go` to utilize functionalities from `cli/reader/reader.go` package. This change improves code readability and separates concerns for content reading operations.
    
    * test(structure): restructure tests with `tests/tests.go` for helpers and constants
    
    Introduced `tests/tests.go` to hold helper functions and constants used across test cases, improving organization and reusability of testing resources.
    
    * test(reorganize): reorganize `tests/clipper/clipper_test.go` for `cli/clipper/clipper.go` tests
    
    Reorganized `tests/clipper/clipper_test.go` to focus exclusively on testing functionalities within `cli/clipper/clipper.go`, ensuring clear and specific test coverage.
    
    * test(add): implement `tests/reader/reader_test.go` for `cli/reader/reader.go` tests
    
    Introduced `tests/reader/reader_test.go` to contain tests exclusively targeting functionalities within `cli/reader/reader.go`. Enhances clarity and maintainability of test cases related to content reading operations.
    supitsdu authored Jun 30, 2024
    Configuration menu
    Copy the full SHA
    7ddb223 View commit details
    Browse the repository at this point in the history
  2. fix: Prevent unexpected newline in output for empty files (#35)

    * fix: Prevent unexpected newline in output for empty files
    
    Modified ReadContentConcurrently and AggregateContent functions in reader package to handle empty content scenarios gracefully. ReadContentConcurrently now checks for empty content before appending to results, ensuring only valid content is processed. AggregateContent skips appending newline separators for empty content, addressing the issue where empty files would erroneously contribute newlines to the final output.
    
    - [x] Review the unit tests for ParseContent to ensure they cover the case of empty file input.
    - [x] Consider adding a test specifically for this scenario to prevent regressions in the future.
    
    Closes #31
    
    * test(reader): Prevent regression with empty files
    
    Updated tests in reader_test.go to include checks for handling empty files in ParseContent function of reader package. Added tests to verify that ParseContent correctly returns an empty string when provided with an empty file path and a newline character string. This ensures consistent behavior and addresses potential issues highlighted in #31.
    supitsdu authored Jun 30, 2024
    Configuration menu
    Copy the full SHA
    a1e6216 View commit details
    Browse the repository at this point in the history
Loading