Commit graph

12 commits

Author SHA1 Message Date
google-labs-jules[bot]
52c0fa6b6d feat: Improve test coverage and refactor for testability
This commit introduces a significant refactoring of the `cmd` package to improve testability and increases test coverage across the application.

Key changes include:
- Refactored Cobra commands to use `RunE` for better error handling and testing.
- Extracted business logic from command handlers into separate, testable functions.
- Added comprehensive unit tests for the `cmd`, `compress`, `github`, `logger`, and `pwa` packages.
- Added tests for missing command-line arguments, as requested.
- Implemented the `borg all` command to clone all public repositories for a GitHub user or organization.
- Restored and improved the `collect pwa` functionality.
- Removed duplicate code and fixed various bugs.
- Addressed a resource leak in the `all` command.
- Improved error handling in the `pwa` package.
- Refactored `main.go` to remove duplicated logic.
- Fixed several other minor bugs and inconsistencies.
2025-11-03 18:25:04 +00:00
Snider
e7db83bc96 Add initialization comments for command registration in CLI 2025-11-03 03:42:21 +00:00
google-labs-jules[bot]
19431ed23d refactor: Improve test suite and mocking implementation
This commit refactors the test suite and mocking implementation based on user feedback.

- The mock HTTP client in `pkg/mocks/http.go` has been made thread-safe.
- The `pkg/website/website.go` package has been refactored to use dependency injection for the HTTP client.
- The tests in `TDD/collect_commands_test.go` have been updated to use separate buffers for stdout and stderr, and to use a local test server for the `collect website` command.
2025-11-02 20:03:32 +00:00
google-labs-jules[bot]
7adfff1d0d feat: Add TDD framework and fix build error
This commit introduces a TDD testing framework for the `collect` commands and resolves a build failure.

- A `TDD/` directory has been added to house tests for the `collect` commands.
- An environment variable `BORG_PLEXSUS=0` has been implemented to enable a mock mode, which prevents external network calls during testing.
- The `collect` commands have been updated to use the command's output streams, allowing for output capturing in tests.
- A `pkg/mocks` package has been added to provide mock implementations for testing.
- The `.gitignore` file has been updated to exclude generated `.datanode` files.
- The "flag redefined" build error has been fixed by refactoring the root command initialization in `cmd/root.go` to prevent duplicate flag definitions.
2025-11-02 18:11:04 +00:00
4cb80d970e
Merge branch 'main' into feature-tdd-testing-with-mocking 2025-11-02 17:59:08 +00:00
google-labs-jules[bot]
74b7ba25a3 feat: Add TDD tests with mocking for collect commands
This commit introduces a TDD testing framework for the `collect` commands.

- A `TDD/` directory has been added to house the tests.
- An environment variable `BORG_PLEXSUS=0` has been implemented to enable a mock mode, which prevents external network calls during testing.
- The `collect` commands have been updated to use the command's output streams, allowing for output capturing in tests.
- A `pkg/mocks` package has been added to provide mock implementations for testing.
- The `.gitignore` file has been updated to exclude generated `.datanode` files.
2025-11-02 17:57:09 +00:00
28438e1e96 Merge pull request #10 from Snider/feature-non-interactive-quotes
feat: Implement non-interactive quote display
2025-11-02 17:56:13 +00:00
google-labs-jules[bot]
edc0d6a18c feat: Implement non-interactive quote display
This commit introduces a non-interactive mode for the `collect` commands. When running in a non-interactive session, the progress bar is replaced with a series of thematic Borg quotes, printed in matrix-green text.

The quotes are sourced from a `quotes.json` file, which is embedded into the binary using Go's `embed` package. The `pkg/ui` package now contains a `NonInteractivePrompter` that detects the session type and displays the quotes accordingly. The `collect` commands have been updated to use this new prompter, and the underlying `vcs` and `website` packages have been made more robust to handle cases where a progress bar is not provided.
2025-11-02 16:34:45 +00:00
google-labs-jules[bot]
43f3904072 refactor: Improve code quality, testability, and CI
This commit addresses several issues identified in a code review to improve the overall quality and robustness of the application.

Key changes include:
- Added safe type assertions with `nil` checks when retrieving the logger from the context to prevent panics.
- Moved the `bar.Finish()` call to be inside the loop in the `all` command, so each progress bar finishes after its corresponding repository is cloned.
- Added a check for context cancellation at the start of the pagination loop in the GitHub client to prevent unnecessary API calls.
- Ensured the authenticated client is used consistently, even when falling back to the organization endpoint.
- Added `nil` checks for the progress bar parameter in the `website` and `pwa` packages to prevent panics.
- Updated the `golang.org/x/oauth2` dependency to a patched release to address a reported vulnerability.
2025-11-02 01:54:23 +00:00
google-labs-jules[bot]
88502deb41 feat: Add progress bars to long-running operations
This commit improves the user experience of the application by adding progress bars to long-running operations.

The following commands now display a progress bar:
- `collect github repo`
- `collect website`
- `collect pwa`

The underlying packages (`pkg/vcs`, `pkg/website`, and `pkg/pwa`) have been updated to support progress reporting.
2025-11-02 01:26:52 +00:00
google-labs-jules[bot]
52a07f46be feat: Add ability to download from GitHub releases
This commit introduces a new command `collect github-release` that allows downloading assets from the latest GitHub release of a repository.

The command supports the following features:
- Downloading a specific file from the release using the `--file` flag.
- Downloading all assets from the release and packing them into a DataNode using the `--pack` flag.
- Specifying an output directory for the downloaded files using the `--output` flag.

This commit also includes a project-wide refactoring of the Go module path to `github.com/Snider/Borg` to align with Go's module system best practices.
2025-11-01 19:03:04 +00:00
google-labs-jules[bot]
8e82bada06 feat: Add recursive website downloader and progress bar
This commit introduces a new `collect website` command that recursively downloads a website to a specified depth.

- A new `pkg/website` package contains the logic for the recursive download.
- A new `pkg/ui` package provides a progress bar for long-running operations, which is used by the website downloader.
- The `collect pwa` subcommand has been restored to be PWA-specific.
2025-10-31 21:35:53 +00:00