Skip to content

Commit 34971e4

Browse files
committed
Add ability to sync from a git repository
fixes: #4708 Generated by: claude-opus-4.6-thinking
1 parent 86a7293 commit 34971e4

File tree

12 files changed

+866
-5
lines changed

12 files changed

+866
-5
lines changed

CHANGES/pulp_file/4708.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added ability to sync a git repository with the new FileGitRemote.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 5.2.10 on 2026-02-05 19:22
2+
3+
import django.db.models.deletion
4+
import pulpcore.app.models.access_policy
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('core', '0145_domainize_import_export'),
12+
('file', '0018_alter_filecontent_options'),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='FileGitRemote',
18+
fields=[
19+
('remote_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.remote')),
20+
('git_ref', models.TextField(default='HEAD')),
21+
],
22+
options={
23+
'permissions': [('manage_roles_filegitremote', 'Can manage roles on file git remotes')],
24+
'default_related_name': '%(app_label)s_%(model_name)s',
25+
},
26+
bases=('core.remote', pulpcore.app.models.access_policy.AutoAddObjPermsMixin),
27+
),
28+
]

pulp_file/app/models.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,33 @@ class Meta:
6262
]
6363

6464

65+
class FileGitRemote(Remote, AutoAddObjPermsMixin):
66+
"""
67+
Remote for syncing files from a Git repository (without PULP_MANIFEST).
68+
69+
The URL should point to a Git repository. The ``git_ref`` field can be used to specify a
70+
branch, tag, or commit to sync from (defaults to ``HEAD``).
71+
"""
72+
73+
TYPE = "git"
74+
75+
git_ref = models.TextField(default="HEAD")
76+
77+
class Meta:
78+
default_related_name = "%(app_label)s_%(model_name)s"
79+
permissions = [
80+
("manage_roles_filegitremote", "Can manage roles on file git remotes"),
81+
]
82+
83+
6584
class FileRepository(Repository, AutoAddObjPermsMixin):
6685
"""
6786
The "file" repository type.
6887
"""
6988

7089
TYPE = "file"
7190
CONTENT_TYPES = [FileContent]
72-
REMOTE_TYPES = [FileRemote]
91+
REMOTE_TYPES = [FileRemote, FileGitRemote]
7392

7493
manifest = models.TextField(default="PULP_MANIFEST", null=True)
7594
autopublish = models.BooleanField(default=False)

pulp_file/app/serializers.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
FileAlternateContentSource,
2525
FileContent,
2626
FileDistribution,
27+
FileGitRemote,
2728
FileRemote,
2829
FileRepository,
2930
FilePublication,
@@ -160,6 +161,26 @@ class Meta:
160161
model = FileRemote
161162

162163

164+
class FileGitRemoteSerializer(RemoteSerializer):
165+
"""
166+
Serializer for File Git Remotes.
167+
"""
168+
169+
git_ref = serializers.CharField(
170+
help_text=_(
171+
"The git ref (branch, tag, or commit hash) to sync from. Defaults to HEAD."
172+
),
173+
default="HEAD",
174+
required=False,
175+
)
176+
177+
policy = serializers.HiddenField(default=models.Remote.IMMEDIATE)
178+
179+
class Meta:
180+
fields = RemoteSerializer.Meta.fields + ("git_ref",)
181+
model = FileGitRemote
182+
183+
163184
class FilePublicationSerializer(PublicationSerializer):
164185
"""
165186
Serializer for File Publications.

0 commit comments

Comments
 (0)