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

Sweep: Allow comparing a file on the left with another on the right with a different name, while comparing directories #2

Open
1 task done
weshouman opened this issue Oct 17, 2023 · 1 comment · May be fixed by #3
Labels

Comments

@weshouman
Copy link
Owner

weshouman commented Oct 17, 2023

Brief

While comparing 2 directories we would like to have the option to compare 2 file names that may have different names.

Expected behavior

Right click on a file on the left and select "Select left file/dir to compare" then right click on the right file (or dir) and select "Compare to 'filename'". Note we should be able to do that also starting from the right file

Checklist
  • meld/dirdiff.py ✅ Commit 3447ab7
@sweep-ai sweep-ai bot added the sweep label Oct 17, 2023
@sweep-ai
Copy link

sweep-ai bot commented Oct 17, 2023

Here's the PR! #3.

⚡ Sweep Basic Tier: I'm creating this ticket using GPT-4. You have 4 GPT-4 tickets left for the month and 2 for the day. For more GPT-4 tickets, visit our payment portal.

Actions (click)

  • ↻ Restart Sweep
Install Sweep Configs: Pull Request

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

Step 2: ⌨️ Coding

  • meld/dirdiff.py ✅ Commit 3447ab7
Modify meld/dirdiff.py with contents:
• Add a new method `select_left_file_to_compare` in the `DirDiff` class. This method should store the selected file or directory path in a class variable.
• Add a new method `select_right_file_to_compare` in the `DirDiff` class. This method should store the selected file or directory path in a class variable.
• Modify the `on_button_press_event` method in the `DirDiff` class to add two new options in the context menu: "Select left file/dir to compare" and "Compare to 'filename'". The first option should call the `select_left_file_to_compare` method and the second option should call the `select_right_file_to_compare` method.
• Modify the `compare_selected_files` method in the `DirDiff` class to compare the files or directories stored in the class variables when the "Compare to 'filename'" option is selected.


Step 3: 🔁 Code Review

Here are my self-reviews of my changes at sweep/compare-files-with-different-names.

Here is the 1st review

Thanks for your contribution. There are a few changes that need to be made:
  1. In meld/dirdiff.py, the select_left_file_to_compare and select_right_file_to_compare methods are connected to the "activate" signal of the menu items, but these methods expect a pane argument which is not provided by the "activate" signal. This will cause a TypeError when the menu items are activated. You need to modify these methods to not require the pane argument.

  2. The compare_selected_files method is trying to get an iterator from the file paths stored in self.left_file_to_compare and self.right_file_to_compare using the get_iter method of the model. However, the get_iter method expects a TreePath or a string that represents a TreePath, not a file path. This will cause a ValueError. You need to find a way to convert the file paths to TreePaths.

  3. The "Compare to 'filename'" menu item is always added to the context menu, even when no file or directory has been selected for comparison. This could confuse the user as clicking this menu item without selecting a file or directory for comparison will do nothing. You should add a condition to only add this menu item when a file or directory has been selected for comparison.

  4. The left_file_to_compare and right_file_to_compare variables are not initialized in the DirDiff class. If the action_diff method is called before these variables are set, it will cause an AttributeError. You should initialize these variables in the __init__ method of the DirDiff class.

Please make these changes and submit a new pull request.

I finished incorporating these changes.


🎉 Latest improvements to Sweep:

  • Sweep can now passively improve your repository! Check out Rules to learn more.

💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant