Skip to content

Commit 8476d63

Browse files
committed
rename parent_directory_path field to parent_path
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
1 parent 474ce17 commit 8476d63

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

scanpipe/migrations/0073_codebaseresource_parent_directory_path_and_more.py renamed to scanpipe/migrations/0073_codebaseresource_parent_path_and_more.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 5.1.9 on 2025-06-14 10:11
1+
# Generated by Django 5.1.9 on 2025-06-16 17:42
22

33
from django.db import migrations, models
44

@@ -12,11 +12,11 @@ class Migration(migrations.Migration):
1212
operations = [
1313
migrations.AddField(
1414
model_name='codebaseresource',
15-
name='parent_directory_path',
15+
name='parent_path',
1616
field=models.CharField(blank=True, help_text='Path of the immediate parent directory of a resource. For top level resources the value is set to None', max_length=2000, null=True),
1717
),
1818
migrations.AddIndex(
1919
model_name='codebaseresource',
20-
index=models.Index(fields=['project', 'parent_directory_path'], name='scanpipe_co_project_f4a24b_idx'),
20+
index=models.Index(fields=['project', 'parent_path'], name='scanpipe_co_project_008448_idx'),
2121
),
2222
]

scanpipe/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,7 @@ class CodebaseResource(
26962696
),
26972697
)
26982698

2699-
parent_directory_path = models.CharField(
2699+
parent_path = models.CharField(
27002700
max_length=2000,
27012701
null=True,
27022702
blank=True,
@@ -2799,7 +2799,7 @@ class Meta:
27992799
models.Index(fields=["compliance_alert"]),
28002800
models.Index(fields=["is_binary"]),
28012801
models.Index(fields=["is_text"]),
2802-
models.Index(fields=["project", "parent_directory_path"]),
2802+
models.Index(fields=["project", "parent_path"]),
28032803
]
28042804
constraints = [
28052805
models.UniqueConstraint(
@@ -2813,8 +2813,8 @@ def __str__(self):
28132813
return self.path
28142814

28152815
def save(self, *args, **kwargs):
2816-
if self.path and not self.parent_directory_path:
2817-
self.parent_directory_path = parent_directory(
2816+
if self.path and not self.parent_path:
2817+
self.parent_path = parent_directory(
28182818
str(self.path), with_trail=False
28192819
)
28202820
super().save(*args, **kwargs)

scanpipe/pipes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def make_codebase_resource(project, location, save=True, **extra_fields):
9696
codebase_resource = CodebaseResource(
9797
project=project,
9898
path=relative_path,
99-
parent_directory_path=parent_path,
99+
parent_path=parent_path,
100100
**resource_data,
101101
)
102102

scanpipe/tests/test_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,15 +1645,15 @@ def test_scanpipe_can_compute_compliance_alert_for_license_exceptions(self):
16451645
resource.update(detected_license_expression=license_expression)
16461646
self.assertEqual("warning", resource.compute_compliance_alert())
16471647

1648-
def test_scanpipe_codebase_root_parent_directory_path(self):
1648+
def test_scanpipe_codebase_root_parent_path(self):
16491649
resource1 = self.project1.codebaseresources.create(path="file")
16501650

1651-
self.assertEqual("", resource1.parent_directory_path)
1651+
self.assertEqual("", resource1.parent_path)
16521652

1653-
def test_scanpipe_codebase_regular_parent_directory_path(self):
1653+
def test_scanpipe_codebase_regular_parent_path(self):
16541654
resource2 = self.project1.codebaseresources.create(path="dir1/dir2/file")
16551655

1656-
self.assertEqual("dir1/dir2", resource2.parent_directory_path)
1656+
self.assertEqual("dir1/dir2", resource2.parent_path)
16571657

16581658
def test_scanpipe_scan_fields_model_mixin_methods(self):
16591659
expected = [

scanpipe/tests/test_pipelines.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,13 +880,13 @@ def test_scanpipe_scan_codebase_creates_top_level_paths(self):
880880
expected_top_level_paths = ["is-npm-1.0.0.tgz", "is-npm-1.0.0.tgz-extract"]
881881

882882
top_level_resources = project1.codebaseresources.filter(
883-
parent_directory_path=None
883+
parent_path=None
884884
)
885885
top_level_paths = [res.path for res in top_level_resources]
886886

887887
self.assertListEqual(top_level_paths, expected_top_level_paths)
888888

889-
def test_scanpipe_scan_codebase_creates_parent_directory_path_field(self):
889+
def test_scanpipe_scan_codebase_creates_parent_path_field(self):
890890
pipeline_name = "scan_codebase"
891891
project1 = make_project()
892892

@@ -908,14 +908,14 @@ def test_scanpipe_scan_codebase_creates_parent_directory_path_field(self):
908908
]
909909

910910
top_level_resources = project1.codebaseresources.filter(
911-
parent_directory_path=None
911+
parent_path=None
912912
)
913913
top_level_paths = [res.path for res in top_level_resources]
914914

915915
self.assertListEqual(top_level_paths, expected_top_level_paths)
916916

917917
nested_resources = project1.codebaseresources.filter(
918-
parent_directory_path="is-npm-1.0.0.tgz-extract/package"
918+
parent_path="is-npm-1.0.0.tgz-extract/package"
919919
)
920920
nested_paths = [res.path for res in nested_resources]
921921

0 commit comments

Comments
 (0)