x/model: clarify Merge semantics
This commit is contained in:
parent
6aa9795c4f
commit
cfe0bb6bb6
@ -175,19 +175,21 @@ func ParseName(s string) Name {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge folds the domain, namespace, tag, and build of b into a if not set.
|
// Merge performs a partial merge of dst into src. Only the non-name parts
|
||||||
// The name is left untouched.
|
// are merged. The name part is always left untouched. Other parts are
|
||||||
|
// merged if and only if they are missing in dst.
|
||||||
//
|
//
|
||||||
// Use this for merging a ref with a default ref.
|
// Use this for merging a fully qualified ref with a partial ref, such as
|
||||||
func Merge(a, b Name) Name {
|
// when filling in a missing parts with defaults.
|
||||||
|
func Merge(dst, src Name) Name {
|
||||||
return Name{
|
return Name{
|
||||||
// name is left untouched
|
// name is left untouched
|
||||||
nick: a.nick,
|
nick: dst.nick,
|
||||||
|
|
||||||
domain: cmp.Or(a.domain, b.domain),
|
domain: cmp.Or(dst.domain, src.domain),
|
||||||
namespace: cmp.Or(a.namespace, b.namespace),
|
namespace: cmp.Or(dst.namespace, src.namespace),
|
||||||
tag: cmp.Or(a.tag, b.tag),
|
tag: cmp.Or(dst.tag, src.tag),
|
||||||
build: cmp.Or(a.build, b.build),
|
build: cmp.Or(dst.build, src.build),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user