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

feat: add dryRun settings #277

Merged
merged 15 commits into from
Jan 21, 2024
Merged

feat: add dryRun settings #277

merged 15 commits into from
Jan 21, 2024

Conversation

Mara-Li
Copy link
Member

@Mara-Li Mara-Li commented Jan 21, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a "Dry run" mode for previewing repository update actions without making actual changes.
    • Added new settings to configure the "Dry run" mode, including enabling it, specifying a folder for dry run actions, and auto-cleanup options.
  • Enhancements

    • Improved file management to filter out files based on their paths before processing.
    • Enhanced the submenu commands to conditionally include items based on path exclusions and dry run checks.
    • Updated the user interface to reflect the new "Dry run" mode settings.
  • Bug Fixes

    • Fixed issues with the creation, modification, and checking of files and folders during dry run operations.
    • Corrected the conditional logic for executing repository actions based on dry run settings.
  • Documentation

    • Updated the documentation to include information about the new "Dry run" mode and settings.
  • Refactor

    • Refactored code to integrate "Dry run" logic across various components and methods for consistent behavior.

Copy link

coderabbitai bot commented Jan 21, 2024

Walkthrough

The software has been updated to include a "dry run" mode across various components, which allows users to simulate actions like updating, deleting, and uploading to GitHub without making actual changes. This feature is useful for verifying the behavior of operations before execution. The implementation touches upon methods handling file operations and settings, integrating the dry run logic and ensuring that the simulated actions don't affect live data.

Changes

File Path Change Summary
src/GitHub/branch.ts
src/GitHub/upload.ts
src/commands/index.ts
src/utils/parse_frontmatter.ts
Added support for dryRun parameter to simulate updates without applying them.
src/GitHub/delete.ts
src/commands/file_menu.ts
src/utils/data_validation_test.ts
Enhanced file deletion logic and path validation to support dryRun mode and additional parameters.
src/GitHub/files.ts Modified file filtering method to consider file paths conditionally.
src/settings.ts
src/settings/interface.ts
Introduced "Dry run" mode settings in the GitHubPublisherSettingsTab and updated the interface to reflect new settings.

🐇✨
"In the realm of code, where the data bunnies leap,
A new spell cast, no changes to keep.
Dry run mode, a cautious rabbit's dream,
Simulate the push, without a data stream." 🌟🐾

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 6

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c14c510 and d8eb7c4.
Files selected for processing (10)
  • src/GitHub/branch.ts (1 hunks)
  • src/GitHub/delete.ts (5 hunks)
  • src/GitHub/files.ts (1 hunks)
  • src/GitHub/upload.ts (8 hunks)
  • src/commands/file_menu.ts (2 hunks)
  • src/commands/index.ts (6 hunks)
  • src/settings.ts (1 hunks)
  • src/settings/interface.ts (3 hunks)
  • src/utils/data_validation_test.ts (6 hunks)
  • src/utils/parse_frontmatter.ts (6 hunks)
Additional comments: 27
src/settings/interface.ts (2)
  • 63-66: The dryRun property has been added to the GitHubPublisherSettings interface. Ensure that all parts of the code that use this interface are updated to handle the new dryRun structure.
  • 223-226: The DEFAULT_SETTINGS constant has been updated to include default values for the dryRun property. This is a good practice to ensure that there are sensible defaults for new settings.
src/GitHub/branch.ts (1)
  • 209-212: The updateRepository method now accepts a dryRun parameter. If dryRun is true, the method returns immediately. This change correctly implements the dry run feature for the update process.
src/commands/file_menu.ts (3)
  • 6-6: The import statement has been updated to include isExcludedPath and isInDryRunFolder. Ensure that these functions are implemented correctly and used wherever necessary.
  • 49-62: The addSubMenuCommandsFolder function now checks if the path is excluded before adding submenu items. This is a good use of the new isExcludedPath function to conditionally display menu items.
  • 66-66: The isInDryRunFolder function is used to skip adding submenu items for folders that are part of the dry run. This is a good implementation of the dry run feature in the UI.
src/commands/index.ts (5)
  • 137-140: The noticeFragment variable is used to create a span element for notices. This is a good practice for creating dynamic HTML content in JavaScript.
  • 144-145: The purgeNotesRemote function now checks the dryRun setting before creating a new branch. This is a correct implementation of the dry run feature for the deletion process.
  • 152-153: The updateRepository call within purgeNotesRemote is also gated by the dryRun setting. This ensures that repository updates are not performed during a dry run.
  • 188-189: The shareOneNote function correctly checks the dryRun setting before creating a new branch. This is consistent with the dry run feature's intended behavior.
  • 214-214: The updateRepository method is called with the dryRun setting as an argument. This is a good practice to pass configuration settings down to methods that need them.
