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

fix(file): Remove unnecessary write permission check on source directories #374

Merged
merged 3 commits into from
Feb 25, 2025

Conversation

yamadashy
Copy link
Owner

ref: #372

Checklist

  • Run npm run test
  • Run npm run lint

@yamadashy yamadashy changed the title Fix/permission error handle fix(file): Fix repomix to request write and execute permissions for the target folder Feb 25, 2025
Copy link

cloudflare-workers-and-pages bot commented Feb 25, 2025

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: ebb4087
Status: ✅  Deploy successful!
Preview URL: https://43932f25.repomix.pages.dev
Branch Preview URL: https://fix-permission-error-handle.repomix.pages.dev

View logs

@yamadashy yamadashy force-pushed the fix/permission-error-handle branch from 6a4c347 to 9e0f637 Compare February 25, 2025 14:02
@yamadashy yamadashy changed the title fix(file): Fix repomix to request write and execute permissions for the target folder fix(file): Remove unnecessary write permission check on source directories Feb 25, 2025
Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

This pull request updates several modules to improve error handling and consistency in permission checks. In the file search module, the error handling logic now checks the directory’s read permission via permissionCheck.details and throws a specialized RepomixError with a detailed message if access is denied. The permission check module has been updated to rename the property from hasPermission to hasAllPermission uniformly. New constants providing URLs for GitHub, issues, and Discord have been added in the shared constants module. In addition, the error handling module now logs an initial empty line, prefixes error messages with a "✖" symbol, and includes enhanced logging of stack traces and community support information. Test cases have been adjusted accordingly to reflect the property name changes.

Sequence Diagram(s)

sequenceDiagram
  participant C as Caller
  participant FS as FileSearch
  participant PC as PermissionCheck
  C->>FS: Invoke searchFiles(directory)
  FS->>PC: checkDirectoryPermissions(directory)
  PC-->>FS: Return { hasAllPermission, details: {read} }
  alt Read permission granted
    FS->>C: Continue file search process
  else Read permission denied
    FS->>FS: Throw RepomixError with detailed message
  end
Loading
sequenceDiagram
  participant E as Error Source
  participant EH as Error Handler
  participant L as Logger
  E->>EH: Pass error (RepomixError or Error)
  EH->>L: Log empty line for spacing
  alt Error is RepomixError
    EH->>L: Log error message with "✖" prefix and debug stack trace
  else Error is generic Error
    EH->>L: Log error message with "✖" prefix, record stack with note, advise using --verbose
  end
  EH->>EH: Append community support info with GitHub issues and Discord links
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c8b60c and ebb4087.

📒 Files selected for processing (5)
  • src/core/file/fileSearch.ts (2 hunks)
  • src/core/file/permissionCheck.ts (3 hunks)
  • src/shared/constants.ts (1 hunks)
  • src/shared/errorHandle.ts (2 hunks)
  • tests/core/file/permissionCheck.test.ts (9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Test (macos-latest, 23.x)
  • GitHub Check: Test (windows-latest, 23.x)
  • GitHub Check: Test (windows-latest, 22.x)
  • GitHub Check: Test (windows-latest, 21.x)
  • GitHub Check: Test (windows-latest, 20.x)
  • GitHub Check: Test (windows-latest, 19.x)
  • GitHub Check: Test (windows-latest, 18.0.0)
  • GitHub Check: Test coverage
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (12)
src/shared/constants.ts (1)

1-3: Good addition of URL constants.

Adding these URLs as constants promotes consistency and maintainability across the application. These constants can be referenced throughout the codebase, making it easier to update URLs in a single location if they ever change.

tests/core/file/permissionCheck.test.ts (1)

29-29: Property name updated correctly throughout tests.

All instances of hasPermission property have been consistently renamed to hasAllPermission throughout the test file to match the interface changes in the implementation. This maintains the test coverage while reflecting the more semantically accurate property name.

Also applies to: 58-58, 77-77, 92-92, 107-107, 118-118, 194-194, 214-214, 233-233

src/core/file/fileSearch.ts (2)

7-7: Good import addition for error handling.

Adding the import for RepomixError allows for more specific error types, which will improve error handling and user experience.


77-84: Improved permission check and error handling.

This change properly focuses on checking only read permission instead of requiring all permissions, which aligns with the PR objective to remove unnecessary write permission checks. The error message is now more specific and helpful for users.

The use of RepomixError instead of a generic Error provides more consistent error handling across the application.

src/core/file/permissionCheck.ts (2)

7-7: More explicit interface property name.

Renaming from hasPermission to hasAllPermission makes the semantics clearer that this property indicates whether all required permissions are present, not just any permission.


58-58: Consistent property name update throughout implementation.

All return statements have been correctly updated to use the new hasAllPermission property name, maintaining consistency with the interface change.

Also applies to: 64-64, 74-74, 80-80, 86-86

src/shared/errorHandle.ts (6)

2-3: Improved imports for better error handling and user guidance.

The addition of URLs and log level constants enhances the error handling capabilities by providing users with specific resources for assistance.


20-21: Empty line before error messages improves readability.

Adding an empty line before displaying error messages creates better visual separation in the console output.


23-25: Enhanced error visibility with consistent prefixing.

The addition of the "✖" symbol to error messages improves visual scanning of the console output and creates consistency in error formatting.


26-34: Improved unexpected error handling with better debugging guidance.

The changes provide clearer error messaging and appropriately guide users to enable verbose logging when needed, which aligns with the PR's goal of improving error handling.


36-41: Consistent error handling for unknown errors.

The code now handles unknown errors with the same level of detail as other error types, maintaining consistency in the error reporting experience.


44-48: Enhanced user support information.

The addition of specific guidance and resource links helps users find assistance when encountering errors, which is particularly valuable in the context of permission-related issues addressed in the PR.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@yamadashy yamadashy force-pushed the fix/permission-error-handle branch from 9e0f637 to 47f99f2 Compare February 25, 2025 14:04
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 58.62069% with 12 lines in your changes missing coverage. Please review.

Project coverage is 89.18%. Comparing base (4c8b60c) to head (ebb4087).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/shared/errorHandle.ts 52.94% 8 Missing ⚠️
src/core/file/fileSearch.ts 25.00% 3 Missing ⚠️
src/core/file/permissionCheck.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   89.43%   89.18%   -0.25%     
==========================================
  Files          66       67       +1     
  Lines        2914     2931      +17     
  Branches      594      595       +1     
==========================================
+ Hits         2606     2614       +8     
- Misses        308      317       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yamadashy yamadashy force-pushed the fix/permission-error-handle branch from 47f99f2 to ebb4087 Compare February 25, 2025 15:09
@yamadashy yamadashy merged commit 15b214c into main Feb 25, 2025
53 checks passed
@yamadashy yamadashy deleted the fix/permission-error-handle branch February 25, 2025 15:13
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