mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:11:49 +00:00
Update unified cody context to only use search when embeddings are disabled (#59360)
* update cody context to use search when embeddings are disabled * Update internal/codycontext/context.go Co-authored-by: Camden Cheek <camden@ccheek.com> * fix test by adding required embeddings config --------- Co-authored-by: Camden Cheek <camden@ccheek.com>
This commit is contained in:
parent
320cdcdd4e
commit
7f1df01d62
@ -33,10 +33,20 @@ import (
|
||||
func TestContextResolver(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
repo1 := types.Repo{Name: "repo1"}
|
||||
repo2 := types.Repo{Name: "repo2"}
|
||||
truePtr := true
|
||||
conf.Mock(&conf.Unified{
|
||||
SiteConfiguration: schema.SiteConfiguration{
|
||||
CodyEnabled: &truePtr,
|
||||
Embeddings: &schema.Embeddings{
|
||||
Provider: "sourcegraph",
|
||||
Enabled: &truePtr,
|
||||
AccessToken: "123",
|
||||
},
|
||||
},
|
||||
})
|
||||
// Create populates the IDs in the passed in types.Repo
|
||||
err := db.Repos().Create(ctx, &repo1, &repo2)
|
||||
require.NoError(t, err)
|
||||
@ -139,13 +149,6 @@ func TestContextResolver(t *testing.T) {
|
||||
contextClient,
|
||||
)
|
||||
|
||||
truePtr := true
|
||||
conf.Mock(&conf.Unified{
|
||||
SiteConfiguration: schema.SiteConfiguration{
|
||||
CodyEnabled: &truePtr,
|
||||
},
|
||||
})
|
||||
|
||||
ctx = actor.WithActor(ctx, actor.FromMockUser(1))
|
||||
ffs := featureflag.NewMemoryStore(map[string]bool{"cody": true}, nil, nil)
|
||||
ctx = featureflag.WithFlags(ctx, ffs)
|
||||
|
||||
@ -160,6 +160,10 @@ func (c *CodyContextClient) GetCodyContext(ctx context.Context, args GetContextA
|
||||
|
||||
// partitionRepos splits a set of repos into repos with embeddings and repos without embeddings
|
||||
func (c *CodyContextClient) partitionRepos(ctx context.Context, input []types.RepoIDName) (embedded, notEmbedded []types.RepoIDName, err error) {
|
||||
// if embeddings are disabled , return all repos in the notEmbedded slice
|
||||
if !conf.EmbeddingsEnabled() {
|
||||
return nil, input, nil
|
||||
}
|
||||
for _, repo := range input {
|
||||
exists, err := c.db.Repos().RepoEmbeddingExists(ctx, repo.ID)
|
||||
if err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user