sweepai / sweep

Sweep: open-source AI-powered Software Developer for small features and bug fixes.
https://sweep.dev
Other
7.46k stars 428 forks source link

Sweep: If Sweep edits a file to be completely empty, delete it in the pull request #498

Open wwzeng1 opened 1 year ago

wwzeng1 commented 1 year ago

Description

Do this in create_pr

Relevant files

No response

sweep-nightly[bot] commented 1 year ago

Here's the PR! https://github.com/sweepai/sweep/pull/499.

To create this ticket, I used gpt-4. You have 25 gpt-4 tickets left.


Step 1: 🔍 Code Search

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. https://github.com/sweepai/sweep/blob/fbd13c47faff07dfa4728b1eaadc516a477f555a/sweepai/handlers/on_comment.py#L144-L260 https://github.com/sweepai/sweep/blob/fbd13c47faff07dfa4728b1eaadc516a477f555a/README.md#L1-L99 https://github.com/sweepai/sweep/blob/fbd13c47faff07dfa4728b1eaadc516a477f555a/sweepai/handlers/create_pr.py#L1-L203 https://github.com/sweepai/sweep/blob/fbd13c47faff07dfa4728b1eaadc516a477f555a/sweepai/app/ui.py#L1-L186 https://github.com/sweepai/sweep/blob/fbd13c47faff07dfa4728b1eaadc516a477f555a/sweepai/handlers/on_ticket.py#L309-L477

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
sweepai/handlers/create_pr.py In the create_pr function, add a check to see if any of the files in file_change_requests are empty after Sweep's edits. If a file is empty, delete it from the repository.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Fix: Delete file if it is empty in create_pr sweep/fix/delete-empty-file

Description

This PR fixes the issue where a file is deleted if it is empty after Sweep's edits in the create_pr function.

Changes Made

  • Added logic to check if any of the files in file_change_requests are empty after Sweep's edits.
  • If a file is empty, it is deleted from the repository.

Files Modified

  • sweepai/handlers/create_pr.py

How to Test

  1. Checkout the branch fix/delete-empty-file
  2. Run the tests to ensure the changes are working as expected.

Checklist

  • [ ] Tested the changes locally
  • [ ] Updated the documentation if necessary
  • [ ] Reviewed the code changes

Please review and merge this PR. Thank you!


Step 4: ⌨️ Coding

I have finished coding the issue. I am now reviewing it for completeness.


Step 5: 🔁 Code Review

Success! 🚀


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind! Join Our Discord