Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
types/model: export ParseNameBare and Merge (#3957)
Blake Mizeranyb1390a7b37dc
diff --git a/types/model/name.go b/types/model/name.goindex 09895b1f0..991fdc828 100644--- a/types/model/name.go+++ b/types/model/name.go@@ -132,11 +132,12 @@ type Name struct {// field values are left in an undefined state. Use [Name.IsValid] to check// if the name is valid.func ParseName(s string) Name {- return merge(parseName(s), DefaultName())+ return Merge(ParseNameBare(s), DefaultName())}-// parseName is the same as [ParseName] without a merge.-func parseName(s string) Name {+// ParseNameBare parses s as a name string and returns a Name. No merge with+// [DefaultName] is performed.+func ParseNameBare(s string) Name {var n Namevar promised bool@@ -161,9 +162,9 @@ func parseName(s string) Name {return n}-// merge merges the host, namespace, and tag parts of the two names,+// Merge merges the host, namespace, and tag parts of the two names,// preferring the non-empty parts of a.-func merge(a, b Name) Name {+func Merge(a, b Name) Name {a.Host = cmp.Or(a.Host, b.Host)a.Namespace = cmp.Or(a.Namespace, b.Namespace)a.Tag = cmp.Or(a.Tag, b.Tag)diff --git a/types/model/name_test.go b/types/model/name_test.goindex 81e9d44c7..81de0acab 100644--- a/types/model/name_test.go+++ b/types/model/name_test.go@@ -93,7 +93,7 @@ func TestParseNameParts(t *testing.T) {for _, tt := range cases {t.Run(tt.in, func(t *testing.T) {- got := parseName(tt.in)+ got := ParseNameBare(tt.in)if !reflect.DeepEqual(got, tt.want) {t.Errorf("parseName(%q) = %v; want %v", tt.in, got, tt.want)}@@ -166,7 +166,7 @@ func TestNameparseNameDefault(t *testing.T) {func TestNameIsValid(t *testing.T) {var numStringTests intfor s, want := range testCases {- n := parseName(s)+ n := ParseNameBare(s)t.Logf("n: %#v", n)got := n.IsValid()if got != want {@@ -175,7 +175,7 @@ func TestNameIsValid(t *testing.T) {// Test roundtrip with Stringif got {- got := parseName(s).String()+ got := ParseNameBare(s).String()if got != s {t.Errorf("parseName(%q).String() = %q; want %q", s, got, s)}@@ -221,7 +221,7 @@ func FuzzName(f *testing.F) {f.Add(s)}f.Fuzz(func(t *testing.T, s string) {- n := parseName(s)+ n := ParseNameBare(s)if n.IsValid() {parts := [...]string{n.Host, n.Namespace, n.Model, n.Tag, n.RawDigest}for _, part := range parts {