Commit graph

18 commits

Author SHA1 Message Date
google-labs-jules[bot]
38fafbf639 feat: Add comprehensive docstrings and refactor matrix to tim
Add comprehensive Go docstrings with examples to all packages to achieve 100% coverage.

Refactor the `matrix` package to `tim` (Terminal Isolation Matrix). Update all references to the old package and terminology across the codebase, including commands, tests, and examples.

Fix inconsistencies in command-line flags and help text related to the refactoring.
2025-11-14 21:23:11 +00:00
google-labs-jules[bot]
8ba0deab91 feat: Add _Good, _Bad, and _Ugly tests
Refactored the existing tests to use the `_Good`, `_Bad`, and `_Ugly`
testing convention. This provides a more structured approach to testing
and ensures that a wider range of scenarios are covered, including
valid inputs, invalid inputs, and edge cases.

In addition to refactoring the tests, this change also includes several
bug fixes that were uncovered by the new tests. These fixes improve the
robustness and reliability of the codebase.

The following packages and commands were affected:
- `pkg/datanode`
- `pkg/compress`
- `pkg/github`
- `pkg/matrix`
- `pkg/pwa`
- `pkg/vcs`
- `pkg/website`
- `cmd/all`
- `cmd/collect`
- `cmd/collect_github_repo`
- `cmd/collect_website`
- `cmd/compile`
- `cmd/root`
- `cmd/run`
- `cmd/serve`
2025-11-14 10:36:35 +00:00
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
784e7afef9
Merge branch 'main' into feature-improve-test-coverage 2025-11-03 16:40:16 +00:00
google-labs-jules[bot]
d27d9f3a37 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.
2025-11-03 16:31:26 +00:00
Snider
e7db83bc96 Add initialization comments for command registration in CLI 2025-11-03 03:42:21 +00:00
google-labs-jules[bot]
bb6d30122d refactor: Use dependency injection for mocking
This commit refactors the codebase to use dependency injection for mocking external dependencies, removing the need for in-code mocking with the `BORG_PLEXSUS` environment variable.

- Interfaces have been created for external dependencies in the `pkg/vcs`, `pkg/github`, and `pkg/pwa` packages.
- The `cmd` package has been refactored to use these interfaces, with dependencies exposed as public variables for easy mocking in tests.
- The tests in `TDD/collect_commands_test.go` have been updated to inject mock implementations of these interfaces.
- The `BORG_PLEXSUS` environment variable has been removed from the codebase.
2025-11-02 22:14:52 +00:00
google-labs-jules[bot]
a8dc55aba5 fix: Correct mock data and test environment handling
This commit addresses several issues in the testing framework:

- Corrected a malformed URL in the mock response data in `pkg/github/github.go`.
- Fixed a bug in the mock HTTP client in `pkg/mocks/http.go` where the response body was being exhausted after the first read. The client now returns a deep copy of the response for each call.
- Refactored the environment variable handling in `TDD/collect_commands_test.go` to use `t.Setenv`, ensuring proper cleanup after the test.
2025-11-02 18:46:09 +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]
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]
beaeb04f03 feat: Add authenticated GitHub access and structured logging
This commit introduces two key improvements to the application:

1.  **Authenticated GitHub API Access:** The GitHub client now uses a personal access token (PAT) from the `GITHUB_TOKEN` environment variable if it is available. This increases the rate limit for GitHub API requests, making the tool more robust for users who need to collect a large number of repositories.

2.  **Structured Logging:** The application now uses the standard library's `slog` package for structured logging. A `--verbose` flag has been added to the root command to control the log level, allowing for more detailed output when needed. This makes the application's output more consistent and easier to parse.
2025-11-02 00:59:46 +00:00
google-labs-jules[bot]
19f6a95964 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:
- Refactored `cmd.Execute()` to return an error instead of calling `os.Exit`, making the application more testable.
- Fixed critical issues in `cmd/main_test.go`, including renaming `TestMain` to avoid conflicts and removing the brittle E2E test.
- Improved the GitHub API client in `pkg/github/github.go` by:
  - Fixing a resource leak where an HTTP response body was not being closed.
  - Restoring a parameterized function to improve testability.
  - Adding support for `context.Context` and API pagination for robustness.
- Updated the `.github/workflows/go.yml` CI workflow to use the `Taskfile.yml` for building and testing, ensuring consistency.
- Added a `test` task to `Taskfile.yml`.
- Ran `go mod tidy` and fixed several unused import errors.
2025-11-02 00:31:15 +00:00
google-labs-jules[bot]
aaa8ab3966 fix: Resolve broken build and improve testing
This commit fixes a critical build issue where the application was being compiled as an archive instead of an executable. This was caused by the absence of a `main` package.

The following changes have been made to resolve this and improve the development process:

- A `main.go` file has been added to the root of the project to serve as the application's entry point.
- A `Taskfile.yml` has been introduced to standardize the build, run, and testing processes.
- The build process has been corrected to produce a runnable binary.
- An end-to-end test (`TestE2E`) has been added to the test suite. This test builds the application and runs it with the `--help` flag to ensure the binary is always executable, preventing similar build regressions in the future.
2025-11-01 23:55:14 +00:00
google-labs-jules[bot]
c68626985e feat: Add go.work, update module path, and add examples
This commit introduces several maintenance improvements to the repository.

- A `go.work` file has been added to define the workspace and make the project easier to work with.
- The module path in `go.mod` has been updated to use a GitHub URL, and all import paths have been updated accordingly.
- `examples` and `docs` directories have been created.
- The `examples` directory contains scripts that demonstrate the tool's functionality.
- The `docs` directory contains documentation for the project.
- Tests have been added to the `pkg/github` package following the `_Good`, `_Bad`, `_Ugly` convention.
- The missing `pkg/borg` package has been added to resolve a build error.
2025-10-31 22:15:05 +00:00
google-labs-jules[bot]
21f9a9ca74 feat: Implement core data collection and Trix cube functionality
This commit introduces the core functionality of the Borg Data Collector.

- Adds the `collect` command to clone a single Git repository and store it in a Trix cube.
- Adds the `collect all` command to clone all public repositories from a GitHub user or organization.
- Implements the Trix cube as a `tar` archive.
- Adds the `ingest` command to add files to a Trix cube.
- Adds the `cat` command to extract files from a Trix cube.
- Integrates Borg-themed status messages for a more engaging user experience.
2025-10-31 05:02:29 +00:00