Skip to content

Commit ecb4ab6

Browse files
committed
rename ancestor field to parent_directory_path
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
1 parent e417f9d commit ecb4ab6

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

scanpipe/migrations/0073_codebaseresource_ancestor_and_more.py

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 5.1.9 on 2025-06-14 10:11
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('scanpipe', '0072_discovereddependency_uuid_unique'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='codebaseresource',
15+
name='parent_directory_path',
16+
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),
17+
),
18+
migrations.AddIndex(
19+
model_name='codebaseresource',
20+
index=models.Index(fields=['project', 'parent_directory_path'], name='scanpipe_co_project_f4a24b_idx'),
21+
),
22+
]

scanpipe/models.py

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

2699-
ancestor = models.CharField(
2699+
parent_directory_path = models.CharField(
27002700
max_length=2000,
27012701
null=True,
27022702
blank=True,
27032703
help_text=_(
27042704
"Path of the immediate parent directory of a resource. "
2705-
"For top level resources the value is '.'"
2705+
"For top level resources the value is set to None"
27062706
),
27072707
)
27082708

@@ -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", "ancestor"]),
2802+
models.Index(fields=["project", "parent_directory_path"]),
28032803
]
28042804
constraints = [
28052805
models.UniqueConstraint(

scanpipe/pipes/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def make_codebase_resource(project, location, save=True, **extra_fields):
7272

7373
relative_path = Path(location).relative_to(project.codebase_path)
7474
parent_path = str(relative_path.parent)
75+
76+
if parent_path == ".":
77+
parent_path = None
78+
7579
try:
7680
resource_data = scancode.get_resource_info(location=str(location))
7781
except OSError as error:
@@ -92,7 +96,7 @@ def make_codebase_resource(project, location, save=True, **extra_fields):
9296
codebase_resource = CodebaseResource(
9397
project=project,
9498
path=relative_path,
95-
ancestor=parent_path,
99+
parent_directory_path=parent_path,
96100
**resource_data,
97101
)
98102

0 commit comments

Comments
 (0)