Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.3 Enhanced Buffer Handling for Large Diffs in evergit commit Command #6

Merged
merged 9 commits into from
Nov 19, 2024

Conversation

IanSkelskey
Copy link
Owner

Summary

This pull request addresses the ENOBUFS error encountered when executing the evergit commit command with a large number of staged changes, which previously caused spawnSync to exceed its default buffer size.

Changes Made

  • Increased the buffer size in the getDiffForStagedFiles function to 10 MB, allowing it to handle larger diffs without failing.
  • Added custom error handling for buffer overflow scenarios. If the output exceeds the buffer limit, a specific error message is thrown, guiding the user to limit staged files or increase the buffer size.

Testing Instructions

  • Prepare a Large Diff: Stage a significant number of changes or a large file.
  • Run evergit commit: Execute the command to confirm that the increased buffer handles large diffs as expected.
  • Custom Error Validation: Adjust the maxBuffer size to a lower value (e.g., 1 MB) and confirm that the custom error message appears if the diff output exceeds this limit.

Additional Notes

This enhancement ensures evergit can handle larger commit diffs more reliably, and the custom error message improves the user experience by providing clear guidance when the buffer size is exceeded.

IanSkelskey and others added 9 commits November 16, 2024 21:22
Improve the existing test suite by adding integration tests for Git-related utilities. This includes setting up a temporary Git repository to validate behavior in an actual repository context, ensuring correctness of utilities like `isInGitRepo`, `hasGitChanges`, `stageAllFiles`, and `getCurrentBranchName`.

- Created a temporary Git repository for test execution.
- Added a test to verify repository setup without mocking.
- Validated change detection with `hasGitChanges` after modifying a file.
- Tested branch name retrieval with `getCurrentBranchName` in branch-agnostic manner.
- Ensured test repository cleanup post-tests.

Release-Note: Add integration tests for Git utilities enhancing test reliability.

Signed-off-by: Ian Skelskey <ianskelskey@gmail.com>
- Update `main` function to accept command-line arguments, enabling easier testing
- Export `main` function for use in tests; retain standalone execution capability
- Add Jest tests for CLI commands to verify `commit` calls and help output
- Mock `process.exit` to prevent Jest from terminating during tests
- Suppress unwanted console errors and warnings in AI utility tests to ensure clarity

Release-Note: Improve CLI testability by refactoring the main function and adding comprehensive test coverage.

Signed-off-by: Ian Skelskey <ianskelskey@gmail.com>
Improves the getDiffForStagedFiles function by introducing a buffer size limit of 10 MB. Handles potential buffer overflow errors gracefully by advising the user to either reduce the number of staged files or increase the buffer size.

Release-Note: Improve buffer handling in git diff function to prevent overflow

Signed-off-by: Ian Skelskey <ianskelskey@gmail.com>
- Updated the version in README, package.json, and main.ts to 0.1.3
- Improved buffer handling in the `getDiffForStagedFiles` function
- Enhanced the CLI main function and added corresponding tests
- Added integration tests for Git utilities
- Beautified codebase for increased readability

Release-Note: Version updated to 0.1.3; enhanced CLI and code quality

Signed-off-by: Ian Skelskey <ianskelskey@gmail.com>
- Introduced `setUserName` and `setUserEmail` functions in `src/util/git.ts` for configuring Git user identity.
- Updated `git.test.ts` to include integration tests ensuring user identity can be set during repository setup.

Release-Note: Add Git utilities for setting user name and email in repository setup.

Signed-off-by: Ian Skelskey <ianskelskey@gmail.com>
@IanSkelskey IanSkelskey merged commit a83a7e3 into main Nov 19, 2024
4 checks passed
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.

1 participant