weshouman / meld

Read-only mirror of https://gitlab.gnome.org/GNOME/meld
https://gitlab.gnome.org/GNOME/meld
GNU General Public License v2.0
0 stars 0 forks source link

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

Open weshouman opened 1 year ago

weshouman commented 1 year ago

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 - [X] ``meld/dirdiff.py`` ✅ Commit 3447ab7
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/weshouman/meld/pull/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)


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


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:


💡 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