Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create command to remove unused data by checking existing code #493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cristianowa
Copy link

This PR is related to the issue #492 .

The idea behind it is that in some cases the switches/flags/samples can be automatically removed by checking if they are present in the source code.

Parsing the code for that is implemented directly in Python using the standard lib to maximize compatibility.

The default behavior is to ask for a confirmation in each flag, but there is an override.

I've also checked the messages ./run.sh makemessages and there were no new ones, so I didn't updated those files.

def expression_exists(expression):
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
if not (file.endswith(".py") or file.endswith(".html")): #TODO: make this a list of extensions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you going to do this? Perhaps allow them to be passed in as an optional argument?

@@ -329,3 +329,44 @@ def test_delete_some_but_not_all_records(self):

call_command('waffle_delete', flag_names=[flag_1])
self.assertTrue(get_waffle_flag_model().objects.filter(name=flag_2).exists())


class WaffleDeleteUnused(TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests aren't really testing the desired behavior—deleting flags. Consider updating the command to take a file path of code to search, and passing that in the test calls to confirm items are deleted.

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

Successfully merging this pull request may close these issues.

2 participants