- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
Add BUCK file parser and buck rule patcher #8
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
Conversation
Signed-off-by: jl.jiang <[email protected]>
Signed-off-by: jl.jiang <[email protected]>
…` commands Signed-off-by: jl.jiang <[email protected]>
Signed-off-by: jl.jiang <[email protected]>
Signed-off-by: jl.jiang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds BUCK file parsing capabilities and rule patching functionality to handle existing BUCK files when migrating dependencies. It removes the minimal flag option and enhances the migration process to preserve existing BUCK file configurations.
- Adds Python-based BUCK file parser using PyO3 for existing rule extraction
 - Implements rule patching to merge existing BUCK configurations with new generated rules
 - Removes the 
minimalflag from command arguments and simplifies rule generation 
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description | 
|---|---|
| src/commands/migrate.rs | Enhanced migration logic with BUCK file parsing and patching support | 
| src/commands/add.rs | Removed minimal flag parameter from function calls | 
| src/buckify.rs | Simplified rule generation by removing minimal flag and added more target kinds | 
| src/buck.rs | Added comprehensive BUCK file parsing and rule patching functionality using PyO3 | 
| Cargo.toml | Added PyO3 dependencies for Python integration | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Process dep nodes | ||
| let mut queue: VecDeque<Node> = VecDeque::new(); | ||
| let mut visited: HashSet<&str> = HashSet::new(); | ||
| let mut visited: HashSet<String> = HashSet::new(); | 
    
      
    
      Copilot
AI
    
    
    
      Sep 7, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HashSet type changed from HashSet<&str> to HashSet<String>. This creates unnecessary string allocations. Consider keeping the original HashSet<&str> type to avoid cloning strings for each node ID.
| if visited.contains(node.id.repr.as_str()) { | ||
| continue; | ||
| } | ||
| visited.insert(node.id.repr.to_owned()); | 
    
      
    
      Copilot
AI
    
    
    
      Sep 7, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line clones the string unnecessarily. If the HashSet type remains as HashSet<&str>, this should be visited.insert(&node.id.repr) to avoid the allocation.
| .expect("Expected 'include' argument") | ||
| .and_then(|v| v.extract().ok()) | ||
| .unwrap_or_default(); | ||
| let include: Set<String> = include_vec.into_iter().collect(); | ||
| let exclude_vec: Vec<String> = kwargs | ||
| .get_item("exclude") | ||
| .expect("Expected 'exclude' argument") | 
    
      
    
      Copilot
AI
    
    
    
      Sep 7, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expect message 'Expected 'include' argument' is misleading. The expect is called on get_item which returns an Option, not on the absence of the argument. Consider using a more accurate message like 'Failed to get include item from dict'.
| .expect("Expected 'include' argument") | |
| .and_then(|v| v.extract().ok()) | |
| .unwrap_or_default(); | |
| let include: Set<String> = include_vec.into_iter().collect(); | |
| let exclude_vec: Vec<String> = kwargs | |
| .get_item("exclude") | |
| .expect("Expected 'exclude' argument") | |
| .expect("Failed to get include item from dict") | |
| .and_then(|v| v.extract().ok()) | |
| .unwrap_or_default(); | |
| let include: Set<String> = include_vec.into_iter().collect(); | |
| let exclude_vec: Vec<String> = kwargs | |
| .get_item("exclude") | |
| .expect("Failed to get exclude item from dict") | 
| let rule = BuildscriptRun::from_py_dict(kwargs)?; | ||
| buck_rules.insert(func_name.to_string(), Rule::BuildscriptRun(rule)); | ||
| } | ||
| _ => panic!("Unknown function name: {}", func_name), | 
    
      
    
      Copilot
AI
    
    
    
      Sep 7, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using panic for unknown function names is too aggressive and will crash the program. Consider returning a proper error or logging a warning and skipping unknown functions instead.
| _ => panic!("Unknown function name: {}", func_name), | |
| _ => { | |
| eprintln!("Warning: Unknown function name encountered: {}", func_name); | |
| // Skip unknown function names | |
| } | 
No description provided.