Skip to content

Commit

Permalink
rules: fix migrations to be able to run utests locally
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicold authored and pevma committed Apr 10, 2024
1 parent 516a1ba commit a0f78fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rules/migrations/0102_auto_20230626_1624.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ def migration_2(apps, _):
ruleset = Ruleset.objects.get(pk=ruleset_pk)
ruleset.sources.set(Source.objects.filter(pk__in=sources_pk))

if not os.path.exists(settings.GIT_SOURCES_BASE_DIRECTORY):
return

# remove git directories
for item in os.listdir(settings.GIT_SOURCES_BASE_DIRECTORY):
full_path = os.path.join(settings.GIT_SOURCES_BASE_DIRECTORY, item)
if os.path.isdir(full_path) and item.isdigit():
git_path = os.path.join(full_path, '.git')
shutil.rmtree(git_path)
if os.path.exists(git_path):
shutil.rmtree(git_path, ignore_errors=True)


class Migration(migrations.Migration):
Expand Down

0 comments on commit a0f78fc

Please sign in to comment.