fix overwriting gitignore in initializaiton - #877
Merged
Merged
Conversation
…DB#868) <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR implements `helix sync` to pull schema and query files from Helix Cloud clusters, integrating the CLI with the dashboard backend. It adds comprehensive workspace/project/cluster management flows for both standard and enterprise deployments. **Major additions:** - New `helix sync` command with three flows: workspace-based, project-based, and instance-specific syncing - Interactive workspace/project/cluster selection using `cliclack` prompts - Enterprise cluster support across `add`, `init`, `sync`, and `delete` commands - Path sanitization for remote files to prevent directory traversal attacks - Workspace config persistence to `~/.helix/config` - New `intersect` graph traversal operator in the query engine - Fixed `Ord` implementation in `Value` type to use consistent variant ordering **Critical issues found:** 1. `helix-cli/src/commands/sync.rs:495` - `config.enterprise.clear()` unconditionally removes ALL enterprise instances, not just those from the selected project (similar to the already-flagged issue with cloud instances) 2. `helix-cli/src/commands/delete.rs:93,99` - `todo!()` macros will panic when users delete enterprise instances 3. `helix-db/src/protocol/value.rs:237-249` - Ord/PartialEq inconsistency in Date↔String comparison due to reversed ordering **Recommendations:** - Replace `config.enterprise.clear()` with selective removal logic (like `config.cloud.retain()`) - Implement enterprise instance deletion instead of using `todo!()` - Fix the Date/String comparison ordering to maintain Ord/PartialEq consistency <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | helix-cli/src/commands/sync.rs | New 1410-line file implementing `helix sync` command with workspace/project/cluster selection flows, file syncing from cloud, and path sanitization. Notable issue: `reconcile_project_config_from_cloud` clears all enterprise entries (line 495) which could delete unrelated instances. | | helix-cli/src/commands/workspace_flow.rs | New 456-line file implementing workspace → project → cluster creation flow for `helix add` and `helix init`. Clean implementation with proper workspace caching, billing checks, and enterprise cluster support. | | helix-cli/src/prompts.rs | New 551-line file providing interactive CLI prompts using `cliclack`. Implements workspace/cluster selection, input validation, and deployment configuration flows. Well-structured with proper validation logic. | | helix-cli/src/config.rs | Added `WorkspaceConfig` for persisting workspace selections to `~/.helix/config`, and `EnterpriseInstanceConfig` for enterprise cluster support. Clean additions with proper error handling. | | helix-cli/src/commands/delete.rs | Added enterprise instance handling with `todo!()` placeholders on lines 93 and 99. Will panic when users try to delete enterprise instances created via `helix add cloud` or `helix init cloud`. | | helix-db/src/protocol/value.rs | Fixed `Ord` implementation to use consistent variant ordering instead of returning `Equal` for incomparable types (which violated Ord contract). Added `Date`↔`String` comparison logic. | </details> </details> <details><summary><h3>Flowchart</h3></summary> ```mermaid flowchart TD A[helix sync] --> B{Project context<br/>exists?} B -->|No| C[Workspace Sync Flow] B -->|Yes, with instance| D[Instance-specific Sync] B -->|Yes, interactive| E[Project Sync Flow] C --> F[Load/Select Workspace] F --> G[Fetch Workspace Clusters] G --> H{Cluster Type?} H -->|Standard| I[Sync .hx files from cluster] H -->|Enterprise| J[Sync .rs files from cluster] E --> K[Authenticate & Select Workspace] K --> L[Resolve/Create Project] L --> M[Fetch Project Clusters] M --> N[User Selects Cluster] N --> O{Cluster Type?} O -->|Standard| P[Sync .hx files into project] O -->|Enterprise| Q[Sync .rs files into project] P --> R[Reconcile helix.toml] Q --> R R --> S[Update cloud/enterprise instances] D --> T{Instance Type?} T -->|Helix Cloud| U[Pull from cloud cluster] T -->|Enterprise| V[Pull from enterprise cluster] T -->|Local| W[Not implemented - warn user] U --> X[Fetch cluster metadata] X --> Y[Reconcile helix.toml] V --> Z[Fetch enterprise files] style R fill:#ff9999 style S fill:#ff9999 style Y fill:#ff9999 ``` </details> <sub>Last reviewed commit: a330ecb</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->
HelixDB#870) <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR significantly improves the CLI's sync functionality with intelligent conflict resolution, enhances authentication with cluster API key rotation, and adds update command improvements. **Key Changes:** - **Intelligent Sync**: Implements SHA256-based file hashing and timestamp-based conflict resolution for bidirectional sync between local and cloud. The new system detects divergence and intelligently suggests push/pull operations based on which side has newer changes (with 5-second clock skew tolerance) - **Project Identity**: Adds canonical project ID tracking in `helix.toml` so projects are matched by ID first, then by name as fallback - **Auth Improvements**: Implements cluster API key rotation endpoint (`helix auth create-key`) with proper error handling - **Update Fix**: Adds `no_confirm` flag to the self-update process for non-interactive environments - **Better UX**: Enhanced prompts for project selection with options to create new or choose existing projects **Architectural Improvements:** - New manifest-based sync system compares local and remote state using content hashes - Timestamp-based authority determination for concurrent edits - Path sanitization for security when handling remote file paths - Validation of `.hx` queries before pushing to prevent deploying broken code <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | helix-cli/src/commands/sync.rs | Major refactor to intelligent sync with SHA256 hashing, timestamp-based conflict resolution, and bidirectional reconciliation | | helix-cli/src/commands/auth.rs | Implements cluster API key rotation, memory leak from `.leak()` call on user_id string | | helix-cli/src/commands/workspace_flow.rs | Enhanced project resolution to use project ID as canonical identity with fallback to name matching | | helix-cli/src/prompts.rs | Added new prompts for missing project choice and project selection with better UX | | helix-cli/src/config.rs | Added optional project ID field to ProjectConfig for canonical identity tracking | </details> </details> <details><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A[helix sync command] --> B{Fetch cloud state} B --> C[Build local manifest<br/>SHA256 + timestamps] B --> D[Build remote manifest<br/>SHA256 + timestamps] C --> E[Compare manifests] D --> E E --> F{Comparison result} F -->|Both empty| G[No action needed] F -->|In sync| G F -->|Local only| H{Validate local queries} F -->|Remote only| I{Confirm pull?} F -->|Diverged| J{Determine authority} H -->|Valid| K{Confirm push?} H -->|Invalid| L[Show error] K -->|Yes| M[Push to cloud] K -->|No| G I -->|Yes| N[Pull to local] I -->|No| G J -->|Local newer| O{Push allowed?} J -->|Remote newer| P{Confirm pull?} J -->|Tie/Unknown| Q{User choice} O -->|Yes + Confirm| M O -->|No/Decline| R{Offer pull instead?} P -->|Yes| N P -->|No| G Q -->|Push| M Q -->|Pull| N Q -->|NoOp| G R -->|Yes| N R -->|No| G M --> S[Reconciliation complete] N --> S G --> S ``` </details> <sub>Last reviewed commit: 04280f6</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->
xav-db
requested changes
Mar 3, 2026
| "#; | ||
| let gitignore_path = project_dir.join(".gitignore"); | ||
| fs::write(&gitignore_path, gitignore)?; | ||
| let existing = fs::read_to_string(&gitignore_path).unwrap_or_default(); |
Member
There was a problem hiding this comment.
I think greptile is accurate here! please update
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Thx! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
when we initialization helix with
helix initin a folder that contains a .gitignore with some content that got wriped and overwritten. this PR fixes thatRelated Issues
Closes #876
Checklist when merging to main
rustfmthelix-cli/Cargo.tomlandhelixdb/Cargo.tomlAdditional Notes
Greptile Summary
Changed
.gitignorehandling from overwrite to append mode to preserve existing content when runninghelix init..gitignorecontent before adding new entries.gitignorewas being wipedIssue found: The duplicate check uses substring matching (
existing.contains(line)) which can cause false positives - e.g., if.gitignorecontainsmy-target/, the check fortarget/will incorrectly skip adding it.Important Files Changed
Last reviewed commit: 3e51c60