getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.
https://docs.grit.io/
MIT License
3.17k stars 82 forks source link

feat: switch --remote workflows to reuse an existing ID #497

Closed morgante closed 2 months ago

morgante commented 2 months ago

(Avoid populating the UI with many useless one-off instances.)

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago
Walkthrough ## Walkthrough This pull request introduces several modifications across multiple files, primarily focusing on the `run_apply` and `run_remote_workflow` functions. Key changes include the removal of the `pattern_or_workflow` argument in `run_apply`, the addition of an optional `workflow_id` field in the `ApplyMigrationArgs` struct, and the replacement of the `workflow_name` parameter in `run_remote_workflow` with a mechanism to extract `workflow_id` from the arguments. These adjustments streamline parameter handling and enhance the clarity of command-line interface dependencies. ## Changes | Files | Change Summary | |-----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `crates/cli/src/commands/apply.rs` | Simplified `run_apply` function by removing `args.pattern_or_workflow` from the call to `run_remote_workflow`, reducing the number of arguments passed. | | `crates/cli/src/commands/apply_migration.rs`| Added optional `workflow_id` field to `ApplyMigrationArgs` struct, requiring `remote` to be true for its use, and updated help text for `remote` to clarify its dependency on `workflow_id`. | | `crates/cli/src/commands/plumbing.rs` | Introduced `workflow_id` field initialized to `None` in the `ApplyMigrationArgs` struct to support optional workflow identification. | | `crates/cli/src/workflows.rs` | Removed `workflow_name` parameter from `run_remote_workflow` and replaced it with logic to extract `workflow_id` from `args`. Introduced error handling for missing `workflow_id` and updated `RemoteWorkflowSettings` accordingly. | ## Possibly related PRs - **#468**: Modifies `run_apply_migration` for improved error handling based on workflow status, relevant to the changes in `run_apply`. - **#489**: Adds a `flags` parameter to `run_apply`, directly related to the modifications made in the main PR. - **#491**: Introduces authentication handling in `run_apply`, which is relevant to the changes in the main PR affecting `run_apply` logic.

Recent review details **Configuration used: .coderabbit.yaml** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 8eedbe7f674bf7dfb8e335cbe75dfe45003658a1 and 2ee7b0d30b5ebbad51511ec2a4e7ce2d27f101fa.
Files selected for processing (4) * crates/cli/src/commands/apply.rs (1 hunks) * crates/cli/src/commands/apply_migration.rs (1 hunks) * crates/cli/src/commands/plumbing.rs (1 hunks) * crates/cli/src/workflows.rs (2 hunks)
Additional comments not posted (6)
crates/cli/src/commands/apply_migration.rs (2)
`29-30`: **LGTM!** The update to the `help` attribute of the `remote` field clarifies the dependency between the `remote` and `workflow_id` options. This improves the usability of the CLI. --- `33-35`: **LGTM!** The addition of the `workflow_id` field, along with the `#[clap]` attribute specifying the dependency on the `remote` field, enhances the clarity of the CLI by making the relationship between `remote` and `workflow_id` explicit.
crates/cli/src/commands/apply.rs (1)
`70-71`: **LGTM!** The code changes are approved. The simplification of the `run_remote_workflow` call by reducing the number of arguments passed aligns with the design decision to streamline the parameters. The removal of the `args.pattern_or_workflow` argument suggests that it is no longer needed in the context of remote workflows. The control flow remains intact, and there are no apparent issues or side effects introduced by this change.
crates/cli/src/commands/plumbing.rs (1)
`335-335`: **LGTM!** The addition of the optional `workflow_id` field to the `ApplyMigrationArgs` struct enhances the flexibility of the `run_apply_migration` function by allowing it to associate a workflow with a specific ID. This change appears to have minimal impact on the existing logic as the `workflow_id` is initialized to `None`. The code changes are approved.
crates/cli/src/workflows.rs (2)
`299-301`: **LGTM!** The changes to extract `workflow_id` from `args.workflow_id` using pattern matching and raising an error if it's not provided, enhance the robustness of the function by enforcing the requirement for a `workflow_id` and handling its absence explicitly. --- `304-304`: **LGTM!** Updating the `RemoteWorkflowSettings` construction to use `workflow_id` instead of `workflow_name` streamlines the parameters used in the workflow settings and aligns with the removal of the `workflow_name` parameter.
--- 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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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 generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@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 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. ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.