Skip to content

Commit 61ce14f

Browse files
committed
Add repair-metadata command for Python repos
closes #1340 Assisted by: Claude Sonnet 4
1 parent 138d055 commit 61ce14f

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

CHANGES/1340.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `repair-metadata` command to `pulp python repository` for repairing package metadata.

CHANGES/pulp-glue/1340.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `repair_metadata` method to `PulpPythonRepositoryContext` for `pulp_python>=3.26.0`.

pulp-glue/src/pulp_glue/python/context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class PulpPythonRepositoryContext(PulpRepositoryContext):
150150
CAPABILITIES = {
151151
"sync": [PluginRequirement("python")],
152152
"pulpexport": [PluginRequirement("python", specifier=">=3.11.0")],
153+
"repair_metadata": [PluginRequirement("python", specifier=">=3.26.0")],
153154
}
154155
NEEDS_PLUGINS = [PluginRequirement("python", specifier=">=3.1.0")]
155156

@@ -158,3 +159,7 @@ def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> En
158159
if "autopublish" in body:
159160
self.pulp_ctx.needs_plugin(PluginRequirement("python", specifier=">=3.3.0"))
160161
return body
162+
163+
def repair_metadata(self) -> t.Any:
164+
self.needs_capability("repair_metadata")
165+
return self.call("repair_metadata", parameters={self.HREF: self.pulp_href})

src/pulpcore/cli/python/repository.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,24 @@ def sync(
183183
)
184184

185185
repository_ctx.sync(body=body)
186+
187+
188+
@repository.command()
189+
@name_option
190+
@href_option
191+
@repository_lookup_option
192+
@pass_repository_context
193+
@pass_pulp_context
194+
def repair_metadata(
195+
pulp_ctx: PulpCLIContext,
196+
repository_ctx: PulpRepositoryContext,
197+
/,
198+
) -> None:
199+
"""
200+
Repair the metadata for all immediate and on-demand packages in the latest version
201+
of the specified repository. For immediate wheel packages, also repair metadata
202+
artifacts derived from the main artifact.
203+
"""
204+
assert isinstance(repository_ctx, PulpPythonRepositoryContext)
205+
result = repository_ctx.repair_metadata()
206+
pulp_ctx.output_result(result)

tests/scripts/pulp_python/test_repository.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ expect_succ test "$(echo "$OUTPUT" | jq -r '.remote')" = ""
3232
expect_succ pulp python repository list
3333
test "$(echo "$OUTPUT" | jq -r '.|length')" != "0"
3434

35+
if pulp debug has-plugin --name "python" --specifier ">=3.26.0"; then
36+
expect_succ pulp python repository repair-metadata --repository "cli_test_python_repo"
37+
expect_succ test "$(echo "$OUTPUT" | jq -r '.state')" = "completed"
38+
fi
39+
3540
expect_succ pulp python repository destroy --name "cli_test_python_repo"

0 commit comments

Comments
 (0)