63cb8cf23b
The NormalizedNamed interface has shown to not be necessary for integrating the change downstream. The FamiliarName and FamiliarString helpers are the only used interface and allow hiding the normalized completely. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
30 lines
735 B
Go
30 lines
735 B
Go
package reference
|
|
|
|
// IsNameOnly returns true if reference only contains a repo name.
|
|
func IsNameOnly(ref Named) bool {
|
|
if _, ok := ref.(NamedTagged); ok {
|
|
return false
|
|
}
|
|
if _, ok := ref.(Canonical); ok {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// FamiliarName returns the familiar name string
|
|
// for the given named, familiarizing if needed.
|
|
func FamiliarName(ref Named) string {
|
|
if nn, ok := ref.(normalizedNamed); ok {
|
|
return nn.Familiar().Name()
|
|
}
|
|
return ref.Name()
|
|
}
|
|
|
|
// FamiliarString returns the familiar string representation
|
|
// for the given reference, familiarizing if needed.
|
|
func FamiliarString(ref Reference) string {
|
|
if nn, ok := ref.(normalizedNamed); ok {
|
|
return nn.Familiar().String()
|
|
}
|
|
return ref.String()
|
|
}
|