Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
distribution/reference/helpers.go /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
42 lines (37 sloc)
1.11 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package reference | |
| import "path" | |
| // 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() | |
| } | |
| // FamiliarMatch reports whether ref matches the specified pattern. | |
| // See [path.Match] for supported patterns. | |
| func FamiliarMatch(pattern string, ref Reference) (bool, error) { | |
| matched, err := path.Match(pattern, FamiliarString(ref)) | |
| if namedRef, isNamed := ref.(Named); isNamed && !matched { | |
| matched, _ = path.Match(pattern, FamiliarName(namedRef)) | |
| } | |
| return matched, err | |
| } |