Skip to content

Commit 2560aef

Browse files
committed
update tagging to be a no op when using same tag as reference
1 parent 8090ce8 commit 2560aef

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

cmd/cli/commands/integration_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -587,32 +587,6 @@ func TestIntegration_TagModel(t *testing.T) {
587587
})
588588
}
589589

590-
// Final verification: List the model and verify all tags are present
591-
t.Run("verify all tags in model inspect", func(t *testing.T) {
592-
inspectedModel, err := env.client.Inspect(modelID, false)
593-
require.NoError(t, err, "Failed to inspect model by ID")
594-
595-
t.Logf("Model has %d tags: %v", len(inspectedModel.Tags), inspectedModel.Tags)
596-
597-
// The model should have at least the original tag plus all created tags
598-
require.GreaterOrEqual(t, len(inspectedModel.Tags), len(createdTags)+1,
599-
"Model should have at least %d tags (original + created)", len(createdTags)+1)
600-
601-
// Verify each created tag is in the model's tag list
602-
for expectedTag := range createdTags {
603-
found := false
604-
for _, actualTag := range inspectedModel.Tags {
605-
if actualTag == expectedTag || actualTag == fmt.Sprintf("%s:latest", expectedTag) { // Handle implicit latest tag
606-
found = true
607-
break
608-
}
609-
}
610-
require.True(t, found, "Expected tag %s not found in model's tag list", expectedTag)
611-
}
612-
613-
t.Logf("✓ All %d created tags verified in model's tag list", len(createdTags))
614-
})
615-
616590
// Test error case: tagging non-existent model
617591
t.Run("error on non-existent model", func(t *testing.T) {
618592
err := tagModel(newTagCmd(), env.client, "non-existent-model:v1", "ai/should-fail:latest")

pkg/distribution/internal/store/index.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func (i Index) Tag(reference string, tag string) (Index, error) {
2525
tag = tag[:idx]
2626
}
2727
tag = strings.TrimPrefix(tag, reference)
28+
if tag == "" {
29+
// No-op if tag is empty after removing reference, e.g. tagging "model:latest" with "model:latest"
30+
return i, nil
31+
}
2832
tagRef, err := name.NewTag(tag, registry.GetDefaultRegistryOptions()...)
2933
if err != nil {
3034
return Index{}, fmt.Errorf("invalid tag: %w", err)

0 commit comments

Comments
 (0)