search: fix repogroups and introduce types for repogroup values
Created by: rvantonder
Fixes https://github.com/sourcegraph/sourcegraph/issues/13947. https://github.com/sourcegraph/sourcegraph/pull/13730 removed the part where we use a repogroup label to get the list of repo values. Part of the problem there is that the repogroup map of label -> value
was separated from regex patterns, so that regex patterns were not considered a proper value of the repogroup
map. This has janky implicit effects that are alleviated by introducing a variant type for the value
in the label -> value
mapping:
-
our RepoGroups resolver returns repo names associated with a repogroup mapping. Since it doesn't support returning regex patterns associated with a repogroup, this was just implicitly ignored. We should decide on what an acceptable contract is here, either of: (1) returning the set of values, whether repo path or regex patterns associated with a repogroup, or (2) resolving repos associated with regex patterns and returning the set of repo paths. If (1), the return type of the RepoGroups resolver needs to change. If (2), we need to add logic that resolves the regular expressions to valid repo names. Again, this was implicitly ignored in the previous PR, so I will not attempt to address it here. But, the new
RepoGroupValue
type alleviates this and makes the issue explicit, forcing the code to consider how to handle regex-pattern values in this resolver code (see the TODO comment). -
needing to handle a tuple of return values and ignores these based on context. With the the value type, we keep one return value and case out on the map values based on context.
-
we previously wrapped the values in a
*types.Repo
struct but only ever populated (and used) theName
string entry for this data type. This seems unnecessary. Now we use theRepoGroupValue
with string variants.