src/GitHub/delete.ts (5)
  • 4-4: The import statement has been expanded to include several new modules from "obsidian". Ensure that these new imports (MetadataCache, normalizePath, TAbstractFile, TFile, TFolder, Vault) are being used within the file. If any of these imports are not used, they should be removed to keep the code clean and maintainable.
  • 68-68: The dryRun functionality has been integrated into the deleteFromGithubOneRepo function. It checks if dryRun.autoclean is true and returns the result of cleanDryRun if so. This is a logical place to handle the dry run scenario for the delete operation. However, ensure that the cleanDryRun function is correctly simulating the deletion without making actual changes when dryRun is enabled.
  • 193-193: The excludedFileFromDelete function has been updated but the changes are not visible in the diff. Ensure that the logic for determining if a file should be excluded from deletion is correctly implemented and that it respects the dryRun setting if applicable.
  • 315-389: The cleanDryRun function is responsible for simulating the deletion of files when dryRun is enabled. It appears to be correctly identifying files within the dryRunFolder and simulating their deletion. However, ensure that the vault.trash method is not actually deleting the files when in dryRun mode. The function should only simulate the deletion process.
  • 391-402: The indexFileDryRun function checks the frontmatter of a file to determine if it should be excluded from the dry run deletion process. Ensure that the frontmatter properties (index, delete, share) are being used as intended and that the function returns the correct boolean value to indicate whether a file should be skipped during the dry run deletion.
src/utils/data_validation_test.ts (6)
  • 3-3: The import statement now includes TFolder. Verify that TFolder is being used within the file. If it is not used, it should be removed to avoid unnecessary imports.
  • 34-34: The isInternalShared function now includes a call to isInDryRunFolder. Ensure that this new logic correctly determines whether a file is part of the dry run folder and should be treated as shared or not based on the dryRun settings.
  • 91-92: The isShared function has been updated to include a call to isExcludedPath. Confirm that this change correctly filters out files that should not be shared based on the repository settings and the dryRun configuration.
  • 103-118: The isExcludedPath function has been modified to include a new parameter repository and a call to isInDryRunFolder. Verify that the function correctly identifies excluded paths and respects the dryRun settings when determining if a file or folder should be excluded.
  • 327-327: The checkRepositoryValidityWithRepoFrontmatter function now includes a check for settings.github.dryRun.enable. Ensure that this check correctly bypasses the repository validity checks when dryRun is enabled, as no actual changes should be made to the repository in this mode.
  • 434-445: The new isInDryRunFolder function has been added to determine if a file or folder is part of the dry run folder. Confirm that the function correctly identifies files and folders based on the dryRun folder settings and that it is used consistently throughout the codebase where such checks are necessary.
src/GitHub/files.ts (1)
  • 92-92: The getAllFileWithPath method in the FilesManagement class has been modified to filter out files based on their path. Ensure that this new condition correctly excludes files from the dryRun folder from being processed further, aligning with the intended behavior of the dryRun feature.
src/GitHub/upload.ts (4)
  • 452-478: The uploadImage function contains logic to handle dryRun mode by creating or modifying files in the vault. This logic is correct, but it's important to ensure that the dryRun folder is properly secured to prevent unauthorized access, as it may contain sensitive data.

Ensure that the dryRun folder is secured and not accessible to unauthorized users.

  • 496-524: The uploadText function also contains logic to handle dryRun mode by creating or modifying files in the vault. Similar to the uploadImage function, ensure that the dryRun folder is properly secured.

Ensure that the dryRun folder is secured and not accessible to unauthorized users.

  • 551-551: The uploadMetadataExtractorFiles function correctly checks for dryRun mode and returns early if it's enabled. This prevents any actual uploading of metadata files during a dry run.
  • 582-582: The workflowGestion function correctly checks for dryRun mode and returns false if it's enabled, preventing the workflow dispatch from being triggered during a dry run.

src/utils/parse_frontmatter.ts Outdated Show resolved Hide resolved
src/utils/parse_frontmatter.ts Outdated Show resolved Hide resolved
src/utils/parse_frontmatter.ts Outdated Show resolved Hide resolved
src/settings.ts Outdated Show resolved Hide resolved
src/GitHub/upload.ts Outdated Show resolved Hide resolved
src/GitHub/upload.ts Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d8eb7c4 and 23b6142.
Files ignored due to path filters (2)
  • src/i18n/locales/en.json is excluded by: !**/*.json
  • src/i18n/locales/fr.json is excluded by: !**/*.json
Files selected for processing (3)
  • src/GitHub/upload.ts (9 hunks)
  • src/settings.ts (1 hunks)
  • src/utils/parse_frontmatter.ts (6 hunks)
Files skipped from review as they are similar to previous changes (3)
  • src/GitHub/upload.ts
  • src/settings.ts
  • src/utils/parse_frontmatter.ts

@Mara-Li
Copy link
Member Author

Mara-Li commented Jan 21, 2024

@coderabbitai review

@Enveloppe Enveloppe deleted a comment from github-actions bot Jan 21, 2024
@Mara-Li
Copy link
Member Author

Mara-Li commented Jan 21, 2024

@coderabbitai resolve

@Mara-Li
Copy link
Member Author

Mara-Li commented Jan 21, 2024

@coderabbitai help

Copy link

coderabbitai bot commented Jan 21, 2024

CodeRabbit Commands

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

@Mara-Li Mara-Li merged commit b94a318 into master Jan 21, 2024
@Mara-Li Mara-Li deleted the dry-run branch January 21, 2024 19:02
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