Skip to content

Commit 76e2b3a

Browse files
committed
rename parent_directory_path field to parent_path
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
1 parent 393cf0f commit 76e2b3a

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
@@ -2686,7 +2686,7 @@ class CodebaseResource(
26862686
),
26872687
)
26882688

2689-
parent_directory_path = models.CharField(
2689+
parent_path = models.CharField(
26902690
max_length=2000,
26912691
null=True,
26922692
blank=True,
@@ -2783,7 +2783,7 @@ class Meta:
27832783
models.Index(fields=["compliance_alert"]),
27842784
models.Index(fields=["is_binary"]),
27852785
models.Index(fields=["is_text"]),
2786-
models.Index(fields=["project", "parent_directory_path"]),
2786+
models.Index(fields=["project", "parent_path"]),
27872787
]
27882788
constraints = [
27892789
models.UniqueConstraint(
@@ -2797,8 +2797,8 @@ def __str__(self):
27972797
return self.path
27982798

27992799
def save(self, *args, **kwargs):
2800-
if self.path and not self.parent_directory_path:
2801-
self.parent_directory_path = parent_directory(
2800+
if self.path and not self.parent_path:
2801+
self.parent_path = parent_directory(
28022802
str(self.path), with_trail=False
28032803
)
28042804
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
@@ -1593,15 +1593,15 @@ def test_scanpipe_codebase_resource_model_compliance_alert_update_fields(self):
15931593
# Reset the index value
15941594
scanpipe_app.license_policies_index = None
15951595

1596-
def test_scanpipe_codebase_root_parent_directory_path(self):
1596+
def test_scanpipe_codebase_root_parent_path(self):
15971597
resource1 = self.project1.codebaseresources.create(path="file")
15981598

1599-
self.assertEqual("", resource1.parent_directory_path)
1599+
self.assertEqual("", resource1.parent_path)
16001600

1601-
def test_scanpipe_codebase_regular_parent_directory_path(self):
1601+
def test_scanpipe_codebase_regular_parent_path(self):
16021602
resource2 = self.project1.codebaseresources.create(path="dir1/dir2/file")
16031603

1604-
self.assertEqual("dir1/dir2", resource2.parent_directory_path)
1604+
self.assertEqual("dir1/dir2", resource2.parent_path)
16051605

16061606
def test_scanpipe_scan_fields_model_mixin_methods(self):
16071607
expected = [

scanpipe/tests/test_pipelines.py

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

879879
top_level_resources = project1.codebaseresources.filter(
880-
parent_directory_path=None
880+
parent_path=None
881881
)
882882
top_level_paths = [res.path for res in top_level_resources]
883883

884884
self.assertListEqual(top_level_paths, expected_top_level_paths)
885885

886-
def test_scanpipe_scan_codebase_creates_parent_directory_path_field(self):
886+
def test_scanpipe_scan_codebase_creates_parent_path_field(self):
887887
pipeline_name = "scan_codebase"
888888
project1 = make_project()
889889

@@ -905,14 +905,14 @@ def test_scanpipe_scan_codebase_creates_parent_directory_path_field(self):
905905
]
906906

907907
top_level_resources = project1.codebaseresources.filter(
908-
parent_directory_path=None
908+
parent_path=None
909909
)
910910
top_level_paths = [res.path for res in top_level_resources]
911911

912912
self.assertListEqual(top_level_paths, expected_top_level_paths)
913913

914914
nested_resources = project1.codebaseresources.filter(
915-
parent_directory_path="is-npm-1.0.0.tgz-extract/package"
915+
parent_path="is-npm-1.0.0.tgz-extract/package"
916916
)
917917
nested_paths = [res.path for res in nested_resources]
918918

0 commit comments

Comments
 (0)