mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
codeintel: Reorganize types (#42847)
This commit is contained in:
parent
6af4e4a0f3
commit
21c49c855e
@ -4,12 +4,19 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/regexp"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/dependencies"
|
||||
policies "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
codeinteltypes "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
"github.com/sourcegraph/sourcegraph/internal/repoupdater/protocol"
|
||||
"github.com/sourcegraph/sourcegraph/internal/types"
|
||||
"github.com/sourcegraph/sourcegraph/lib/codeintel/autoindex/config"
|
||||
"github.com/sourcegraph/sourcegraph/lib/codeintel/precise"
|
||||
)
|
||||
|
||||
@ -18,7 +25,7 @@ type DependenciesService interface {
|
||||
}
|
||||
|
||||
type PoliciesService interface {
|
||||
GetConfigurationPolicies(ctx context.Context, opts codeinteltypes.GetConfigurationPoliciesOptions) ([]codeinteltypes.ConfigurationPolicy, int, error)
|
||||
GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) ([]codeinteltypes.ConfigurationPolicy, int, error)
|
||||
}
|
||||
|
||||
type ReposStore interface {
|
||||
@ -42,3 +49,36 @@ type AutoIndexingServiceForDepScheduling interface {
|
||||
type PolicyMatcher interface {
|
||||
CommitsDescribedByPolicyInternal(ctx context.Context, repositoryID int, policies []codeinteltypes.ConfigurationPolicy, now time.Time, filterCommits ...string) (map[string][]policies.PolicyMatch, error)
|
||||
}
|
||||
|
||||
type RepoUpdaterClient interface {
|
||||
RepoLookup(ctx context.Context, args protocol.RepoLookupArgs) (*protocol.RepoLookupResult, error)
|
||||
EnqueueRepoUpdate(ctx context.Context, repo api.RepoName) (*protocol.RepoUpdateResponse, error)
|
||||
}
|
||||
|
||||
type GitserverClient interface {
|
||||
Head(ctx context.Context, repositoryID int) (string, bool, error)
|
||||
CommitExists(ctx context.Context, repositoryID int, commit string) (bool, error)
|
||||
ListFiles(ctx context.Context, repositoryID int, commit string, pattern *regexp.Regexp) ([]string, error)
|
||||
FileExists(ctx context.Context, repositoryID int, commit, file string) (bool, error)
|
||||
RawContents(ctx context.Context, repositoryID int, commit, file string) ([]byte, error)
|
||||
ResolveRevision(ctx context.Context, repositoryID int, versionString string) (api.CommitID, error)
|
||||
ListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
|
||||
CommitDate(ctx context.Context, repositoryID int, commit string) (string, time.Time, bool, error)
|
||||
RefDescriptions(ctx context.Context, repositoryID int, gitOjbs ...string) (map[string][]gitdomain.RefDescription, error)
|
||||
CommitsUniqueToBranch(ctx context.Context, repositoryID int, branchName string, isDefaultBranch bool, maxAge *time.Time) (map[string]time.Time, error)
|
||||
}
|
||||
|
||||
type InferenceService interface {
|
||||
InferIndexJobs(ctx context.Context, repo api.RepoName, commit, overrideScript string) ([]config.IndexJob, error)
|
||||
InferIndexJobHints(ctx context.Context, repo api.RepoName, commit, overrideScript string) ([]config.IndexJobHint, error)
|
||||
}
|
||||
|
||||
type UploadService interface {
|
||||
GetRepoName(ctx context.Context, repositoryID int) (_ string, err error) // upload service
|
||||
GetDirtyRepositories(ctx context.Context) (_ map[int]int, err error) // upload service
|
||||
GetUploadsByIDs(ctx context.Context, ids ...int) (_ []codeinteltypes.Upload, err error) // upload service
|
||||
GetUploadByID(ctx context.Context, id int) (codeinteltypes.Upload, bool, error)
|
||||
ReferencesForUpload(ctx context.Context, uploadID int) (shared.PackageReferenceScanner, error)
|
||||
GetRepositoriesForIndexScan(ctx context.Context, table, column string, processDelay time.Duration, allowGlobalPolicies bool, repositoryMatchLimit *int, limit int, now time.Time) (_ []int, err error)
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
backgroundjobs "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/background"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/inference"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/store"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/memo"
|
||||
"github.com/sourcegraph/sourcegraph/internal/observation"
|
||||
@ -18,10 +17,10 @@ import (
|
||||
// If the service is not yet initialized, it will use the provided dependencies.
|
||||
func GetService(
|
||||
db database.DB,
|
||||
uploadSvc shared.UploadService,
|
||||
uploadSvc UploadService,
|
||||
depsSvc DependenciesService,
|
||||
policiesSvc PoliciesService,
|
||||
gitserver shared.GitserverClient,
|
||||
gitserver GitserverClient,
|
||||
) *Service {
|
||||
svc, _ := initServiceMemo.Init(serviceDependencies{
|
||||
db,
|
||||
@ -36,10 +35,10 @@ func GetService(
|
||||
|
||||
type serviceDependencies struct {
|
||||
db database.DB
|
||||
uploadSvc shared.UploadService
|
||||
uploadSvc UploadService
|
||||
depsSvc DependenciesService
|
||||
policiesSvc PoliciesService
|
||||
gitserver shared.GitserverClient
|
||||
gitserver GitserverClient
|
||||
}
|
||||
|
||||
var initServiceMemo = memo.NewMemoizedConstructorWithArg(func(deps serviceDependencies) (*Service, error) {
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
"github.com/sourcegraph/log"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/store"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/goroutine"
|
||||
"github.com/sourcegraph/sourcegraph/internal/observation"
|
||||
@ -38,14 +37,14 @@ type BackgroundJob interface {
|
||||
}
|
||||
|
||||
type backgroundJob struct {
|
||||
uploadSvc shared.UploadService
|
||||
uploadSvc UploadService
|
||||
depsSvc DependenciesService
|
||||
policiesSvc PoliciesService
|
||||
autoindexingSvc AutoIndexingService
|
||||
|
||||
policyMatcher PolicyMatcher
|
||||
repoUpdater shared.RepoUpdaterClient
|
||||
gitserverClient shared.GitserverClient
|
||||
repoUpdater RepoUpdaterClient
|
||||
gitserverClient GitserverClient
|
||||
|
||||
store store.Store
|
||||
repoStore ReposStore
|
||||
@ -68,12 +67,12 @@ type backgroundJob struct {
|
||||
func New(
|
||||
db database.DB,
|
||||
store store.Store,
|
||||
uploadSvc shared.UploadService,
|
||||
uploadSvc UploadService,
|
||||
depsSvc DependenciesService,
|
||||
policiesSvc PoliciesService,
|
||||
policyMatcher PolicyMatcher,
|
||||
gitserverClient shared.GitserverClient,
|
||||
repoUpdater shared.RepoUpdaterClient,
|
||||
gitserverClient GitserverClient,
|
||||
repoUpdater RepoUpdaterClient,
|
||||
observationContext *observation.Context,
|
||||
) BackgroundJob {
|
||||
repoStore := db.Repos()
|
||||
|
||||
@ -4,12 +4,19 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/regexp"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/dependencies"
|
||||
policies "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
codeinteltypes "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
"github.com/sourcegraph/sourcegraph/internal/repoupdater/protocol"
|
||||
"github.com/sourcegraph/sourcegraph/internal/types"
|
||||
"github.com/sourcegraph/sourcegraph/lib/codeintel/autoindex/config"
|
||||
"github.com/sourcegraph/sourcegraph/lib/codeintel/precise"
|
||||
)
|
||||
|
||||
@ -35,7 +42,7 @@ type PolicyMatcher interface {
|
||||
}
|
||||
|
||||
type PoliciesService interface {
|
||||
GetConfigurationPolicies(ctx context.Context, opts codeinteltypes.GetConfigurationPoliciesOptions) ([]codeinteltypes.ConfigurationPolicy, int, error)
|
||||
GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) ([]codeinteltypes.ConfigurationPolicy, int, error)
|
||||
}
|
||||
|
||||
type AutoIndexingService interface {
|
||||
@ -43,3 +50,36 @@ type AutoIndexingService interface {
|
||||
QueueIndexesForPackage(ctx context.Context, pkg precise.Package) (err error)
|
||||
InsertDependencyIndexingJob(ctx context.Context, uploadID int, externalServiceKind string, syncTime time.Time) (id int, err error)
|
||||
}
|
||||
|
||||
type RepoUpdaterClient interface {
|
||||
RepoLookup(ctx context.Context, args protocol.RepoLookupArgs) (*protocol.RepoLookupResult, error)
|
||||
EnqueueRepoUpdate(ctx context.Context, repo api.RepoName) (*protocol.RepoUpdateResponse, error)
|
||||
}
|
||||
|
||||
type GitserverClient interface {
|
||||
Head(ctx context.Context, repositoryID int) (string, bool, error)
|
||||
CommitExists(ctx context.Context, repositoryID int, commit string) (bool, error)
|
||||
ListFiles(ctx context.Context, repositoryID int, commit string, pattern *regexp.Regexp) ([]string, error)
|
||||
FileExists(ctx context.Context, repositoryID int, commit, file string) (bool, error)
|
||||
RawContents(ctx context.Context, repositoryID int, commit, file string) ([]byte, error)
|
||||
ResolveRevision(ctx context.Context, repositoryID int, versionString string) (api.CommitID, error)
|
||||
ListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
|
||||
CommitDate(ctx context.Context, repositoryID int, commit string) (string, time.Time, bool, error)
|
||||
RefDescriptions(ctx context.Context, repositoryID int, gitOjbs ...string) (map[string][]gitdomain.RefDescription, error)
|
||||
CommitsUniqueToBranch(ctx context.Context, repositoryID int, branchName string, isDefaultBranch bool, maxAge *time.Time) (map[string]time.Time, error)
|
||||
}
|
||||
|
||||
type InferenceService interface {
|
||||
InferIndexJobs(ctx context.Context, repo api.RepoName, commit, overrideScript string) ([]config.IndexJob, error)
|
||||
InferIndexJobHints(ctx context.Context, repo api.RepoName, commit, overrideScript string) ([]config.IndexJobHint, error)
|
||||
}
|
||||
|
||||
type UploadService interface {
|
||||
GetRepoName(ctx context.Context, repositoryID int) (_ string, err error) // upload service
|
||||
GetDirtyRepositories(ctx context.Context) (_ map[int]int, err error) // upload service
|
||||
GetUploadsByIDs(ctx context.Context, ids ...int) (_ []codeinteltypes.Upload, err error) // upload service
|
||||
GetUploadByID(ctx context.Context, id int) (codeinteltypes.Upload, bool, error)
|
||||
ReferencesForUpload(ctx context.Context, uploadID int) (shared.PackageReferenceScanner, error)
|
||||
GetRepositoriesForIndexScan(ctx context.Context, table, column string, processDelay time.Duration, allowGlobalPolicies bool, repositoryMatchLimit *int, limit int, now time.Time) (_ []int, err error)
|
||||
}
|
||||
|
||||
@ -52,13 +52,13 @@ func (b *backgroundJob) NewDependencyIndexingScheduler(pollInterval time.Duratio
|
||||
}
|
||||
|
||||
type dependencyIndexingSchedulerHandler struct {
|
||||
uploadsSvc shared.UploadService
|
||||
uploadsSvc UploadService
|
||||
repoStore ReposStore
|
||||
indexEnqueuer AutoIndexingService
|
||||
extsvcStore ExternalServiceStore
|
||||
gitserverRepoStore GitserverRepoStore
|
||||
workerStore dbworkerstore.Store
|
||||
repoUpdater shared.RepoUpdaterClient
|
||||
repoUpdater RepoUpdaterClient
|
||||
}
|
||||
|
||||
const requeueBackoff = time.Second * 30
|
||||
|
||||
@ -46,7 +46,7 @@ func (b *backgroundJob) NewDependencySyncScheduler(pollInterval time.Duration) *
|
||||
}
|
||||
|
||||
type dependencySyncSchedulerHandler struct {
|
||||
uploadsSvc shared.UploadService
|
||||
uploadsSvc UploadService
|
||||
depsSvc DependenciesService
|
||||
autoindexingSvc AutoIndexingService
|
||||
workerStore dbworkerstore.Store
|
||||
@ -231,7 +231,7 @@ func (h *dependencySyncSchedulerHandler) insertDependencyRepo(ctx context.Contex
|
||||
// shouldIndexDependencies returns true if the given upload should undergo dependency
|
||||
// indexing. Currently, we're only enabling dependency indexing for a repositories that
|
||||
// were indexed via lsif-go, scip-java, lsif-tsc and scip-typescript.
|
||||
func (h *dependencySyncSchedulerHandler) shouldIndexDependencies(ctx context.Context, store shared.UploadService, uploadID int) (bool, error) {
|
||||
func (h *dependencySyncSchedulerHandler) shouldIndexDependencies(ctx context.Context, store UploadService, uploadID int) (bool, error) {
|
||||
upload, _, err := store.GetUploadByID(ctx, uploadID)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "dbstore.GetUploadByID")
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/conf"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
"github.com/sourcegraph/sourcegraph/internal/goroutine"
|
||||
@ -80,7 +80,7 @@ func (b backgroundJob) handleRepository(ctx context.Context, repositoryID, polic
|
||||
|
||||
for {
|
||||
// Retrieve the set of configuration policies that affect indexing for this repository.
|
||||
policies, totalCount, err := b.policiesSvc.GetConfigurationPolicies(ctx, types.GetConfigurationPoliciesOptions{
|
||||
policies, totalCount, err := b.policiesSvc.GetConfigurationPolicies(ctx, policiesshared.GetConfigurationPoliciesOptions{
|
||||
RepositoryID: repositoryID,
|
||||
ForIndexing: true,
|
||||
Limit: policyBatchSize,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -26,13 +26,13 @@ type Store interface {
|
||||
|
||||
// Indexes
|
||||
InsertIndexes(ctx context.Context, indexes []types.Index) (_ []types.Index, err error)
|
||||
GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexes(ctx context.Context, opts shared.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexByID(ctx context.Context, id int) (_ types.Index, _ bool, err error)
|
||||
GetIndexesByIDs(ctx context.Context, ids ...int) (_ []types.Index, err error)
|
||||
GetRecentIndexesSummary(ctx context.Context, repositoryID int) (summaries []shared.IndexesWithRepositoryNamespace, err error)
|
||||
GetLastIndexScanForRepository(ctx context.Context, repositoryID int) (_ *time.Time, err error)
|
||||
DeleteIndexByID(ctx context.Context, id int) (_ bool, err error)
|
||||
DeleteIndexes(ctx context.Context, opts types.DeleteIndexesOptions) (err error)
|
||||
DeleteIndexes(ctx context.Context, opts shared.DeleteIndexesOptions) (err error)
|
||||
DeleteIndexesWithoutRepository(ctx context.Context, now time.Time) (_ map[int]int, err error)
|
||||
IsQueued(ctx context.Context, repositoryID int, commit string) (_ bool, err error)
|
||||
QueueRepoRev(ctx context.Context, repositoryID int, commit string) error
|
||||
|
||||
@ -89,7 +89,7 @@ RETURNING id
|
||||
`
|
||||
|
||||
// GetIndexes returns a list of indexes and the total count of records matching the given conditions.
|
||||
func (s *store) GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error) {
|
||||
func (s *store) GetIndexes(ctx context.Context, opts shared.GetIndexesOptions) (_ []types.Index, _ int, err error) {
|
||||
ctx, trace, endObservation := s.operations.getIndexes.With(ctx, &err, observation.Args{LogFields: []log.Field{
|
||||
log.Int("repositoryID", opts.RepositoryID),
|
||||
log.String("state", opts.State),
|
||||
@ -168,7 +168,7 @@ WHERE repo.deleted_at IS NULL AND %s ORDER BY queued_at DESC, u.id LIMIT %d OFFS
|
||||
`
|
||||
|
||||
// DeleteIndexes deletes indexes matching the given filter criteria.
|
||||
func (s *store) DeleteIndexes(ctx context.Context, opts types.DeleteIndexesOptions) (err error) {
|
||||
func (s *store) DeleteIndexes(ctx context.Context, opts shared.DeleteIndexesOptions) (err error) {
|
||||
ctx, _, endObservation := s.operations.deleteIndexes.With(ctx, &err, observation.Args{LogFields: []log.Field{
|
||||
log.Int("repositoryID", opts.RepositoryID),
|
||||
log.String("state", opts.State),
|
||||
|
||||
@ -223,7 +223,7 @@ func TestGetIndexes(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
indexes, totalCount, err := store.GetIndexes(ctx, types.GetIndexesOptions{
|
||||
indexes, totalCount, err := store.GetIndexes(ctx, shared.GetIndexesOptions{
|
||||
RepositoryID: testCase.repositoryID,
|
||||
State: testCase.state,
|
||||
Term: testCase.term,
|
||||
@ -258,7 +258,7 @@ func TestGetIndexes(t *testing.T) {
|
||||
defer globals.SetPermissionsUserMapping(before)
|
||||
|
||||
indexes, totalCount, err := store.GetIndexes(ctx,
|
||||
types.GetIndexesOptions{
|
||||
shared.GetIndexesOptions{
|
||||
Limit: 1,
|
||||
},
|
||||
)
|
||||
@ -580,7 +580,7 @@ func TestDeleteIndexes(t *testing.T) {
|
||||
insertIndexes(t, db, types.Index{ID: 1, State: "completed"})
|
||||
insertIndexes(t, db, types.Index{ID: 2, State: "errored"})
|
||||
|
||||
if err := store.DeleteIndexes(context.Background(), types.DeleteIndexesOptions{
|
||||
if err := store.DeleteIndexes(context.Background(), shared.DeleteIndexesOptions{
|
||||
State: "errored",
|
||||
Term: "",
|
||||
RepositoryID: 0,
|
||||
|
||||
@ -124,7 +124,7 @@ func NewMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
DeleteIndexesFunc: &StoreDeleteIndexesFunc{
|
||||
defaultHook: func(context.Context, types.DeleteIndexesOptions) (r0 error) {
|
||||
defaultHook: func(context.Context, shared.DeleteIndexesOptions) (r0 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -154,7 +154,7 @@ func NewMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &StoreGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -261,7 +261,7 @@ func NewStrictMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
DeleteIndexesFunc: &StoreDeleteIndexesFunc{
|
||||
defaultHook: func(context.Context, types.DeleteIndexesOptions) error {
|
||||
defaultHook: func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
panic("unexpected invocation of MockStore.DeleteIndexes")
|
||||
},
|
||||
},
|
||||
@ -291,7 +291,7 @@ func NewStrictMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &StoreGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
panic("unexpected invocation of MockStore.GetIndexes")
|
||||
},
|
||||
},
|
||||
@ -584,15 +584,15 @@ func (c StoreDeleteIndexByIDFuncCall) Results() []interface{} {
|
||||
// StoreDeleteIndexesFunc describes the behavior when the DeleteIndexes
|
||||
// method of the parent MockStore instance is invoked.
|
||||
type StoreDeleteIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.DeleteIndexesOptions) error
|
||||
hooks []func(context.Context, types.DeleteIndexesOptions) error
|
||||
defaultHook func(context.Context, shared.DeleteIndexesOptions) error
|
||||
hooks []func(context.Context, shared.DeleteIndexesOptions) error
|
||||
history []StoreDeleteIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// DeleteIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockStore) DeleteIndexes(v0 context.Context, v1 types.DeleteIndexesOptions) error {
|
||||
func (m *MockStore) DeleteIndexes(v0 context.Context, v1 shared.DeleteIndexesOptions) error {
|
||||
r0 := m.DeleteIndexesFunc.nextHook()(v0, v1)
|
||||
m.DeleteIndexesFunc.appendCall(StoreDeleteIndexesFuncCall{v0, v1, r0})
|
||||
return r0
|
||||
@ -600,7 +600,7 @@ func (m *MockStore) DeleteIndexes(v0 context.Context, v1 types.DeleteIndexesOpti
|
||||
|
||||
// SetDefaultHook sets function that is called when the DeleteIndexes method
|
||||
// of the parent MockStore instance is invoked and the hook queue is empty.
|
||||
func (f *StoreDeleteIndexesFunc) SetDefaultHook(hook func(context.Context, types.DeleteIndexesOptions) error) {
|
||||
func (f *StoreDeleteIndexesFunc) SetDefaultHook(hook func(context.Context, shared.DeleteIndexesOptions) error) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ func (f *StoreDeleteIndexesFunc) SetDefaultHook(hook func(context.Context, types
|
||||
// DeleteIndexes method of the parent MockStore instance invokes the hook at
|
||||
// the front of the queue and discards it. After the queue is empty, the
|
||||
// default hook function is invoked for any future action.
|
||||
func (f *StoreDeleteIndexesFunc) PushHook(hook func(context.Context, types.DeleteIndexesOptions) error) {
|
||||
func (f *StoreDeleteIndexesFunc) PushHook(hook func(context.Context, shared.DeleteIndexesOptions) error) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -617,19 +617,19 @@ func (f *StoreDeleteIndexesFunc) PushHook(hook func(context.Context, types.Delet
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *StoreDeleteIndexesFunc) SetDefaultReturn(r0 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.DeleteIndexesOptions) error {
|
||||
f.SetDefaultHook(func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *StoreDeleteIndexesFunc) PushReturn(r0 error) {
|
||||
f.PushHook(func(context.Context, types.DeleteIndexesOptions) error {
|
||||
f.PushHook(func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
func (f *StoreDeleteIndexesFunc) nextHook() func(context.Context, types.DeleteIndexesOptions) error {
|
||||
func (f *StoreDeleteIndexesFunc) nextHook() func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -667,7 +667,7 @@ type StoreDeleteIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.DeleteIndexesOptions
|
||||
Arg1 shared.DeleteIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 error
|
||||
@ -1240,15 +1240,15 @@ func (c StoreGetIndexConfigurationByRepositoryIDFuncCall) Results() []interface{
|
||||
// StoreGetIndexesFunc describes the behavior when the GetIndexes method of
|
||||
// the parent MockStore instance is invoked.
|
||||
type StoreGetIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
defaultHook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
history []StoreGetIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockStore) GetIndexes(v0 context.Context, v1 types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (m *MockStore) GetIndexes(v0 context.Context, v1 shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
r0, r1, r2 := m.GetIndexesFunc.nextHook()(v0, v1)
|
||||
m.GetIndexesFunc.appendCall(StoreGetIndexesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -1256,7 +1256,7 @@ func (m *MockStore) GetIndexes(v0 context.Context, v1 types.GetIndexesOptions) (
|
||||
|
||||
// SetDefaultHook sets function that is called when the GetIndexes method of
|
||||
// the parent MockStore instance is invoked and the hook queue is empty.
|
||||
func (f *StoreGetIndexesFunc) SetDefaultHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *StoreGetIndexesFunc) SetDefaultHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1264,7 +1264,7 @@ func (f *StoreGetIndexesFunc) SetDefaultHook(hook func(context.Context, types.Ge
|
||||
// GetIndexes method of the parent MockStore instance invokes the hook at
|
||||
// the front of the queue and discards it. After the queue is empty, the
|
||||
// default hook function is invoked for any future action.
|
||||
func (f *StoreGetIndexesFunc) PushHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *StoreGetIndexesFunc) PushHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1273,19 +1273,19 @@ func (f *StoreGetIndexesFunc) PushHook(hook func(context.Context, types.GetIndex
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *StoreGetIndexesFunc) SetDefaultReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *StoreGetIndexesFunc) PushReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *StoreGetIndexesFunc) nextHook() func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (f *StoreGetIndexesFunc) nextHook() func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1323,7 +1323,7 @@ type StoreGetIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetIndexesOptions
|
||||
Arg1 shared.GetIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Index
|
||||
@ -3312,8 +3312,8 @@ func (c StoreUpdateSourcedCommitsFuncCall) Results() []interface{} {
|
||||
|
||||
// MockGitserverClient is a mock implementation of the GitserverClient
|
||||
// interface (from the package
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared)
|
||||
// used for unit testing.
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing) used
|
||||
// for unit testing.
|
||||
type MockGitserverClient struct {
|
||||
// CommitDateFunc is an instance of a mock function object controlling
|
||||
// the behavior of the method CommitDate.
|
||||
@ -3465,7 +3465,7 @@ func NewStrictMockGitserverClient() *MockGitserverClient {
|
||||
// NewMockGitserverClientFrom creates a new mock of the MockGitserverClient
|
||||
// interface. All methods delegate to the given implementation, unless
|
||||
// overwritten.
|
||||
func NewMockGitserverClientFrom(i shared.GitserverClient) *MockGitserverClient {
|
||||
func NewMockGitserverClientFrom(i GitserverClient) *MockGitserverClient {
|
||||
return &MockGitserverClient{
|
||||
CommitDateFunc: &GitserverClientCommitDateFunc{
|
||||
defaultHook: i.CommitDate,
|
||||
@ -4656,8 +4656,8 @@ func (c GitserverClientResolveRevisionFuncCall) Results() []interface{} {
|
||||
|
||||
// MockInferenceService is a mock implementation of the InferenceService
|
||||
// interface (from the package
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared)
|
||||
// used for unit testing.
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing) used
|
||||
// for unit testing.
|
||||
type MockInferenceService struct {
|
||||
// InferIndexJobHintsFunc is an instance of a mock function object
|
||||
// controlling the behavior of the method InferIndexJobHints.
|
||||
@ -4705,7 +4705,7 @@ func NewStrictMockInferenceService() *MockInferenceService {
|
||||
// NewMockInferenceServiceFrom creates a new mock of the
|
||||
// MockInferenceService interface. All methods delegate to the given
|
||||
// implementation, unless overwritten.
|
||||
func NewMockInferenceServiceFrom(i shared.InferenceService) *MockInferenceService {
|
||||
func NewMockInferenceServiceFrom(i InferenceService) *MockInferenceService {
|
||||
return &MockInferenceService{
|
||||
InferIndexJobHintsFunc: &InferenceServiceInferIndexJobHintsFunc{
|
||||
defaultHook: i.InferIndexJobHints,
|
||||
@ -4951,8 +4951,8 @@ func (c InferenceServiceInferIndexJobsFuncCall) Results() []interface{} {
|
||||
|
||||
// MockRepoUpdaterClient is a mock implementation of the RepoUpdaterClient
|
||||
// interface (from the package
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared)
|
||||
// used for unit testing.
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing) used
|
||||
// for unit testing.
|
||||
type MockRepoUpdaterClient struct {
|
||||
// EnqueueRepoUpdateFunc is an instance of a mock function object
|
||||
// controlling the behavior of the method EnqueueRepoUpdate.
|
||||
@ -5001,7 +5001,7 @@ func NewStrictMockRepoUpdaterClient() *MockRepoUpdaterClient {
|
||||
// NewMockRepoUpdaterClientFrom creates a new mock of the
|
||||
// MockRepoUpdaterClient interface. All methods delegate to the given
|
||||
// implementation, unless overwritten.
|
||||
func NewMockRepoUpdaterClientFrom(i shared.RepoUpdaterClient) *MockRepoUpdaterClient {
|
||||
func NewMockRepoUpdaterClientFrom(i RepoUpdaterClient) *MockRepoUpdaterClient {
|
||||
return &MockRepoUpdaterClient{
|
||||
EnqueueRepoUpdateFunc: &RepoUpdaterClientEnqueueRepoUpdateFunc{
|
||||
defaultHook: i.EnqueueRepoUpdate,
|
||||
@ -5234,8 +5234,8 @@ func (c RepoUpdaterClientRepoLookupFuncCall) Results() []interface{} {
|
||||
|
||||
// MockUploadService is a mock implementation of the UploadService interface
|
||||
// (from the package
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared)
|
||||
// used for unit testing.
|
||||
// github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing) used
|
||||
// for unit testing.
|
||||
type MockUploadService struct {
|
||||
// GetDirtyRepositoriesFunc is an instance of a mock function object
|
||||
// controlling the behavior of the method GetDirtyRepositories.
|
||||
@ -5335,7 +5335,7 @@ func NewStrictMockUploadService() *MockUploadService {
|
||||
// NewMockUploadServiceFrom creates a new mock of the MockUploadService
|
||||
// interface. All methods delegate to the given implementation, unless
|
||||
// overwritten.
|
||||
func NewMockUploadServiceFrom(i shared.UploadService) *MockUploadService {
|
||||
func NewMockUploadServiceFrom(i UploadService) *MockUploadService {
|
||||
return &MockUploadService{
|
||||
GetDirtyRepositoriesFunc: &UploadServiceGetDirtyRepositoriesFunc{
|
||||
defaultHook: i.GetDirtyRepositories,
|
||||
|
||||
@ -31,10 +31,10 @@ import (
|
||||
type Service struct {
|
||||
store store.Store
|
||||
|
||||
uploadSvc shared.UploadService
|
||||
inferenceSvc shared.InferenceService
|
||||
repoUpdater shared.RepoUpdaterClient
|
||||
gitserverClient shared.GitserverClient
|
||||
uploadSvc UploadService
|
||||
inferenceSvc InferenceService
|
||||
repoUpdater RepoUpdaterClient
|
||||
gitserverClient GitserverClient
|
||||
symbolsClient *symbols.Client
|
||||
backgroundJobs background.BackgroundJob
|
||||
|
||||
@ -44,10 +44,10 @@ type Service struct {
|
||||
|
||||
func newService(
|
||||
store store.Store,
|
||||
uploadSvc shared.UploadService,
|
||||
inferenceSvc shared.InferenceService,
|
||||
repoUpdater shared.RepoUpdaterClient,
|
||||
gitserver shared.GitserverClient,
|
||||
uploadSvc UploadService,
|
||||
inferenceSvc InferenceService,
|
||||
repoUpdater RepoUpdaterClient,
|
||||
gitserver GitserverClient,
|
||||
symbolsClient *symbols.Client,
|
||||
backgroundJobs background.BackgroundJob,
|
||||
observationContext *observation.Context,
|
||||
@ -77,7 +77,7 @@ func GetDependencyIndexingStore(s *Service) dbworkerstore.Store {
|
||||
return s.backgroundJobs.DependencyIndexingStore()
|
||||
}
|
||||
|
||||
func (s *Service) GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error) {
|
||||
func (s *Service) GetIndexes(ctx context.Context, opts shared.GetIndexesOptions) (_ []types.Index, _ int, err error) {
|
||||
ctx, _, endObservation := s.operations.getIndexes.With(ctx, &err, observation.Args{})
|
||||
defer endObservation(1, observation.Args{})
|
||||
|
||||
@ -119,7 +119,7 @@ func (s *Service) DeleteIndexByID(ctx context.Context, id int) (_ bool, err erro
|
||||
return s.store.DeleteIndexByID(ctx, id)
|
||||
}
|
||||
|
||||
func (s *Service) DeleteIndexes(ctx context.Context, opts types.DeleteIndexesOptions) (err error) {
|
||||
func (s *Service) DeleteIndexes(ctx context.Context, opts shared.DeleteIndexesOptions) (err error) {
|
||||
ctx, _, endObservation := s.operations.deleteIndexes.With(ctx, &err, observation.Args{})
|
||||
defer endObservation(1, observation.Args{})
|
||||
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/regexp"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
"github.com/sourcegraph/sourcegraph/internal/repoupdater/protocol"
|
||||
"github.com/sourcegraph/sourcegraph/lib/codeintel/autoindex/config"
|
||||
)
|
||||
|
||||
type RepoUpdaterClient interface {
|
||||
RepoLookup(ctx context.Context, args protocol.RepoLookupArgs) (*protocol.RepoLookupResult, error)
|
||||
EnqueueRepoUpdate(ctx context.Context, repo api.RepoName) (*protocol.RepoUpdateResponse, error)
|
||||
}
|
||||
|
||||
type GitserverClient interface {
|
||||
Head(ctx context.Context, repositoryID int) (string, bool, error)
|
||||
CommitExists(ctx context.Context, repositoryID int, commit string) (bool, error)
|
||||
ListFiles(ctx context.Context, repositoryID int, commit string, pattern *regexp.Regexp) ([]string, error)
|
||||
FileExists(ctx context.Context, repositoryID int, commit, file string) (bool, error)
|
||||
RawContents(ctx context.Context, repositoryID int, commit, file string) ([]byte, error)
|
||||
ResolveRevision(ctx context.Context, repositoryID int, versionString string) (api.CommitID, error)
|
||||
ListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
|
||||
CommitDate(ctx context.Context, repositoryID int, commit string) (string, time.Time, bool, error)
|
||||
RefDescriptions(ctx context.Context, repositoryID int, gitOjbs ...string) (map[string][]gitdomain.RefDescription, error)
|
||||
CommitsUniqueToBranch(ctx context.Context, repositoryID int, branchName string, isDefaultBranch bool, maxAge *time.Time) (map[string]time.Time, error)
|
||||
}
|
||||
|
||||
type InferenceService interface {
|
||||
InferIndexJobs(ctx context.Context, repo api.RepoName, commit, overrideScript string) ([]config.IndexJob, error)
|
||||
InferIndexJobHints(ctx context.Context, repo api.RepoName, commit, overrideScript string) ([]config.IndexJobHint, error)
|
||||
}
|
||||
|
||||
type UploadService interface {
|
||||
GetRepoName(ctx context.Context, repositoryID int) (_ string, err error) // upload service
|
||||
GetDirtyRepositories(ctx context.Context) (_ map[int]int, err error) // upload service
|
||||
GetUploadsByIDs(ctx context.Context, ids ...int) (_ []types.Upload, err error) // upload service
|
||||
GetUploadByID(ctx context.Context, id int) (types.Upload, bool, error)
|
||||
ReferencesForUpload(ctx context.Context, uploadID int) (shared.PackageReferenceScanner, error)
|
||||
GetRepositoriesForIndexScan(ctx context.Context, table, column string, processDelay time.Duration, allowGlobalPolicies bool, repositoryMatchLimit *int, limit int, now time.Time) (_ []int, err error)
|
||||
}
|
||||
@ -1,13 +1,15 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
)
|
||||
|
||||
type IndexJob struct {
|
||||
Indexer string
|
||||
type GetIndexesOptions struct {
|
||||
RepositoryID int
|
||||
State string
|
||||
Term string
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
type SourcedCommits struct {
|
||||
@ -29,50 +31,8 @@ type IndexesWithRepositoryNamespace struct {
|
||||
Indexes []types.Index
|
||||
}
|
||||
|
||||
// UploadLocation is a path and range pair from within a particular upload. The target commit
|
||||
// denotes the target commit for which the location was set (the originally requested commit).
|
||||
type UploadLocation struct {
|
||||
Dump Dump
|
||||
Path string
|
||||
TargetCommit string
|
||||
TargetRange Range
|
||||
}
|
||||
|
||||
// Dump is a subset of the lsif_uploads table (queried via the lsif_dumps_with_repository_name view)
|
||||
// and stores only processed records.
|
||||
type Dump struct {
|
||||
ID int `json:"id"`
|
||||
Commit string `json:"commit"`
|
||||
Root string `json:"root"`
|
||||
VisibleAtTip bool `json:"visibleAtTip"`
|
||||
UploadedAt time.Time `json:"uploadedAt"`
|
||||
State string `json:"state"`
|
||||
FailureMessage *string `json:"failureMessage"`
|
||||
StartedAt *time.Time `json:"startedAt"`
|
||||
FinishedAt *time.Time `json:"finishedAt"`
|
||||
ProcessAfter *time.Time `json:"processAfter"`
|
||||
NumResets int `json:"numResets"`
|
||||
NumFailures int `json:"numFailures"`
|
||||
RepositoryID int `json:"repositoryId"`
|
||||
RepositoryName string `json:"repositoryName"`
|
||||
Indexer string `json:"indexer"`
|
||||
IndexerVersion string `json:"indexerVersion"`
|
||||
AssociatedIndexID *int `json:"associatedIndex"`
|
||||
}
|
||||
|
||||
// Range is an inclusive bounds within a file.
|
||||
type Range struct {
|
||||
Start Position
|
||||
End Position
|
||||
}
|
||||
|
||||
// Position is a unique position within a file.
|
||||
type Position struct {
|
||||
Line int
|
||||
Character int
|
||||
}
|
||||
|
||||
type DeleteUploadsOptions struct {
|
||||
State string
|
||||
Term string
|
||||
type DeleteIndexesOptions struct {
|
||||
State string
|
||||
Term string
|
||||
RepositoryID int
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ func (r *codeIntelTreeInfoResolver) PreciseSupport(ctx context.Context) (*[]GitT
|
||||
resolvers = append(resolvers, &codeIntelTreePreciseCoverageResolver{
|
||||
confidence: indexJobInfered,
|
||||
// drop the tag if it exists
|
||||
indexer: codeinteltypes.ImageToIndexer[strings.Split(job.Indexer, ":")[0]],
|
||||
indexer: codeinteltypes.NewCodeIntelIndexerResolverFrom(codeinteltypes.ImageToIndexer[strings.Split(job.Indexer, ":")[0]]),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ func (r *codeIntelTreeInfoResolver) PreciseSupport(ctx context.Context) (*[]GitT
|
||||
resolvers = append(resolvers, &codeIntelTreePreciseCoverageResolver{
|
||||
confidence: confidence,
|
||||
// expected that job hints don't include a tag in the indexer name
|
||||
indexer: codeinteltypes.ImageToIndexer[hint.Indexer],
|
||||
indexer: codeinteltypes.NewCodeIntelIndexerResolverFrom(codeinteltypes.ImageToIndexer[hint.Indexer]),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,14 +17,14 @@ import (
|
||||
|
||||
type AutoIndexingService interface {
|
||||
GetIndexConfigurationByRepositoryID(ctx context.Context, repositoryID int) (_ shared.IndexConfiguration, _ bool, err error)
|
||||
GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexes(ctx context.Context, opts shared.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexByID(ctx context.Context, id int) (_ types.Index, _ bool, err error)
|
||||
GetIndexesByIDs(ctx context.Context, ids ...int) (_ []types.Index, err error)
|
||||
GetRecentIndexesSummary(ctx context.Context, repositoryID int) (summaries []shared.IndexesWithRepositoryNamespace, err error)
|
||||
GetLastIndexScanForRepository(ctx context.Context, repositoryID int) (_ *time.Time, err error)
|
||||
UpdateIndexConfigurationByRepositoryID(ctx context.Context, repositoryID int, data []byte) (err error)
|
||||
DeleteIndexByID(ctx context.Context, id int) (_ bool, err error)
|
||||
DeleteIndexes(ctx context.Context, opts types.DeleteIndexesOptions) (err error)
|
||||
DeleteIndexes(ctx context.Context, opts shared.DeleteIndexesOptions) (err error)
|
||||
GetInferenceScript(ctx context.Context) (script string, err error)
|
||||
SetInferenceScript(ctx context.Context, script string) (err error)
|
||||
|
||||
@ -44,7 +44,7 @@ type AutoIndexingService interface {
|
||||
type UploadsService interface {
|
||||
GetLastUploadRetentionScanForRepository(ctx context.Context, repositoryID int) (_ *time.Time, err error)
|
||||
GetRecentUploadsSummary(ctx context.Context, repositoryID int) (upload []uploadshared.UploadsWithRepositoryNamespace, err error)
|
||||
GetUploads(ctx context.Context, opts types.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetUploads(ctx context.Context, opts uploadshared.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetAuditLogsForUpload(ctx context.Context, uploadID int) (_ []types.UploadLog, err error)
|
||||
GetListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
GetUploadDocumentsForPath(ctx context.Context, bundleID int, pathPattern string) ([]string, int, error)
|
||||
|
||||
@ -100,7 +100,7 @@ func NewMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
DeleteIndexesFunc: &AutoIndexingServiceDeleteIndexesFunc{
|
||||
defaultHook: func(context.Context, types.DeleteIndexesOptions) (r0 error) {
|
||||
defaultHook: func(context.Context, shared.DeleteIndexesOptions) (r0 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -115,7 +115,7 @@ func NewMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -203,7 +203,7 @@ func NewStrictMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
DeleteIndexesFunc: &AutoIndexingServiceDeleteIndexesFunc{
|
||||
defaultHook: func(context.Context, types.DeleteIndexesOptions) error {
|
||||
defaultHook: func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
panic("unexpected invocation of MockAutoIndexingService.DeleteIndexes")
|
||||
},
|
||||
},
|
||||
@ -218,7 +218,7 @@ func NewStrictMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
panic("unexpected invocation of MockAutoIndexingService.GetIndexes")
|
||||
},
|
||||
},
|
||||
@ -475,15 +475,15 @@ func (c AutoIndexingServiceDeleteIndexByIDFuncCall) Results() []interface{} {
|
||||
// DeleteIndexes method of the parent MockAutoIndexingService instance is
|
||||
// invoked.
|
||||
type AutoIndexingServiceDeleteIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.DeleteIndexesOptions) error
|
||||
hooks []func(context.Context, types.DeleteIndexesOptions) error
|
||||
defaultHook func(context.Context, shared.DeleteIndexesOptions) error
|
||||
hooks []func(context.Context, shared.DeleteIndexesOptions) error
|
||||
history []AutoIndexingServiceDeleteIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// DeleteIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockAutoIndexingService) DeleteIndexes(v0 context.Context, v1 types.DeleteIndexesOptions) error {
|
||||
func (m *MockAutoIndexingService) DeleteIndexes(v0 context.Context, v1 shared.DeleteIndexesOptions) error {
|
||||
r0 := m.DeleteIndexesFunc.nextHook()(v0, v1)
|
||||
m.DeleteIndexesFunc.appendCall(AutoIndexingServiceDeleteIndexesFuncCall{v0, v1, r0})
|
||||
return r0
|
||||
@ -492,7 +492,7 @@ func (m *MockAutoIndexingService) DeleteIndexes(v0 context.Context, v1 types.Del
|
||||
// SetDefaultHook sets function that is called when the DeleteIndexes method
|
||||
// of the parent MockAutoIndexingService instance is invoked and the hook
|
||||
// queue is empty.
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) SetDefaultHook(hook func(context.Context, types.DeleteIndexesOptions) error) {
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) SetDefaultHook(hook func(context.Context, shared.DeleteIndexesOptions) error) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -501,7 +501,7 @@ func (f *AutoIndexingServiceDeleteIndexesFunc) SetDefaultHook(hook func(context.
|
||||
// invokes the hook at the front of the queue and discards it. After the
|
||||
// queue is empty, the default hook function is invoked for any future
|
||||
// action.
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) PushHook(hook func(context.Context, types.DeleteIndexesOptions) error) {
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) PushHook(hook func(context.Context, shared.DeleteIndexesOptions) error) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -510,19 +510,19 @@ func (f *AutoIndexingServiceDeleteIndexesFunc) PushHook(hook func(context.Contex
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) SetDefaultReturn(r0 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.DeleteIndexesOptions) error {
|
||||
f.SetDefaultHook(func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) PushReturn(r0 error) {
|
||||
f.PushHook(func(context.Context, types.DeleteIndexesOptions) error {
|
||||
f.PushHook(func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) nextHook() func(context.Context, types.DeleteIndexesOptions) error {
|
||||
func (f *AutoIndexingServiceDeleteIndexesFunc) nextHook() func(context.Context, shared.DeleteIndexesOptions) error {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -561,7 +561,7 @@ type AutoIndexingServiceDeleteIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.DeleteIndexesOptions
|
||||
Arg1 shared.DeleteIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 error
|
||||
@ -814,15 +814,15 @@ func (c AutoIndexingServiceGetIndexConfigurationByRepositoryIDFuncCall) Results(
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance is
|
||||
// invoked.
|
||||
type AutoIndexingServiceGetIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
defaultHook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
history []AutoIndexingServiceGetIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
r0, r1, r2 := m.GetIndexesFunc.nextHook()(v0, v1)
|
||||
m.GetIndexesFunc.appendCall(AutoIndexingServiceGetIndexesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -831,7 +831,7 @@ func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetInd
|
||||
// SetDefaultHook sets function that is called when the GetIndexes method of
|
||||
// the parent MockAutoIndexingService instance is invoked and the hook queue
|
||||
// is empty.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -839,7 +839,7 @@ func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Con
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance invokes
|
||||
// the hook at the front of the queue and discards it. After the queue is
|
||||
// empty, the default hook function is invoked for any future action.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -848,19 +848,19 @@ func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context,
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -899,7 +899,7 @@ type AutoIndexingServiceGetIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetIndexesOptions
|
||||
Arg1 shared.GetIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Index
|
||||
@ -2755,7 +2755,7 @@ func NewMockUploadsService() *MockUploadsService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadsServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared1.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -2797,7 +2797,7 @@ func NewStrictMockUploadsService() *MockUploadsService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadsServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
defaultHook: func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
panic("unexpected invocation of MockUploadsService.GetUploads")
|
||||
},
|
||||
},
|
||||
@ -3414,15 +3414,15 @@ func (c UploadsServiceGetUploadDocumentsForPathFuncCall) Results() []interface{}
|
||||
// UploadsServiceGetUploadsFunc describes the behavior when the GetUploads
|
||||
// method of the parent MockUploadsService instance is invoked.
|
||||
type UploadsServiceGetUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
defaultHook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
history []UploadsServiceGetUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockUploadsService) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (m *MockUploadsService) GetUploads(v0 context.Context, v1 shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
r0, r1, r2 := m.GetUploadsFunc.nextHook()(v0, v1)
|
||||
m.GetUploadsFunc.appendCall(UploadsServiceGetUploadsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -3431,7 +3431,7 @@ func (m *MockUploadsService) GetUploads(v0 context.Context, v1 types.GetUploadsO
|
||||
// SetDefaultHook sets function that is called when the GetUploads method of
|
||||
// the parent MockUploadsService instance is invoked and the hook queue is
|
||||
// empty.
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -3439,7 +3439,7 @@ func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context,
|
||||
// GetUploads method of the parent MockUploadsService instance invokes the
|
||||
// hook at the front of the queue and discards it. After the queue is empty,
|
||||
// the default hook function is invoked for any future action.
|
||||
func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -3448,19 +3448,19 @@ func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, types
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *UploadsServiceGetUploadsFunc) PushReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.PushHook(func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *UploadsServiceGetUploadsFunc) nextHook() func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (f *UploadsServiceGetUploadsFunc) nextHook() func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -3498,7 +3498,7 @@ type UploadsServiceGetUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetUploadsOptions
|
||||
Arg1 shared1.GetUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Upload
|
||||
|
||||
@ -25,8 +25,15 @@ type preciseCodeIntelSupportResolver struct {
|
||||
}
|
||||
|
||||
func NewPreciseCodeIntelSupportResolver(filepath string) PreciseSupportResolver {
|
||||
indexers := types.LanguageToIndexer[path.Ext(filepath)]
|
||||
|
||||
resolvers := make([]types.CodeIntelIndexerResolver, len(indexers))
|
||||
for _, indexer := range indexers {
|
||||
resolvers = append(resolvers, types.NewCodeIntelIndexerResolverFrom(indexer))
|
||||
}
|
||||
|
||||
return &preciseCodeIntelSupportResolver{
|
||||
indexers: types.LanguageToIndexer[path.Ext(filepath)],
|
||||
indexers: resolvers,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend/graphqlutil"
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
)
|
||||
|
||||
@ -77,18 +77,18 @@ const DefaultIndexPageSize = 50
|
||||
|
||||
// makeGetIndexesOptions translates the given GraphQL arguments into options defined by the
|
||||
// store.GetIndexes operations.
|
||||
func makeGetIndexesOptions(args *LSIFRepositoryIndexesQueryArgs) (types.GetIndexesOptions, error) {
|
||||
func makeGetIndexesOptions(args *LSIFRepositoryIndexesQueryArgs) (shared.GetIndexesOptions, error) {
|
||||
repositoryID, err := resolveRepositoryID(args.RepositoryID)
|
||||
if err != nil {
|
||||
return types.GetIndexesOptions{}, err
|
||||
return shared.GetIndexesOptions{}, err
|
||||
}
|
||||
|
||||
offset, err := graphqlutil.DecodeIntCursor(args.After)
|
||||
if err != nil {
|
||||
return types.GetIndexesOptions{}, err
|
||||
return shared.GetIndexesOptions{}, err
|
||||
}
|
||||
|
||||
return types.GetIndexesOptions{
|
||||
return shared.GetIndexesOptions{
|
||||
RepositoryID: repositoryID,
|
||||
State: strings.ToLower(derefString(args.State, "")),
|
||||
Term: derefString(args.Query, ""),
|
||||
@ -223,17 +223,17 @@ func EncodeCursor(val *string) *PageInfo {
|
||||
|
||||
// makeDeleteIndexesOptions translates the given GraphQL arguments into options defined by the
|
||||
// store.DeleteIndexes operations.
|
||||
func makeDeleteIndexesOptions(args *DeleteLSIFIndexesArgs) (types.DeleteIndexesOptions, error) {
|
||||
func makeDeleteIndexesOptions(args *DeleteLSIFIndexesArgs) (shared.DeleteIndexesOptions, error) {
|
||||
var repository int
|
||||
if args.Repository != nil {
|
||||
var err error
|
||||
repository, err = resolveRepositoryID(*args.Repository)
|
||||
if err != nil {
|
||||
return types.DeleteIndexesOptions{}, err
|
||||
return shared.DeleteIndexesOptions{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return types.DeleteIndexesOptions{
|
||||
return shared.DeleteIndexesOptions{
|
||||
State: strings.ToLower(derefString(args.State, "")),
|
||||
Term: derefString(args.Query, ""),
|
||||
RepositoryID: repository,
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/graph-gophers/graphql-go"
|
||||
|
||||
codeinteltypes "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
)
|
||||
|
||||
func TestMakeGetIndexesOptions(t *testing.T) {
|
||||
@ -26,7 +26,7 @@ func TestMakeGetIndexesOptions(t *testing.T) {
|
||||
t.Fatalf("unexpected error making options: %s", err)
|
||||
}
|
||||
|
||||
expected := codeinteltypes.GetIndexesOptions{
|
||||
expected := shared.GetIndexesOptions{
|
||||
RepositoryID: 50,
|
||||
State: "s",
|
||||
Term: "q",
|
||||
@ -46,7 +46,7 @@ func TestMakeGetIndexesOptionsDefaults(t *testing.T) {
|
||||
t.Fatalf("unexpected error making options: %s", err)
|
||||
}
|
||||
|
||||
expected := codeinteltypes.GetIndexesOptions{
|
||||
expected := shared.GetIndexesOptions{
|
||||
RepositoryID: 0,
|
||||
State: "",
|
||||
Term: "",
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/gitserver"
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
)
|
||||
@ -18,12 +17,12 @@ type CommitCache interface {
|
||||
}
|
||||
|
||||
type commitCache struct {
|
||||
gitserverClient shared.GitserverClient
|
||||
gitserverClient GitserverClient
|
||||
mutex sync.RWMutex
|
||||
cache map[int]map[string]bool
|
||||
}
|
||||
|
||||
func NewCommitCache(client shared.GitserverClient) CommitCache {
|
||||
func NewCommitCache(client GitserverClient) CommitCache {
|
||||
return &commitCache{
|
||||
gitserverClient: client,
|
||||
cache: map[int]map[string]bool{},
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"github.com/sourcegraph/go-diff/diff"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
sgtypes "github.com/sourcegraph/sourcegraph/internal/types"
|
||||
)
|
||||
@ -38,7 +37,7 @@ type GitTreeTranslator interface {
|
||||
}
|
||||
|
||||
type gitTreeTranslator struct {
|
||||
client shared.GitserverClient
|
||||
client GitserverClient
|
||||
localRequestArgs *requestArgs
|
||||
hunkCache HunkCache
|
||||
}
|
||||
@ -74,7 +73,7 @@ func NewHunkCache(size int) (HunkCache, error) {
|
||||
}
|
||||
|
||||
// NewGitTreeTranslator creates a new GitTreeTranslator with the given repository and source commit.
|
||||
func NewGitTreeTranslator(client shared.GitserverClient, args *requestArgs, hunkCache HunkCache) GitTreeTranslator {
|
||||
func NewGitTreeTranslator(client GitserverClient, args *requestArgs, hunkCache HunkCache) GitTreeTranslator {
|
||||
return &gitTreeTranslator{
|
||||
client: client,
|
||||
hunkCache: hunkCache,
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
sgTypes "github.com/sourcegraph/sourcegraph/internal/types"
|
||||
)
|
||||
@ -28,7 +27,7 @@ type RequestState struct {
|
||||
func NewRequestState(
|
||||
uploads []types.Dump,
|
||||
authChecker authz.SubRepoPermissionChecker,
|
||||
gitclient shared.GitserverClient, repo *sgTypes.Repo, commit, path string,
|
||||
gitclient GitserverClient, repo *sgTypes.Repo, commit, path string,
|
||||
maxIndexes int,
|
||||
hunkCacheSize int,
|
||||
) RequestState {
|
||||
@ -65,7 +64,7 @@ func (r *RequestState) SetUploadsDataLoader(uploads []types.Dump) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RequestState) SetLocalGitTreeTranslator(client shared.GitserverClient, repo *sgTypes.Repo, commit, path string, hunkCacheSize int) error {
|
||||
func (r *RequestState) SetLocalGitTreeTranslator(client GitserverClient, repo *sgTypes.Repo, commit, path string, hunkCacheSize int) error {
|
||||
hunkCache, err := NewHunkCache(hunkCacheSize)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -82,7 +81,7 @@ func (r *RequestState) SetLocalGitTreeTranslator(client shared.GitserverClient,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RequestState) SetLocalCommitCache(client shared.GitserverClient) {
|
||||
func (r *RequestState) SetLocalCommitCache(client GitserverClient) {
|
||||
r.commitCache = NewCommitCache(client)
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sourcegraph/go-diff/diff"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/gitserver"
|
||||
)
|
||||
|
||||
type GitserverClient interface {
|
||||
CommitsExist(ctx context.Context, commits []gitserver.RepositoryCommit) ([]bool, error)
|
||||
DiffPath(ctx context.Context, checker authz.SubRepoPermissionChecker, repo api.RepoName, sourceCommit, targetCommit, path string) ([]*diff.Hunk, error)
|
||||
}
|
||||
@ -5,10 +5,6 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/lib/codeintel/precise"
|
||||
)
|
||||
|
||||
type Symbol struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
// Location is an LSP-like location scoped to a dump.
|
||||
type Location struct {
|
||||
DumpID int
|
||||
|
||||
@ -8,10 +8,12 @@ import (
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
autoindexingShared "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/gitserver"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
uploadsshared "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
)
|
||||
@ -38,7 +40,7 @@ type GitserverClient interface {
|
||||
}
|
||||
|
||||
type AutoIndexingService interface {
|
||||
GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexes(ctx context.Context, opts autoindexingShared.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexByID(ctx context.Context, id int) (_ types.Index, _ bool, err error)
|
||||
GetIndexesByIDs(ctx context.Context, ids ...int) (_ []types.Index, err error)
|
||||
GetUnsafeDB() database.DB
|
||||
@ -47,7 +49,7 @@ type AutoIndexingService interface {
|
||||
}
|
||||
|
||||
type UploadsService interface {
|
||||
GetUploads(ctx context.Context, opts types.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetUploads(ctx context.Context, opts uploadsshared.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetAuditLogsForUpload(ctx context.Context, uploadID int) (_ []types.UploadLog, err error)
|
||||
GetListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
GetUploadDocumentsForPath(ctx context.Context, bundleID int, pathPattern string) ([]string, int, error)
|
||||
|
||||
@ -14,9 +14,11 @@ import (
|
||||
diff "github.com/sourcegraph/go-diff/diff"
|
||||
api "github.com/sourcegraph/sourcegraph/internal/api"
|
||||
authz "github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/shared"
|
||||
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
shared1 "github.com/sourcegraph/sourcegraph/internal/codeintel/codenav/shared"
|
||||
gitserver "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/gitserver"
|
||||
types "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
shared2 "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
database "github.com/sourcegraph/sourcegraph/internal/database"
|
||||
gitdomain "github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
)
|
||||
@ -57,7 +59,7 @@ func NewMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -95,7 +97,7 @@ func NewStrictMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
panic("unexpected invocation of MockAutoIndexingService.GetIndexes")
|
||||
},
|
||||
},
|
||||
@ -266,15 +268,15 @@ func (c AutoIndexingServiceGetIndexByIDFuncCall) Results() []interface{} {
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance is
|
||||
// invoked.
|
||||
type AutoIndexingServiceGetIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
defaultHook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
history []AutoIndexingServiceGetIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
r0, r1, r2 := m.GetIndexesFunc.nextHook()(v0, v1)
|
||||
m.GetIndexesFunc.appendCall(AutoIndexingServiceGetIndexesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -283,7 +285,7 @@ func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetInd
|
||||
// SetDefaultHook sets function that is called when the GetIndexes method of
|
||||
// the parent MockAutoIndexingService instance is invoked and the hook queue
|
||||
// is empty.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -291,7 +293,7 @@ func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Con
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance invokes
|
||||
// the hook at the front of the queue and discards it. After the queue is
|
||||
// empty, the default hook function is invoked for any future action.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -300,19 +302,19 @@ func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context,
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -351,7 +353,7 @@ type AutoIndexingServiceGetIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetIndexesOptions
|
||||
Arg1 shared.GetIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Index
|
||||
@ -867,7 +869,7 @@ func NewMockGitBlobResolver() *MockGitBlobResolver {
|
||||
},
|
||||
},
|
||||
DiagnosticsFunc: &GitBlobResolverDiagnosticsFunc{
|
||||
defaultHook: func(context.Context, int) (r0 []shared.DiagnosticAtUpload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, int) (r0 []shared1.DiagnosticAtUpload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -887,7 +889,7 @@ func NewMockGitBlobResolver() *MockGitBlobResolver {
|
||||
},
|
||||
},
|
||||
RangesFunc: &GitBlobResolverRangesFunc{
|
||||
defaultHook: func(context.Context, int, int) (r0 []shared.AdjustedCodeIntelligenceRange, r1 error) {
|
||||
defaultHook: func(context.Context, int, int) (r0 []shared1.AdjustedCodeIntelligenceRange, r1 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -914,7 +916,7 @@ func NewStrictMockGitBlobResolver() *MockGitBlobResolver {
|
||||
},
|
||||
},
|
||||
DiagnosticsFunc: &GitBlobResolverDiagnosticsFunc{
|
||||
defaultHook: func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error) {
|
||||
defaultHook: func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error) {
|
||||
panic("unexpected invocation of MockGitBlobResolver.Diagnostics")
|
||||
},
|
||||
},
|
||||
@ -934,7 +936,7 @@ func NewStrictMockGitBlobResolver() *MockGitBlobResolver {
|
||||
},
|
||||
},
|
||||
RangesFunc: &GitBlobResolverRangesFunc{
|
||||
defaultHook: func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error) {
|
||||
defaultHook: func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error) {
|
||||
panic("unexpected invocation of MockGitBlobResolver.Ranges")
|
||||
},
|
||||
},
|
||||
@ -1097,15 +1099,15 @@ func (c GitBlobResolverDefinitionsFuncCall) Results() []interface{} {
|
||||
// GitBlobResolverDiagnosticsFunc describes the behavior when the
|
||||
// Diagnostics method of the parent MockGitBlobResolver instance is invoked.
|
||||
type GitBlobResolverDiagnosticsFunc struct {
|
||||
defaultHook func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error)
|
||||
hooks []func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error)
|
||||
defaultHook func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error)
|
||||
hooks []func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error)
|
||||
history []GitBlobResolverDiagnosticsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// Diagnostics delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockGitBlobResolver) Diagnostics(v0 context.Context, v1 int) ([]shared.DiagnosticAtUpload, int, error) {
|
||||
func (m *MockGitBlobResolver) Diagnostics(v0 context.Context, v1 int) ([]shared1.DiagnosticAtUpload, int, error) {
|
||||
r0, r1, r2 := m.DiagnosticsFunc.nextHook()(v0, v1)
|
||||
m.DiagnosticsFunc.appendCall(GitBlobResolverDiagnosticsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -1114,7 +1116,7 @@ func (m *MockGitBlobResolver) Diagnostics(v0 context.Context, v1 int) ([]shared.
|
||||
// SetDefaultHook sets function that is called when the Diagnostics method
|
||||
// of the parent MockGitBlobResolver instance is invoked and the hook queue
|
||||
// is empty.
|
||||
func (f *GitBlobResolverDiagnosticsFunc) SetDefaultHook(hook func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error)) {
|
||||
func (f *GitBlobResolverDiagnosticsFunc) SetDefaultHook(hook func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1122,7 +1124,7 @@ func (f *GitBlobResolverDiagnosticsFunc) SetDefaultHook(hook func(context.Contex
|
||||
// Diagnostics method of the parent MockGitBlobResolver instance invokes the
|
||||
// hook at the front of the queue and discards it. After the queue is empty,
|
||||
// the default hook function is invoked for any future action.
|
||||
func (f *GitBlobResolverDiagnosticsFunc) PushHook(hook func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error)) {
|
||||
func (f *GitBlobResolverDiagnosticsFunc) PushHook(hook func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1130,20 +1132,20 @@ func (f *GitBlobResolverDiagnosticsFunc) PushHook(hook func(context.Context, int
|
||||
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *GitBlobResolverDiagnosticsFunc) SetDefaultReturn(r0 []shared.DiagnosticAtUpload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error) {
|
||||
func (f *GitBlobResolverDiagnosticsFunc) SetDefaultReturn(r0 []shared1.DiagnosticAtUpload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *GitBlobResolverDiagnosticsFunc) PushReturn(r0 []shared.DiagnosticAtUpload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error) {
|
||||
func (f *GitBlobResolverDiagnosticsFunc) PushReturn(r0 []shared1.DiagnosticAtUpload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *GitBlobResolverDiagnosticsFunc) nextHook() func(context.Context, int) ([]shared.DiagnosticAtUpload, int, error) {
|
||||
func (f *GitBlobResolverDiagnosticsFunc) nextHook() func(context.Context, int) ([]shared1.DiagnosticAtUpload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1184,7 +1186,7 @@ type GitBlobResolverDiagnosticsFuncCall struct {
|
||||
Arg1 int
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []shared.DiagnosticAtUpload
|
||||
Result0 []shared1.DiagnosticAtUpload
|
||||
// Result1 is the value of the 2nd result returned from this method
|
||||
// invocation.
|
||||
Result1 int
|
||||
@ -1552,15 +1554,15 @@ func (c GitBlobResolverLSIFUploadsFuncCall) Results() []interface{} {
|
||||
// GitBlobResolverRangesFunc describes the behavior when the Ranges method
|
||||
// of the parent MockGitBlobResolver instance is invoked.
|
||||
type GitBlobResolverRangesFunc struct {
|
||||
defaultHook func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error)
|
||||
hooks []func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error)
|
||||
defaultHook func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error)
|
||||
hooks []func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error)
|
||||
history []GitBlobResolverRangesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// Ranges delegates to the next hook function in the queue and stores the
|
||||
// parameter and result values of this invocation.
|
||||
func (m *MockGitBlobResolver) Ranges(v0 context.Context, v1 int, v2 int) ([]shared.AdjustedCodeIntelligenceRange, error) {
|
||||
func (m *MockGitBlobResolver) Ranges(v0 context.Context, v1 int, v2 int) ([]shared1.AdjustedCodeIntelligenceRange, error) {
|
||||
r0, r1 := m.RangesFunc.nextHook()(v0, v1, v2)
|
||||
m.RangesFunc.appendCall(GitBlobResolverRangesFuncCall{v0, v1, v2, r0, r1})
|
||||
return r0, r1
|
||||
@ -1569,7 +1571,7 @@ func (m *MockGitBlobResolver) Ranges(v0 context.Context, v1 int, v2 int) ([]shar
|
||||
// SetDefaultHook sets function that is called when the Ranges method of the
|
||||
// parent MockGitBlobResolver instance is invoked and the hook queue is
|
||||
// empty.
|
||||
func (f *GitBlobResolverRangesFunc) SetDefaultHook(hook func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error)) {
|
||||
func (f *GitBlobResolverRangesFunc) SetDefaultHook(hook func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1577,7 +1579,7 @@ func (f *GitBlobResolverRangesFunc) SetDefaultHook(hook func(context.Context, in
|
||||
// Ranges method of the parent MockGitBlobResolver instance invokes the hook
|
||||
// at the front of the queue and discards it. After the queue is empty, the
|
||||
// default hook function is invoked for any future action.
|
||||
func (f *GitBlobResolverRangesFunc) PushHook(hook func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error)) {
|
||||
func (f *GitBlobResolverRangesFunc) PushHook(hook func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1585,20 +1587,20 @@ func (f *GitBlobResolverRangesFunc) PushHook(hook func(context.Context, int, int
|
||||
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *GitBlobResolverRangesFunc) SetDefaultReturn(r0 []shared.AdjustedCodeIntelligenceRange, r1 error) {
|
||||
f.SetDefaultHook(func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error) {
|
||||
func (f *GitBlobResolverRangesFunc) SetDefaultReturn(r0 []shared1.AdjustedCodeIntelligenceRange, r1 error) {
|
||||
f.SetDefaultHook(func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error) {
|
||||
return r0, r1
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *GitBlobResolverRangesFunc) PushReturn(r0 []shared.AdjustedCodeIntelligenceRange, r1 error) {
|
||||
f.PushHook(func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error) {
|
||||
func (f *GitBlobResolverRangesFunc) PushReturn(r0 []shared1.AdjustedCodeIntelligenceRange, r1 error) {
|
||||
f.PushHook(func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error) {
|
||||
return r0, r1
|
||||
})
|
||||
}
|
||||
|
||||
func (f *GitBlobResolverRangesFunc) nextHook() func(context.Context, int, int) ([]shared.AdjustedCodeIntelligenceRange, error) {
|
||||
func (f *GitBlobResolverRangesFunc) nextHook() func(context.Context, int, int) ([]shared1.AdjustedCodeIntelligenceRange, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1642,7 +1644,7 @@ type GitBlobResolverRangesFuncCall struct {
|
||||
Arg2 int
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []shared.AdjustedCodeIntelligenceRange
|
||||
Result0 []shared1.AdjustedCodeIntelligenceRange
|
||||
// Result1 is the value of the 2nd result returned from this method
|
||||
// invocation.
|
||||
Result1 error
|
||||
@ -2395,7 +2397,7 @@ func NewMockUploadsService() *MockUploadsService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadsServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared2.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -2427,7 +2429,7 @@ func NewStrictMockUploadsService() *MockUploadsService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadsServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
defaultHook: func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
panic("unexpected invocation of MockUploadsService.GetUploads")
|
||||
},
|
||||
},
|
||||
@ -2812,15 +2814,15 @@ func (c UploadsServiceGetUploadDocumentsForPathFuncCall) Results() []interface{}
|
||||
// UploadsServiceGetUploadsFunc describes the behavior when the GetUploads
|
||||
// method of the parent MockUploadsService instance is invoked.
|
||||
type UploadsServiceGetUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
defaultHook func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
history []UploadsServiceGetUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockUploadsService) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (m *MockUploadsService) GetUploads(v0 context.Context, v1 shared2.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
r0, r1, r2 := m.GetUploadsFunc.nextHook()(v0, v1)
|
||||
m.GetUploadsFunc.appendCall(UploadsServiceGetUploadsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -2829,7 +2831,7 @@ func (m *MockUploadsService) GetUploads(v0 context.Context, v1 types.GetUploadsO
|
||||
// SetDefaultHook sets function that is called when the GetUploads method of
|
||||
// the parent MockUploadsService instance is invoked and the hook queue is
|
||||
// empty.
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -2837,7 +2839,7 @@ func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context,
|
||||
// GetUploads method of the parent MockUploadsService instance invokes the
|
||||
// hook at the front of the queue and discards it. After the queue is empty,
|
||||
// the default hook function is invoked for any future action.
|
||||
func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -2846,19 +2848,19 @@ func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, types
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *UploadsServiceGetUploadsFunc) PushReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.PushHook(func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *UploadsServiceGetUploadsFunc) nextHook() func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (f *UploadsServiceGetUploadsFunc) nextHook() func(context.Context, shared2.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -2896,7 +2898,7 @@ type UploadsServiceGetUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetUploadsOptions
|
||||
Arg1 shared2.GetUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Upload
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
logger "github.com/sourcegraph/log"
|
||||
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
|
||||
@ -14,7 +15,7 @@ import (
|
||||
// Store provides the interface for policies storage.
|
||||
type Store interface {
|
||||
// Configurations
|
||||
GetConfigurationPolicies(ctx context.Context, opts types.GetConfigurationPoliciesOptions) (_ []types.ConfigurationPolicy, totalCount int, err error)
|
||||
GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) (_ []types.ConfigurationPolicy, totalCount int, err error)
|
||||
GetConfigurationPolicyByID(ctx context.Context, id int) (_ types.ConfigurationPolicy, _ bool, err error)
|
||||
CreateConfigurationPolicy(ctx context.Context, configurationPolicy types.ConfigurationPolicy) (types.ConfigurationPolicy, error)
|
||||
UpdateConfigurationPolicy(ctx context.Context, policy types.ConfigurationPolicy) (err error)
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/lib/pq"
|
||||
"github.com/opentracing/opentracing-go/log"
|
||||
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
|
||||
@ -18,7 +19,7 @@ import (
|
||||
// GetConfigurationPolicies retrieves the set of configuration policies matching the the given options.
|
||||
// If a repository identifier is supplied (is non-zero), then only the configuration policies that apply
|
||||
// to repository are returned. If repository is not supplied, then all policies may be returned.
|
||||
func (s *store) GetConfigurationPolicies(ctx context.Context, opts types.GetConfigurationPoliciesOptions) (_ []types.ConfigurationPolicy, totalCount int, err error) {
|
||||
func (s *store) GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) (_ []types.ConfigurationPolicy, totalCount int, err error) {
|
||||
ctx, trace, endObservation := s.operations.getConfigurationPolicies.With(ctx, &err, observation.Args{LogFields: []log.Field{
|
||||
log.Int("repositoryID", opts.RepositoryID),
|
||||
log.String("term", opts.Term),
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"github.com/keegancsmith/sqlf"
|
||||
"github.com/sourcegraph/log/logtest"
|
||||
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/dbtest"
|
||||
@ -108,7 +109,7 @@ func TestGetConfigurationPolicies(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
policies, totalCount, err := store.GetConfigurationPolicies(ctx, types.GetConfigurationPoliciesOptions{
|
||||
policies, totalCount, err := store.GetConfigurationPolicies(ctx, policiesshared.GetConfigurationPoliciesOptions{
|
||||
RepositoryID: testCase.repositoryID,
|
||||
Term: testCase.term,
|
||||
ForDataRetention: testCase.forDataRetention,
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
store "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/internal/store"
|
||||
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
types "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
database "github.com/sourcegraph/sourcegraph/internal/database"
|
||||
gitdomain "github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
@ -72,7 +73,7 @@ func NewMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
GetConfigurationPoliciesFunc: &StoreGetConfigurationPoliciesFunc{
|
||||
defaultHook: func(context.Context, types.GetConfigurationPoliciesOptions) (r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetConfigurationPoliciesOptions) (r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -124,7 +125,7 @@ func NewStrictMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
GetConfigurationPoliciesFunc: &StoreGetConfigurationPoliciesFunc{
|
||||
defaultHook: func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
panic("unexpected invocation of MockStore.GetConfigurationPolicies")
|
||||
},
|
||||
},
|
||||
@ -417,15 +418,15 @@ func (c StoreDeleteConfigurationPolicyByIDFuncCall) Results() []interface{} {
|
||||
// GetConfigurationPolicies method of the parent MockStore instance is
|
||||
// invoked.
|
||||
type StoreGetConfigurationPoliciesFunc struct {
|
||||
defaultHook func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
hooks []func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
defaultHook func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
hooks []func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
history []StoreGetConfigurationPoliciesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetConfigurationPolicies delegates to the next hook function in the queue
|
||||
// and stores the parameter and result values of this invocation.
|
||||
func (m *MockStore) GetConfigurationPolicies(v0 context.Context, v1 types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
func (m *MockStore) GetConfigurationPolicies(v0 context.Context, v1 shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
r0, r1, r2 := m.GetConfigurationPoliciesFunc.nextHook()(v0, v1)
|
||||
m.GetConfigurationPoliciesFunc.appendCall(StoreGetConfigurationPoliciesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -434,7 +435,7 @@ func (m *MockStore) GetConfigurationPolicies(v0 context.Context, v1 types.GetCon
|
||||
// SetDefaultHook sets function that is called when the
|
||||
// GetConfigurationPolicies method of the parent MockStore instance is
|
||||
// invoked and the hook queue is empty.
|
||||
func (f *StoreGetConfigurationPoliciesFunc) SetDefaultHook(hook func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
func (f *StoreGetConfigurationPoliciesFunc) SetDefaultHook(hook func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -442,7 +443,7 @@ func (f *StoreGetConfigurationPoliciesFunc) SetDefaultHook(hook func(context.Con
|
||||
// GetConfigurationPolicies method of the parent MockStore instance invokes
|
||||
// the hook at the front of the queue and discards it. After the queue is
|
||||
// empty, the default hook function is invoked for any future action.
|
||||
func (f *StoreGetConfigurationPoliciesFunc) PushHook(hook func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
func (f *StoreGetConfigurationPoliciesFunc) PushHook(hook func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -451,19 +452,19 @@ func (f *StoreGetConfigurationPoliciesFunc) PushHook(hook func(context.Context,
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *StoreGetConfigurationPoliciesFunc) SetDefaultReturn(r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *StoreGetConfigurationPoliciesFunc) PushReturn(r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *StoreGetConfigurationPoliciesFunc) nextHook() func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
func (f *StoreGetConfigurationPoliciesFunc) nextHook() func(context.Context, shared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -502,7 +503,7 @@ type StoreGetConfigurationPoliciesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetConfigurationPoliciesOptions
|
||||
Arg1 shared.GetConfigurationPoliciesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.ConfigurationPolicy
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
|
||||
policies "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/policies/internal/store"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/conf"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
@ -42,7 +43,7 @@ func (s *Service) getPolicyMatcherFromFactory(gitserver GitserverClient, extract
|
||||
return policies.NewMatcher(gitserver, extractor, includeTipOfDefaultBranch, filterByCreatedDate)
|
||||
}
|
||||
|
||||
func (s *Service) GetConfigurationPolicies(ctx context.Context, opts types.GetConfigurationPoliciesOptions) (_ []types.ConfigurationPolicy, totalCount int, err error) {
|
||||
func (s *Service) GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) (_ []types.ConfigurationPolicy, totalCount int, err error) {
|
||||
ctx, _, endObservation := s.operations.getConfigurationPolicies.With(ctx, &err, observation.Args{})
|
||||
defer endObservation(1, observation.Args{})
|
||||
|
||||
@ -118,7 +119,7 @@ func (s *Service) GetRetentionPolicyOverview(ctx context.Context, upload types.U
|
||||
|
||||
policyMatcher := s.getPolicyMatcherFromFactory(s.gitserver, policies.RetentionExtractor, true, false)
|
||||
|
||||
configPolicies, _, err := s.GetConfigurationPolicies(ctx, types.GetConfigurationPoliciesOptions{
|
||||
configPolicies, _, err := s.GetConfigurationPolicies(ctx, policiesshared.GetConfigurationPoliciesOptions{
|
||||
RepositoryID: upload.RepositoryID,
|
||||
Term: query,
|
||||
ForDataRetention: true,
|
||||
|
||||
@ -1,5 +1,25 @@
|
||||
package shared
|
||||
|
||||
type Policy struct {
|
||||
ID int
|
||||
type GetConfigurationPoliciesOptions struct {
|
||||
// RepositoryID indicates that only configuration policies that apply to the
|
||||
// specified repository (directly or via pattern) should be returned. This value
|
||||
// has no effect when equal to zero.
|
||||
RepositoryID int
|
||||
|
||||
// Term is a string to search within the configuration title.
|
||||
Term string
|
||||
|
||||
// ForIndexing indicates that only configuration policies with data retention enabled
|
||||
// should be returned.
|
||||
ForDataRetention bool
|
||||
|
||||
// ForIndexing indicates that only configuration policies with indexing enabled should
|
||||
// be returned.
|
||||
ForIndexing bool
|
||||
|
||||
// Limit indicates the number of results to take from the result set.
|
||||
Limit int
|
||||
|
||||
// Offset indicates the number of results to skip in the result set.
|
||||
Offset int
|
||||
}
|
||||
|
||||
@ -4,12 +4,13 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
// Configurations
|
||||
GetConfigurationPolicies(ctx context.Context, opts types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
GetConfigurationPolicyByID(ctx context.Context, id int) (_ types.ConfigurationPolicy, _ bool, err error)
|
||||
CreateConfigurationPolicy(ctx context.Context, configurationPolicy types.ConfigurationPolicy) (types.ConfigurationPolicy, error)
|
||||
UpdateConfigurationPolicy(ctx context.Context, policy types.ConfigurationPolicy) (err error)
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/auth"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/policies"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
sharedresolvers "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/resolvers"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver"
|
||||
@ -91,7 +92,7 @@ func (r *rootResolver) CodeIntelligenceConfigurationPolicies(ctx context.Context
|
||||
pageSize = int(*args.First)
|
||||
}
|
||||
|
||||
opts := types.GetConfigurationPoliciesOptions{
|
||||
opts := policiesshared.GetConfigurationPoliciesOptions{
|
||||
Limit: pageSize,
|
||||
Offset: offset,
|
||||
}
|
||||
|
||||
@ -7,13 +7,14 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
autoindexingShared "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
uploadsShared "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
)
|
||||
|
||||
type AutoIndexingService interface {
|
||||
GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexes(ctx context.Context, opts autoindexingShared.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexByID(ctx context.Context, id int) (_ types.Index, _ bool, err error)
|
||||
GetIndexesByIDs(ctx context.Context, ids ...int) (_ []types.Index, err error)
|
||||
GetUnsafeDB() database.DB
|
||||
@ -21,7 +22,7 @@ type AutoIndexingService interface {
|
||||
}
|
||||
|
||||
type UploadsService interface {
|
||||
GetUploads(ctx context.Context, opts types.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetUploads(ctx context.Context, opts shared.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetAuditLogsForUpload(ctx context.Context, uploadID int) (_ []types.UploadLog, err error)
|
||||
GetListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
GetUploadDocumentsForPath(ctx context.Context, bundleID int, pathPattern string) ([]string, int, error)
|
||||
|
||||
@ -120,7 +120,7 @@ func (r *indexResolver) ProjectRoot(ctx context.Context) (_ *GitTreeEntryResolve
|
||||
func (r *indexResolver) Indexer() types.CodeIntelIndexerResolver {
|
||||
// drop the tag if it exists
|
||||
if idx, ok := types.ImageToIndexer[strings.Split(r.index.Indexer, ":")[0]]; ok {
|
||||
return idx
|
||||
return types.NewCodeIntelIndexerResolverFrom(idx)
|
||||
}
|
||||
|
||||
return types.NewCodeIntelIndexerResolver(r.index.Indexer)
|
||||
|
||||
@ -32,7 +32,7 @@ func (r *lsifIndexesWithRepositoryNamespaceResolver) Root() string {
|
||||
func (r *lsifIndexesWithRepositoryNamespaceResolver) Indexer() types.CodeIntelIndexerResolver {
|
||||
// drop the tag if it exists
|
||||
if idx, ok := types.ImageToIndexer[strings.Split(r.indexesSummary.Indexer, ":")[0]]; ok {
|
||||
return idx
|
||||
return types.NewCodeIntelIndexerResolverFrom(idx)
|
||||
}
|
||||
|
||||
return types.NewCodeIntelIndexerResolver(r.indexesSummary.Indexer)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend/graphqlutil"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
)
|
||||
|
||||
@ -12,7 +13,7 @@ import (
|
||||
// invoked lazily and its results memoized.
|
||||
type IndexesResolver struct {
|
||||
svc AutoIndexingService
|
||||
opts types.GetIndexesOptions
|
||||
opts shared.GetIndexesOptions
|
||||
once sync.Once
|
||||
//
|
||||
Indexes []types.Index
|
||||
@ -23,7 +24,7 @@ type IndexesResolver struct {
|
||||
|
||||
// NewIndexesResolver creates a new IndexesResolver which wil invoke store.GetIndexes
|
||||
// with the given options.
|
||||
func NewIndexesResolver(svc AutoIndexingService, opts types.GetIndexesOptions) *IndexesResolver {
|
||||
func NewIndexesResolver(svc AutoIndexingService, opts shared.GetIndexesOptions) *IndexesResolver {
|
||||
return &IndexesResolver{svc: svc, opts: opts}
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,9 @@ import (
|
||||
"sync"
|
||||
|
||||
api "github.com/sourcegraph/sourcegraph/internal/api"
|
||||
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
types "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
shared1 "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
database "github.com/sourcegraph/sourcegraph/internal/database"
|
||||
gitdomain "github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
)
|
||||
@ -49,7 +51,7 @@ func NewMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -82,7 +84,7 @@ func NewStrictMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
panic("unexpected invocation of MockAutoIndexingService.GetIndexes")
|
||||
},
|
||||
},
|
||||
@ -245,15 +247,15 @@ func (c AutoIndexingServiceGetIndexByIDFuncCall) Results() []interface{} {
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance is
|
||||
// invoked.
|
||||
type AutoIndexingServiceGetIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
defaultHook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
history []AutoIndexingServiceGetIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
r0, r1, r2 := m.GetIndexesFunc.nextHook()(v0, v1)
|
||||
m.GetIndexesFunc.appendCall(AutoIndexingServiceGetIndexesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -262,7 +264,7 @@ func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetInd
|
||||
// SetDefaultHook sets function that is called when the GetIndexes method of
|
||||
// the parent MockAutoIndexingService instance is invoked and the hook queue
|
||||
// is empty.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -270,7 +272,7 @@ func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Con
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance invokes
|
||||
// the hook at the front of the queue and discards it. After the queue is
|
||||
// empty, the default hook function is invoked for any future action.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -279,19 +281,19 @@ func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context,
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -330,7 +332,7 @@ type AutoIndexingServiceGetIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetIndexesOptions
|
||||
Arg1 shared.GetIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Index
|
||||
@ -736,7 +738,7 @@ func NewMockUploadsService() *MockUploadsService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadsServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared1.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -768,7 +770,7 @@ func NewStrictMockUploadsService() *MockUploadsService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadsServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
defaultHook: func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
panic("unexpected invocation of MockUploadsService.GetUploads")
|
||||
},
|
||||
},
|
||||
@ -1153,15 +1155,15 @@ func (c UploadsServiceGetUploadDocumentsForPathFuncCall) Results() []interface{}
|
||||
// UploadsServiceGetUploadsFunc describes the behavior when the GetUploads
|
||||
// method of the parent MockUploadsService instance is invoked.
|
||||
type UploadsServiceGetUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
defaultHook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
history []UploadsServiceGetUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockUploadsService) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (m *MockUploadsService) GetUploads(v0 context.Context, v1 shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
r0, r1, r2 := m.GetUploadsFunc.nextHook()(v0, v1)
|
||||
m.GetUploadsFunc.appendCall(UploadsServiceGetUploadsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -1170,7 +1172,7 @@ func (m *MockUploadsService) GetUploads(v0 context.Context, v1 types.GetUploadsO
|
||||
// SetDefaultHook sets function that is called when the GetUploads method of
|
||||
// the parent MockUploadsService instance is invoked and the hook queue is
|
||||
// empty.
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1178,7 +1180,7 @@ func (f *UploadsServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context,
|
||||
// GetUploads method of the parent MockUploadsService instance invokes the
|
||||
// hook at the front of the queue and discards it. After the queue is empty,
|
||||
// the default hook function is invoked for any future action.
|
||||
func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1187,19 +1189,19 @@ func (f *UploadsServiceGetUploadsFunc) PushHook(hook func(context.Context, types
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *UploadsServiceGetUploadsFunc) SetDefaultReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *UploadsServiceGetUploadsFunc) PushReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.PushHook(func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *UploadsServiceGetUploadsFunc) nextHook() func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (f *UploadsServiceGetUploadsFunc) nextHook() func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1237,7 +1239,7 @@ type UploadsServiceGetUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetUploadsOptions
|
||||
Arg1 shared1.GetUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Upload
|
||||
|
||||
@ -156,8 +156,8 @@ func (r *UploadResolver) RetentionPolicyOverview(ctx context.Context, args *LSIF
|
||||
|
||||
func (r *UploadResolver) Indexer() types.CodeIntelIndexerResolver {
|
||||
for _, indexer := range types.AllIndexers {
|
||||
if indexer.Name() == r.upload.Indexer {
|
||||
return indexer
|
||||
if indexer.Name == r.upload.Indexer {
|
||||
return types.NewCodeIntelIndexerResolverFrom(indexer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@ func (r *lsifUploadsWithRepositoryNamespaceResolver) Root() string {
|
||||
|
||||
func (r *lsifUploadsWithRepositoryNamespaceResolver) Indexer() types.CodeIntelIndexerResolver {
|
||||
for _, indexer := range types.AllIndexers {
|
||||
if indexer.Name() == r.uploadsSummary.Indexer {
|
||||
return indexer
|
||||
if indexer.Name == r.uploadsSummary.Indexer {
|
||||
return types.NewCodeIntelIndexerResolverFrom(indexer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,13 +5,14 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
)
|
||||
|
||||
// UploadsResolver wraps store.GetUploads so that the underlying function can be
|
||||
// invoked lazily and its results memoized.
|
||||
type UploadsResolver struct {
|
||||
svc UploadsService
|
||||
opts types.GetUploadsOptions
|
||||
opts shared.GetUploadsOptions
|
||||
once sync.Once
|
||||
|
||||
Uploads []types.Upload
|
||||
@ -22,7 +23,7 @@ type UploadsResolver struct {
|
||||
|
||||
// NewUploadsResolver creates a new UploadsResolver which wil invoke store.GetUploads
|
||||
// with the given options.
|
||||
func NewUploadsResolver(svc UploadsService, opts types.GetUploadsOptions) *UploadsResolver {
|
||||
func NewUploadsResolver(svc UploadsService, opts shared.GetUploadsOptions) *UploadsResolver {
|
||||
return &UploadsResolver{svc: svc, opts: opts}
|
||||
}
|
||||
|
||||
|
||||
21
internal/codeintel/shared/types/codenav.go
Normal file
21
internal/codeintel/shared/types/codenav.go
Normal file
@ -0,0 +1,21 @@
|
||||
package types
|
||||
|
||||
// UploadLocation is a path and range pair from within a particular upload. The target commit
|
||||
// denotes the target commit for which the location was set (the originally requested commit).
|
||||
type UploadLocation struct {
|
||||
Dump Dump
|
||||
Path string
|
||||
TargetCommit string
|
||||
TargetRange Range
|
||||
}
|
||||
|
||||
type Range struct {
|
||||
Start Position
|
||||
End Position
|
||||
}
|
||||
|
||||
// Position is a unique position within a file.
|
||||
type Position struct {
|
||||
Line int
|
||||
Character int
|
||||
}
|
||||
25
internal/codeintel/shared/types/dump.go
Normal file
25
internal/codeintel/shared/types/dump.go
Normal file
@ -0,0 +1,25 @@
|
||||
package types
|
||||
|
||||
import "time"
|
||||
|
||||
// Dump is a subset of the lsif_uploads table (queried via the lsif_dumps_with_repository_name view)
|
||||
// and stores only processed records.
|
||||
type Dump struct {
|
||||
ID int `json:"id"`
|
||||
Commit string `json:"commit"`
|
||||
Root string `json:"root"`
|
||||
VisibleAtTip bool `json:"visibleAtTip"`
|
||||
UploadedAt time.Time `json:"uploadedAt"`
|
||||
State string `json:"state"`
|
||||
FailureMessage *string `json:"failureMessage"`
|
||||
StartedAt *time.Time `json:"startedAt"`
|
||||
FinishedAt *time.Time `json:"finishedAt"`
|
||||
ProcessAfter *time.Time `json:"processAfter"`
|
||||
NumResets int `json:"numResets"`
|
||||
NumFailures int `json:"numFailures"`
|
||||
RepositoryID int `json:"repositoryId"`
|
||||
RepositoryName string `json:"repositoryName"`
|
||||
Indexer string `json:"indexer"`
|
||||
IndexerVersion string `json:"indexerVersion"`
|
||||
AssociatedIndexID *int `json:"associatedIndex"`
|
||||
}
|
||||
@ -37,14 +37,6 @@ func (i Index) RecordID() int {
|
||||
return i.ID
|
||||
}
|
||||
|
||||
type GetIndexesOptions struct {
|
||||
RepositoryID int
|
||||
State string
|
||||
Term string
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
type DockerStep struct {
|
||||
Root string `json:"root"`
|
||||
Image string `json:"image"`
|
||||
|
||||
30
internal/codeintel/shared/types/indexer_resolver.go
Normal file
30
internal/codeintel/shared/types/indexer_resolver.go
Normal file
@ -0,0 +1,30 @@
|
||||
package types
|
||||
|
||||
type CodeIntelIndexerResolver interface {
|
||||
Name() string
|
||||
URL() string
|
||||
}
|
||||
|
||||
type codeIntelIndexerResolver struct {
|
||||
indexer CodeIntelIndexer
|
||||
}
|
||||
|
||||
func NewCodeIntelIndexerResolver(name string) CodeIntelIndexerResolver {
|
||||
return NewCodeIntelIndexerResolverFrom(CodeIntelIndexer{Name: name})
|
||||
}
|
||||
|
||||
func NewCodeIntelIndexerResolverFrom(indexer CodeIntelIndexer) CodeIntelIndexerResolver {
|
||||
return &codeIntelIndexerResolver{indexer: indexer}
|
||||
}
|
||||
|
||||
func (r *codeIntelIndexerResolver) Name() string {
|
||||
return r.indexer.Name
|
||||
}
|
||||
|
||||
func (r *codeIntelIndexerResolver) URL() string {
|
||||
if r.indexer.URN == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
return "https://" + r.indexer.URN
|
||||
}
|
||||
@ -1,162 +1,141 @@
|
||||
package types
|
||||
|
||||
type CodeIntelIndexerResolver interface {
|
||||
Name() string
|
||||
URL() string
|
||||
}
|
||||
|
||||
type codeIntelIndexerResolver struct {
|
||||
name string
|
||||
urn string
|
||||
}
|
||||
|
||||
func NewCodeIntelIndexerResolver(name string) CodeIntelIndexerResolver {
|
||||
return &codeIntelIndexerResolver{name: name}
|
||||
}
|
||||
|
||||
func (r *codeIntelIndexerResolver) Name() string {
|
||||
return r.name
|
||||
}
|
||||
|
||||
func (r *codeIntelIndexerResolver) URL() string {
|
||||
if r.urn == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
return "https://" + r.urn
|
||||
type CodeIntelIndexer struct {
|
||||
Name string
|
||||
URN string
|
||||
}
|
||||
|
||||
var (
|
||||
lsifNode = codeIntelIndexerResolver{
|
||||
name: "lsif-tsc",
|
||||
urn: "github.com/sourcegraph/lsif-node",
|
||||
lsifNode = CodeIntelIndexer{
|
||||
Name: "lsif-tsc",
|
||||
URN: "github.com/sourcegraph/lsif-node",
|
||||
}
|
||||
msftNode = codeIntelIndexerResolver{
|
||||
name: "msft/lsif-node",
|
||||
urn: "github.com/Microsoft/lsif-node",
|
||||
msftNode = CodeIntelIndexer{
|
||||
Name: "msft/lsif-node",
|
||||
URN: "github.com/Microsoft/lsif-node",
|
||||
}
|
||||
lsifTypescript = codeIntelIndexerResolver{
|
||||
name: "scip-typescript",
|
||||
urn: "github.com/sourcegraph/scip-typescript",
|
||||
lsifTypescript = CodeIntelIndexer{
|
||||
Name: "scip-typescript",
|
||||
URN: "github.com/sourcegraph/scip-typescript",
|
||||
}
|
||||
scipJava = codeIntelIndexerResolver{
|
||||
name: "scip-java",
|
||||
urn: "github.com/sourcegraph/scip-java",
|
||||
scipJava = CodeIntelIndexer{
|
||||
Name: "scip-java",
|
||||
URN: "github.com/sourcegraph/scip-java",
|
||||
}
|
||||
msftJava = codeIntelIndexerResolver{
|
||||
name: "msft/lsif-java",
|
||||
urn: "github.com/Microsoft/lsif-java",
|
||||
msftJava = CodeIntelIndexer{
|
||||
Name: "msft/lsif-java",
|
||||
URN: "github.com/Microsoft/lsif-java",
|
||||
}
|
||||
lsifGo = codeIntelIndexerResolver{
|
||||
name: "lsif-go",
|
||||
urn: "github.com/sourcegraph/lsif-go",
|
||||
lsifGo = CodeIntelIndexer{
|
||||
Name: "lsif-go",
|
||||
URN: "github.com/sourcegraph/lsif-go",
|
||||
}
|
||||
lsifClang = codeIntelIndexerResolver{
|
||||
name: "lsif-clang",
|
||||
urn: "github.com/sourcegraph/lsif-clang",
|
||||
lsifClang = CodeIntelIndexer{
|
||||
Name: "lsif-clang",
|
||||
URN: "github.com/sourcegraph/lsif-clang",
|
||||
}
|
||||
lsifCPP = codeIntelIndexerResolver{
|
||||
name: "lsif-cpp",
|
||||
urn: "github.com/sourcegraph/lsif-cpp",
|
||||
lsifCPP = CodeIntelIndexer{
|
||||
Name: "lsif-cpp",
|
||||
URN: "github.com/sourcegraph/lsif-cpp",
|
||||
}
|
||||
lsifDart = codeIntelIndexerResolver{
|
||||
name: "lsif-dart",
|
||||
urn: "github.com/sourcegraph/lsif-dart",
|
||||
lsifDart = CodeIntelIndexer{
|
||||
Name: "lsif-dart",
|
||||
URN: "github.com/sourcegraph/lsif-dart",
|
||||
}
|
||||
workivaDart = codeIntelIndexerResolver{
|
||||
name: "lsif_indexer",
|
||||
urn: "github.com/Workiva/lsif_indexer",
|
||||
workivaDart = CodeIntelIndexer{
|
||||
Name: "lsif_indexer",
|
||||
URN: "github.com/Workiva/lsif_indexer",
|
||||
}
|
||||
hieLSIF = codeIntelIndexerResolver{
|
||||
name: "hie-lsif",
|
||||
urn: "github.com/mpickering/hie-lsif",
|
||||
hieLSIF = CodeIntelIndexer{
|
||||
Name: "hie-lsif",
|
||||
URN: "github.com/mpickering/hie-lsif",
|
||||
}
|
||||
lsifJsonnet = codeIntelIndexerResolver{
|
||||
name: "lsif-jsonnet",
|
||||
urn: "github.com/sourcegraph/lsif-jsonnet",
|
||||
lsifJsonnet = CodeIntelIndexer{
|
||||
Name: "lsif-jsonnet",
|
||||
URN: "github.com/sourcegraph/lsif-jsonnet",
|
||||
}
|
||||
lsifOcaml = codeIntelIndexerResolver{
|
||||
name: "lsif-ocaml",
|
||||
urn: "github.com/rvantonder/lsif-ocaml",
|
||||
lsifOcaml = CodeIntelIndexer{
|
||||
Name: "lsif-ocaml",
|
||||
URN: "github.com/rvantonder/lsif-ocaml",
|
||||
}
|
||||
scipPython = codeIntelIndexerResolver{
|
||||
name: "scip-python",
|
||||
urn: "github.com/sourcegraph/scip-python",
|
||||
scipPython = CodeIntelIndexer{
|
||||
Name: "scip-python",
|
||||
URN: "github.com/sourcegraph/scip-python",
|
||||
}
|
||||
rustAnalyzer = codeIntelIndexerResolver{
|
||||
name: "rust-analyzer",
|
||||
urn: "github.com/rust-analyzer/rust-analyzer",
|
||||
rustAnalyzer = CodeIntelIndexer{
|
||||
Name: "rust-analyzer",
|
||||
URN: "github.com/rust-analyzer/rust-analyzer",
|
||||
}
|
||||
lsifPHP = codeIntelIndexerResolver{
|
||||
name: "lsif-php",
|
||||
urn: "github.com/davidrjenni/lsif-php",
|
||||
lsifPHP = CodeIntelIndexer{
|
||||
Name: "lsif-php",
|
||||
URN: "github.com/davidrjenni/lsif-php",
|
||||
}
|
||||
lsifTerraform = codeIntelIndexerResolver{
|
||||
name: "lsif-terraform",
|
||||
urn: "github.com/juliosueiras/lsif-terraform",
|
||||
lsifTerraform = CodeIntelIndexer{
|
||||
Name: "lsif-terraform",
|
||||
URN: "github.com/juliosueiras/lsif-terraform",
|
||||
}
|
||||
lsifDotnet = codeIntelIndexerResolver{
|
||||
name: "lsif-dotnet",
|
||||
urn: "github.com/tcz717/LsifDotnet",
|
||||
lsifDotnet = CodeIntelIndexer{
|
||||
Name: "lsif-dotnet",
|
||||
URN: "github.com/tcz717/LsifDotnet",
|
||||
}
|
||||
)
|
||||
|
||||
var AllIndexers = []CodeIntelIndexerResolver{
|
||||
&lsifNode,
|
||||
&msftNode,
|
||||
&lsifTypescript,
|
||||
&scipJava,
|
||||
&msftJava,
|
||||
&lsifGo,
|
||||
&lsifClang,
|
||||
&lsifCPP,
|
||||
&lsifDart,
|
||||
&workivaDart,
|
||||
&hieLSIF,
|
||||
&lsifJsonnet,
|
||||
&lsifOcaml,
|
||||
&scipPython,
|
||||
&rustAnalyzer,
|
||||
&lsifPHP,
|
||||
&lsifTerraform,
|
||||
&lsifDotnet,
|
||||
var AllIndexers = []CodeIntelIndexer{
|
||||
lsifNode,
|
||||
msftNode,
|
||||
lsifTypescript,
|
||||
scipJava,
|
||||
msftJava,
|
||||
lsifGo,
|
||||
lsifClang,
|
||||
lsifCPP,
|
||||
lsifDart,
|
||||
workivaDart,
|
||||
hieLSIF,
|
||||
lsifJsonnet,
|
||||
lsifOcaml,
|
||||
scipPython,
|
||||
rustAnalyzer,
|
||||
lsifPHP,
|
||||
lsifTerraform,
|
||||
lsifDotnet,
|
||||
}
|
||||
|
||||
// A map of file extension to a list of indexers in order of recommendation
|
||||
// from most to least.
|
||||
var LanguageToIndexer = map[string][]CodeIntelIndexerResolver{
|
||||
".go": {&lsifGo},
|
||||
".java": {&scipJava, &msftJava},
|
||||
".kt": {&scipJava},
|
||||
".scala": {&scipJava},
|
||||
".js": {&lsifTypescript, &lsifNode, &msftNode},
|
||||
".jsx": {&lsifTypescript, &lsifNode, &msftNode},
|
||||
".ts": {&lsifTypescript, &lsifNode, &msftNode},
|
||||
".tsx": {&lsifTypescript, &lsifNode, &msftNode},
|
||||
".dart": {&workivaDart, &lsifDart},
|
||||
".c": {&lsifClang, &lsifCPP},
|
||||
".cc": {&lsifClang, &lsifCPP},
|
||||
".cpp": {&lsifClang, &lsifCPP},
|
||||
".cxx": {&lsifClang, &lsifCPP},
|
||||
".h": {&lsifClang, &lsifCPP},
|
||||
".hpp": {&lsifClang, &lsifCPP},
|
||||
".hs": {&hieLSIF},
|
||||
".jsonnet": {&lsifJsonnet},
|
||||
".py": {&scipPython},
|
||||
".ml": {&lsifOcaml},
|
||||
".rs": {&rustAnalyzer},
|
||||
".php": {&lsifPHP},
|
||||
".tf": {&lsifTerraform},
|
||||
".cs": {&lsifDotnet},
|
||||
var LanguageToIndexer = map[string][]CodeIntelIndexer{
|
||||
".go": {lsifGo},
|
||||
".java": {scipJava, msftJava},
|
||||
".kt": {scipJava},
|
||||
".scala": {scipJava},
|
||||
".js": {lsifTypescript, lsifNode, msftNode},
|
||||
".jsx": {lsifTypescript, lsifNode, msftNode},
|
||||
".ts": {lsifTypescript, lsifNode, msftNode},
|
||||
".tsx": {lsifTypescript, lsifNode, msftNode},
|
||||
".dart": {workivaDart, lsifDart},
|
||||
".c": {lsifClang, lsifCPP},
|
||||
".cc": {lsifClang, lsifCPP},
|
||||
".cpp": {lsifClang, lsifCPP},
|
||||
".cxx": {lsifClang, lsifCPP},
|
||||
".h": {lsifClang, lsifCPP},
|
||||
".hpp": {lsifClang, lsifCPP},
|
||||
".hs": {hieLSIF},
|
||||
".jsonnet": {lsifJsonnet},
|
||||
".py": {scipPython},
|
||||
".ml": {lsifOcaml},
|
||||
".rs": {rustAnalyzer},
|
||||
".php": {lsifPHP},
|
||||
".tf": {lsifTerraform},
|
||||
".cs": {lsifDotnet},
|
||||
}
|
||||
|
||||
var ImageToIndexer = map[string]CodeIntelIndexerResolver{
|
||||
"sourcegraph/scip-java": &scipJava,
|
||||
"sourcegraph/lsif-go": &lsifGo,
|
||||
"sourcegraph/scip-typescript": &lsifTypescript,
|
||||
"sourcegraph/lsif-node": &lsifNode,
|
||||
"sourcegraph/lsif-clang": &lsifClang,
|
||||
"davidrjenni/lsif-php": &lsifPHP,
|
||||
"sourcegraph/lsif-rust": &rustAnalyzer,
|
||||
"sourcegraph/scip-python": &scipPython,
|
||||
var ImageToIndexer = map[string]CodeIntelIndexer{
|
||||
"sourcegraph/scip-java": scipJava,
|
||||
"sourcegraph/lsif-go": lsifGo,
|
||||
"sourcegraph/scip-typescript": lsifTypescript,
|
||||
"sourcegraph/lsif-node": lsifNode,
|
||||
"sourcegraph/lsif-clang": lsifClang,
|
||||
"davidrjenni/lsif-php": lsifPHP,
|
||||
"sourcegraph/lsif-rust": rustAnalyzer,
|
||||
"sourcegraph/scip-python": scipPython,
|
||||
}
|
||||
|
||||
33
internal/codeintel/shared/types/policy.go
Normal file
33
internal/codeintel/shared/types/policy.go
Normal file
@ -0,0 +1,33 @@
|
||||
package types
|
||||
|
||||
import "time"
|
||||
|
||||
type ConfigurationPolicy struct {
|
||||
ID int
|
||||
RepositoryID *int
|
||||
RepositoryPatterns *[]string
|
||||
Name string
|
||||
Type GitObjectType
|
||||
Pattern string
|
||||
Protected bool
|
||||
RetentionEnabled bool
|
||||
RetentionDuration *time.Duration
|
||||
RetainIntermediateCommits bool
|
||||
IndexingEnabled bool
|
||||
IndexCommitMaxAge *time.Duration
|
||||
IndexIntermediateCommits bool
|
||||
}
|
||||
|
||||
type GitObjectType string
|
||||
|
||||
const (
|
||||
GitObjectTypeCommit GitObjectType = "GIT_COMMIT"
|
||||
GitObjectTypeTag GitObjectType = "GIT_TAG"
|
||||
GitObjectTypeTree GitObjectType = "GIT_TREE"
|
||||
)
|
||||
|
||||
type RetentionPolicyMatchCandidate struct {
|
||||
*ConfigurationPolicy
|
||||
Matched bool
|
||||
ProtectingCommits []string
|
||||
}
|
||||
@ -1,188 +0,0 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
)
|
||||
|
||||
// RevSpecSet is a utility type for a set of RevSpecs.
|
||||
type RevSpecSet map[api.RevSpec]struct{}
|
||||
|
||||
// Dump is a subset of the lsif_uploads table (queried via the lsif_dumps_with_repository_name view)
|
||||
// and stores only processed records.
|
||||
type Dump struct {
|
||||
ID int `json:"id"`
|
||||
Commit string `json:"commit"`
|
||||
Root string `json:"root"`
|
||||
VisibleAtTip bool `json:"visibleAtTip"`
|
||||
UploadedAt time.Time `json:"uploadedAt"`
|
||||
State string `json:"state"`
|
||||
FailureMessage *string `json:"failureMessage"`
|
||||
StartedAt *time.Time `json:"startedAt"`
|
||||
FinishedAt *time.Time `json:"finishedAt"`
|
||||
ProcessAfter *time.Time `json:"processAfter"`
|
||||
NumResets int `json:"numResets"`
|
||||
NumFailures int `json:"numFailures"`
|
||||
RepositoryID int `json:"repositoryId"`
|
||||
RepositoryName string `json:"repositoryName"`
|
||||
Indexer string `json:"indexer"`
|
||||
IndexerVersion string `json:"indexerVersion"`
|
||||
AssociatedIndexID *int `json:"associatedIndex"`
|
||||
}
|
||||
|
||||
// UploadLocation is a path and range pair from within a particular upload. The target commit
|
||||
// denotes the target commit for which the location was set (the originally requested commit).
|
||||
type UploadLocation struct {
|
||||
Dump Dump
|
||||
Path string
|
||||
TargetCommit string
|
||||
TargetRange Range
|
||||
}
|
||||
|
||||
type Range struct {
|
||||
Start Position
|
||||
End Position
|
||||
}
|
||||
|
||||
// Position is a unique position within a file.
|
||||
type Position struct {
|
||||
Line int
|
||||
Character int
|
||||
}
|
||||
|
||||
type UploadLog struct {
|
||||
LogTimestamp time.Time
|
||||
RecordDeletedAt *time.Time
|
||||
UploadID int
|
||||
Commit string
|
||||
Root string
|
||||
RepositoryID int
|
||||
UploadedAt time.Time
|
||||
Indexer string
|
||||
IndexerVersion *string
|
||||
UploadSize *int
|
||||
AssociatedIndexID *int
|
||||
TransitionColumns []map[string]*string
|
||||
Reason *string
|
||||
Operation string
|
||||
}
|
||||
|
||||
type Upload struct {
|
||||
ID int
|
||||
Commit string
|
||||
Root string
|
||||
VisibleAtTip bool
|
||||
UploadedAt time.Time
|
||||
State string
|
||||
FailureMessage *string
|
||||
StartedAt *time.Time
|
||||
FinishedAt *time.Time
|
||||
ProcessAfter *time.Time
|
||||
NumResets int
|
||||
NumFailures int
|
||||
RepositoryID int
|
||||
RepositoryName string
|
||||
Indexer string
|
||||
IndexerVersion string
|
||||
NumParts int
|
||||
UploadedParts []int
|
||||
UploadSize *int64
|
||||
UncompressedSize *int64
|
||||
Rank *int
|
||||
AssociatedIndexID *int
|
||||
}
|
||||
|
||||
func (u Upload) RecordID() int {
|
||||
return u.ID
|
||||
}
|
||||
|
||||
type GetUploadsOptions struct {
|
||||
RepositoryID int
|
||||
State string
|
||||
Term string
|
||||
VisibleAtTip bool
|
||||
DependencyOf int
|
||||
DependentOf int
|
||||
UploadedBefore *time.Time
|
||||
UploadedAfter *time.Time
|
||||
LastRetentionScanBefore *time.Time
|
||||
AllowExpired bool
|
||||
AllowDeletedRepo bool
|
||||
AllowDeletedUpload bool
|
||||
OldestFirst bool
|
||||
Limit int
|
||||
Offset int
|
||||
|
||||
// InCommitGraph ensures that the repository commit graph was updated strictly
|
||||
// after this upload was processed. This condition helps us filter out new uploads
|
||||
// that we might later mistake for unreachable.
|
||||
InCommitGraph bool
|
||||
}
|
||||
|
||||
type DeleteUploadsOptions struct {
|
||||
State string
|
||||
Term string
|
||||
VisibleAtTip bool
|
||||
RepositoryID int
|
||||
}
|
||||
|
||||
type DeleteIndexesOptions struct {
|
||||
State string
|
||||
Term string
|
||||
RepositoryID int
|
||||
}
|
||||
|
||||
type GetConfigurationPoliciesOptions struct {
|
||||
// RepositoryID indicates that only configuration policies that apply to the
|
||||
// specified repository (directly or via pattern) should be returned. This value
|
||||
// has no effect when equal to zero.
|
||||
RepositoryID int
|
||||
|
||||
// Term is a string to search within the configuration title.
|
||||
Term string
|
||||
|
||||
// ForIndexing indicates that only configuration policies with data retention enabled
|
||||
// should be returned.
|
||||
ForDataRetention bool
|
||||
|
||||
// ForIndexing indicates that only configuration policies with indexing enabled should
|
||||
// be returned.
|
||||
ForIndexing bool
|
||||
|
||||
// Limit indicates the number of results to take from the result set.
|
||||
Limit int
|
||||
|
||||
// Offset indicates the number of results to skip in the result set.
|
||||
Offset int
|
||||
}
|
||||
|
||||
type ConfigurationPolicy struct {
|
||||
ID int
|
||||
RepositoryID *int
|
||||
RepositoryPatterns *[]string
|
||||
Name string
|
||||
Type GitObjectType
|
||||
Pattern string
|
||||
Protected bool
|
||||
RetentionEnabled bool
|
||||
RetentionDuration *time.Duration
|
||||
RetainIntermediateCommits bool
|
||||
IndexingEnabled bool
|
||||
IndexCommitMaxAge *time.Duration
|
||||
IndexIntermediateCommits bool
|
||||
}
|
||||
|
||||
type RetentionPolicyMatchCandidate struct {
|
||||
*ConfigurationPolicy
|
||||
Matched bool
|
||||
ProtectingCommits []string
|
||||
}
|
||||
|
||||
type GitObjectType string
|
||||
|
||||
const (
|
||||
GitObjectTypeCommit GitObjectType = "GIT_COMMIT"
|
||||
GitObjectTypeTag GitObjectType = "GIT_TAG"
|
||||
GitObjectTypeTree GitObjectType = "GIT_TREE"
|
||||
)
|
||||
49
internal/codeintel/shared/types/upload.go
Normal file
49
internal/codeintel/shared/types/upload.go
Normal file
@ -0,0 +1,49 @@
|
||||
package types
|
||||
|
||||
import "time"
|
||||
|
||||
type Upload struct {
|
||||
ID int
|
||||
Commit string
|
||||
Root string
|
||||
VisibleAtTip bool
|
||||
UploadedAt time.Time
|
||||
State string
|
||||
FailureMessage *string
|
||||
StartedAt *time.Time
|
||||
FinishedAt *time.Time
|
||||
ProcessAfter *time.Time
|
||||
NumResets int
|
||||
NumFailures int
|
||||
RepositoryID int
|
||||
RepositoryName string
|
||||
Indexer string
|
||||
IndexerVersion string
|
||||
NumParts int
|
||||
UploadedParts []int
|
||||
UploadSize *int64
|
||||
UncompressedSize *int64
|
||||
Rank *int
|
||||
AssociatedIndexID *int
|
||||
}
|
||||
|
||||
func (u Upload) RecordID() int {
|
||||
return u.ID
|
||||
}
|
||||
|
||||
type UploadLog struct {
|
||||
LogTimestamp time.Time
|
||||
RecordDeletedAt *time.Time
|
||||
UploadID int
|
||||
Commit string
|
||||
Root string
|
||||
RepositoryID int
|
||||
UploadedAt time.Time
|
||||
Indexer string
|
||||
IndexerVersion *string
|
||||
UploadSize *int
|
||||
AssociatedIndexID *int
|
||||
TransitionColumns []map[string]*string
|
||||
Reason *string
|
||||
Operation string
|
||||
}
|
||||
@ -219,7 +219,7 @@ func (s *Service) handleHardDeleter(ctx context.Context) error {
|
||||
|
||||
func (s *Service) hardDeleteExpiredUploads(ctx context.Context) (count int, err error) {
|
||||
const uploadsBatchSize = 100
|
||||
options := types.GetUploadsOptions{
|
||||
options := shared.GetUploadsOptions{
|
||||
State: "deleted",
|
||||
Limit: uploadsBatchSize,
|
||||
AllowExpired: true,
|
||||
|
||||
@ -7,7 +7,9 @@ import (
|
||||
"github.com/sourcegraph/log"
|
||||
|
||||
policiesEnterprise "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/goroutine"
|
||||
"github.com/sourcegraph/sourcegraph/internal/timeutil"
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
@ -112,7 +114,7 @@ func (e *Service) handleRepository(ctx context.Context, repositoryID int, cfg ex
|
||||
// out new uploads that would happen to be visible to no commits since they were never
|
||||
// installed into the commit graph.
|
||||
|
||||
uploads, _, err := e.GetUploads(ctx, types.GetUploadsOptions{
|
||||
uploads, _, err := e.GetUploads(ctx, shared.GetUploadsOptions{
|
||||
State: "completed",
|
||||
RepositoryID: repositoryID,
|
||||
AllowExpired: false,
|
||||
@ -144,7 +146,7 @@ func (e *Service) buildCommitMap(ctx context.Context, repositoryID int, cfg expi
|
||||
|
||||
for {
|
||||
// Retrieve the complete set of configuration policies that affect data retention for this repository
|
||||
policyBatch, totalCount, err := e.policySvc.GetConfigurationPolicies(ctx, types.GetConfigurationPoliciesOptions{
|
||||
policyBatch, totalCount, err := e.policySvc.GetConfigurationPolicies(ctx, policiesshared.GetConfigurationPoliciesOptions{
|
||||
RepositoryID: repositoryID,
|
||||
ForDataRetention: true,
|
||||
Limit: cfg.policyBatchSize,
|
||||
|
||||
@ -8,11 +8,12 @@ import (
|
||||
|
||||
"github.com/derision-test/glock"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"github.com/sourcegraph/log/logtest"
|
||||
|
||||
policiesEnterprise "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
uploadsshared "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/observation"
|
||||
"github.com/sourcegraph/sourcegraph/internal/timeutil"
|
||||
)
|
||||
@ -99,7 +100,7 @@ func setupMockPolicyService() *MockPolicyService {
|
||||
{ID: 5, RepositoryID: intPtr(50)},
|
||||
}
|
||||
|
||||
getConfigurationPolicies := func(ctx context.Context, opts types.GetConfigurationPoliciesOptions) (filtered []types.ConfigurationPolicy, _ int, _ error) {
|
||||
getConfigurationPolicies := func(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) (filtered []types.ConfigurationPolicy, _ int, _ error) {
|
||||
for _, policy := range policies {
|
||||
if policy.RepositoryID == nil || *policy.RepositoryID == opts.RepositoryID {
|
||||
filtered = append(filtered, policy)
|
||||
@ -162,7 +163,7 @@ func setupMockUploadService(now time.Time) *MockStore {
|
||||
return scannedIDs, nil
|
||||
}
|
||||
|
||||
getUploads := func(ctx context.Context, opts types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
getUploads := func(ctx context.Context, opts uploadsshared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
var filtered []types.Upload
|
||||
for _, upload := range uploads {
|
||||
if upload.RepositoryID != opts.RepositoryID {
|
||||
|
||||
@ -11,8 +11,10 @@ import (
|
||||
"github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
sharedIndexes "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
policies "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
policiesshared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
codeintelgitserver "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/gitserver"
|
||||
codeinteltypes "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
sharedUploads "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/locker"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver"
|
||||
@ -58,7 +60,7 @@ type RepoStore interface {
|
||||
|
||||
type UploadServiceForExpiration interface {
|
||||
// Uploads
|
||||
GetUploads(ctx context.Context, opts codeinteltypes.GetUploadsOptions) (uploads []codeinteltypes.Upload, totalCount int, err error)
|
||||
GetUploads(ctx context.Context, opts shared.GetUploadsOptions) (uploads []codeinteltypes.Upload, totalCount int, err error)
|
||||
UpdateUploadRetention(ctx context.Context, protectedIDs, expiredIDs []int) (err error)
|
||||
BackfillReferenceCountBatch(ctx context.Context, batchSize int) error
|
||||
|
||||
@ -70,7 +72,7 @@ type UploadServiceForExpiration interface {
|
||||
}
|
||||
|
||||
type PolicyService interface {
|
||||
GetConfigurationPolicies(ctx context.Context, opts codeinteltypes.GetConfigurationPoliciesOptions) ([]codeinteltypes.ConfigurationPolicy, int, error)
|
||||
GetConfigurationPolicies(ctx context.Context, opts policiesshared.GetConfigurationPoliciesOptions) ([]codeinteltypes.ConfigurationPolicy, int, error)
|
||||
}
|
||||
|
||||
type PolicyMatcher interface {
|
||||
|
||||
@ -43,7 +43,7 @@ type Store interface {
|
||||
HasRepository(ctx context.Context, repositoryID int) (_ bool, err error)
|
||||
|
||||
// Uploads
|
||||
GetUploads(ctx context.Context, opts types.GetUploadsOptions) (_ []types.Upload, _ int, err error)
|
||||
GetUploads(ctx context.Context, opts shared.GetUploadsOptions) (_ []types.Upload, _ int, err error)
|
||||
GetUploadByID(ctx context.Context, id int) (_ types.Upload, _ bool, err error)
|
||||
GetUploadsByIDs(ctx context.Context, ids ...int) (_ []types.Upload, err error)
|
||||
GetUploadIDsWithReferences(ctx context.Context, orderedMonikers []precise.QualifiedMonikerData, ignoreIDs []int, repositoryID int, commit string, limit int, offset int, trace observation.TraceLogger) (ids []int, recordsScanned int, totalCount int, err error)
|
||||
@ -61,7 +61,7 @@ type Store interface {
|
||||
DeleteUploadsStuckUploading(ctx context.Context, uploadedBefore time.Time) (_ int, err error)
|
||||
DeleteUploadsWithoutRepository(ctx context.Context, now time.Time) (_ map[int]int, err error)
|
||||
DeleteUploadByID(ctx context.Context, id int) (_ bool, err error)
|
||||
DeleteUploads(ctx context.Context, opts types.DeleteUploadsOptions) (err error)
|
||||
DeleteUploads(ctx context.Context, opts shared.DeleteUploadsOptions) (err error)
|
||||
|
||||
// Uploads (uploading)
|
||||
InsertUpload(ctx context.Context, upload types.Upload) (int, error)
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
// GetUploads returns a list of uploads and the total count of records matching the given conditions.
|
||||
func (s *store) GetUploads(ctx context.Context, opts types.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error) {
|
||||
func (s *store) GetUploads(ctx context.Context, opts shared.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error) {
|
||||
ctx, trace, endObservation := s.operations.getUploads.With(ctx, &err, observation.Args{LogFields: buildGetUploadsLogFields(opts)})
|
||||
defer endObservation(1, observation.Args{})
|
||||
|
||||
@ -686,7 +686,7 @@ UPDATE lsif_uploads u SET state = CASE WHEN u.state = 'completed' THEN 'deleting
|
||||
|
||||
// DeleteUploads deletes uploads by filter criteria. The associated repositories will be marked as dirty
|
||||
// so that their commit graphs will be updated in the background.
|
||||
func (s *store) DeleteUploads(ctx context.Context, opts types.DeleteUploadsOptions) (err error) {
|
||||
func (s *store) DeleteUploads(ctx context.Context, opts shared.DeleteUploadsOptions) (err error) {
|
||||
ctx, _, endObservation := s.operations.deleteUploads.With(ctx, &err, observation.Args{LogFields: buildDeleteUploadsLogFields(opts)})
|
||||
defer endObservation(1, observation.Args{})
|
||||
|
||||
@ -1996,7 +1996,7 @@ func nilTimeToString(t *time.Time) string {
|
||||
return t.String()
|
||||
}
|
||||
|
||||
func buildGetConditionsAndCte(opts types.GetUploadsOptions) (*sqlf.Query, []*sqlf.Query, []cteDefinition) {
|
||||
func buildGetConditionsAndCte(opts shared.GetUploadsOptions) (*sqlf.Query, []*sqlf.Query, []cteDefinition) {
|
||||
conds := make([]*sqlf.Query, 0, 12)
|
||||
|
||||
allowDeletedUploads := (opts.AllowDeletedUpload && opts.State == "") || opts.State == "deleted"
|
||||
@ -2112,7 +2112,7 @@ func buildGetConditionsAndCte(opts types.GetUploadsOptions) (*sqlf.Query, []*sql
|
||||
return sourceTableExpr, conds, cteDefinitions
|
||||
}
|
||||
|
||||
func buildDeleteConditions(opts types.DeleteUploadsOptions) []*sqlf.Query {
|
||||
func buildDeleteConditions(opts shared.DeleteUploadsOptions) []*sqlf.Query {
|
||||
conds := []*sqlf.Query{}
|
||||
if opts.RepositoryID != 0 {
|
||||
conds = append(conds, sqlf.Sprintf("u.repository_id = %s", opts.RepositoryID))
|
||||
@ -2183,7 +2183,7 @@ func buildCTEPrefix(cteDefinitions []cteDefinition) *sqlf.Query {
|
||||
return sqlf.Sprintf("WITH\n%s", sqlf.Join(cteQueries, ",\n"))
|
||||
}
|
||||
|
||||
func buildGetUploadsLogFields(opts types.GetUploadsOptions) []log.Field {
|
||||
func buildGetUploadsLogFields(opts shared.GetUploadsOptions) []log.Field {
|
||||
return []log.Field{
|
||||
log.Int("repositoryID", opts.RepositoryID),
|
||||
log.String("state", opts.State),
|
||||
@ -2202,7 +2202,7 @@ func buildGetUploadsLogFields(opts types.GetUploadsOptions) []log.Field {
|
||||
}
|
||||
}
|
||||
|
||||
func buildDeleteUploadsLogFields(opts types.DeleteUploadsOptions) []log.Field {
|
||||
func buildDeleteUploadsLogFields(opts shared.DeleteUploadsOptions) []log.Field {
|
||||
return []log.Field{
|
||||
log.String("state", opts.State),
|
||||
log.String("term", opts.Term),
|
||||
|
||||
@ -179,7 +179,7 @@ func TestGetUploads(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
uploads, totalCount, err := store.GetUploads(ctx, types.GetUploadsOptions{
|
||||
uploads, totalCount, err := store.GetUploads(ctx, shared.GetUploadsOptions{
|
||||
RepositoryID: testCase.repositoryID,
|
||||
State: testCase.state,
|
||||
Term: testCase.term,
|
||||
@ -238,7 +238,7 @@ func TestGetUploads(t *testing.T) {
|
||||
defer globals.SetPermissionsUserMapping(before)
|
||||
|
||||
uploads, totalCount, err := store.GetUploads(ctx,
|
||||
types.GetUploadsOptions{
|
||||
shared.GetUploadsOptions{
|
||||
Limit: 1,
|
||||
},
|
||||
)
|
||||
@ -617,7 +617,7 @@ func TestDeleteUploadsStuckUploading(t *testing.T) {
|
||||
t.Errorf("unexpected count. want=%d have=%d", 2, count)
|
||||
}
|
||||
|
||||
uploads, totalCount, err := store.GetUploads(context.Background(), types.GetUploadsOptions{Limit: 5})
|
||||
uploads, totalCount, err := store.GetUploads(context.Background(), shared.GetUploadsOptions{Limit: 5})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting uploads: %s", err)
|
||||
}
|
||||
@ -657,7 +657,7 @@ func TestDeleteUploads(t *testing.T) {
|
||||
types.Upload{ID: 5, Commit: makeCommit(1115), UploadedAt: t5, State: "uploading"}, // will be deleted
|
||||
)
|
||||
|
||||
err := store.DeleteUploads(context.Background(), types.DeleteUploadsOptions{
|
||||
err := store.DeleteUploads(context.Background(), shared.DeleteUploadsOptions{
|
||||
State: "uploading",
|
||||
Term: "",
|
||||
VisibleAtTip: false,
|
||||
@ -666,7 +666,7 @@ func TestDeleteUploads(t *testing.T) {
|
||||
t.Fatalf("unexpected error deleting uploads: %s", err)
|
||||
}
|
||||
|
||||
uploads, totalCount, err := store.GetUploads(context.Background(), types.GetUploadsOptions{Limit: 5})
|
||||
uploads, totalCount, err := store.GetUploads(context.Background(), shared.GetUploadsOptions{Limit: 5})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting uploads: %s", err)
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
authz "github.com/sourcegraph/sourcegraph/internal/authz"
|
||||
shared1 "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
enterprise "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/enterprise"
|
||||
shared2 "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
|
||||
types "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
lsifstore "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/lsifstore"
|
||||
store "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/store"
|
||||
@ -248,7 +249,7 @@ func NewMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
DeleteUploadsFunc: &StoreDeleteUploadsFunc{
|
||||
defaultHook: func(context.Context, types.DeleteUploadsOptions) (r0 error) {
|
||||
defaultHook: func(context.Context, shared.DeleteUploadsOptions) (r0 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -348,7 +349,7 @@ func NewMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &StoreGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -520,7 +521,7 @@ func NewStrictMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
DeleteUploadsFunc: &StoreDeleteUploadsFunc{
|
||||
defaultHook: func(context.Context, types.DeleteUploadsOptions) error {
|
||||
defaultHook: func(context.Context, shared.DeleteUploadsOptions) error {
|
||||
panic("unexpected invocation of MockStore.DeleteUploads")
|
||||
},
|
||||
},
|
||||
@ -620,7 +621,7 @@ func NewStrictMockStore() *MockStore {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &StoreGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
panic("unexpected invocation of MockStore.GetUploads")
|
||||
},
|
||||
},
|
||||
@ -1595,15 +1596,15 @@ func (c StoreDeleteUploadByIDFuncCall) Results() []interface{} {
|
||||
// StoreDeleteUploadsFunc describes the behavior when the DeleteUploads
|
||||
// method of the parent MockStore instance is invoked.
|
||||
type StoreDeleteUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.DeleteUploadsOptions) error
|
||||
hooks []func(context.Context, types.DeleteUploadsOptions) error
|
||||
defaultHook func(context.Context, shared.DeleteUploadsOptions) error
|
||||
hooks []func(context.Context, shared.DeleteUploadsOptions) error
|
||||
history []StoreDeleteUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// DeleteUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockStore) DeleteUploads(v0 context.Context, v1 types.DeleteUploadsOptions) error {
|
||||
func (m *MockStore) DeleteUploads(v0 context.Context, v1 shared.DeleteUploadsOptions) error {
|
||||
r0 := m.DeleteUploadsFunc.nextHook()(v0, v1)
|
||||
m.DeleteUploadsFunc.appendCall(StoreDeleteUploadsFuncCall{v0, v1, r0})
|
||||
return r0
|
||||
@ -1611,7 +1612,7 @@ func (m *MockStore) DeleteUploads(v0 context.Context, v1 types.DeleteUploadsOpti
|
||||
|
||||
// SetDefaultHook sets function that is called when the DeleteUploads method
|
||||
// of the parent MockStore instance is invoked and the hook queue is empty.
|
||||
func (f *StoreDeleteUploadsFunc) SetDefaultHook(hook func(context.Context, types.DeleteUploadsOptions) error) {
|
||||
func (f *StoreDeleteUploadsFunc) SetDefaultHook(hook func(context.Context, shared.DeleteUploadsOptions) error) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1619,7 +1620,7 @@ func (f *StoreDeleteUploadsFunc) SetDefaultHook(hook func(context.Context, types
|
||||
// DeleteUploads method of the parent MockStore instance invokes the hook at
|
||||
// the front of the queue and discards it. After the queue is empty, the
|
||||
// default hook function is invoked for any future action.
|
||||
func (f *StoreDeleteUploadsFunc) PushHook(hook func(context.Context, types.DeleteUploadsOptions) error) {
|
||||
func (f *StoreDeleteUploadsFunc) PushHook(hook func(context.Context, shared.DeleteUploadsOptions) error) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1628,19 +1629,19 @@ func (f *StoreDeleteUploadsFunc) PushHook(hook func(context.Context, types.Delet
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *StoreDeleteUploadsFunc) SetDefaultReturn(r0 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.DeleteUploadsOptions) error {
|
||||
f.SetDefaultHook(func(context.Context, shared.DeleteUploadsOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *StoreDeleteUploadsFunc) PushReturn(r0 error) {
|
||||
f.PushHook(func(context.Context, types.DeleteUploadsOptions) error {
|
||||
f.PushHook(func(context.Context, shared.DeleteUploadsOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
func (f *StoreDeleteUploadsFunc) nextHook() func(context.Context, types.DeleteUploadsOptions) error {
|
||||
func (f *StoreDeleteUploadsFunc) nextHook() func(context.Context, shared.DeleteUploadsOptions) error {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1678,7 +1679,7 @@ type StoreDeleteUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.DeleteUploadsOptions
|
||||
Arg1 shared.DeleteUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 error
|
||||
@ -3862,15 +3863,15 @@ func (c StoreGetUploadIDsWithReferencesFuncCall) Results() []interface{} {
|
||||
// StoreGetUploadsFunc describes the behavior when the GetUploads method of
|
||||
// the parent MockStore instance is invoked.
|
||||
type StoreGetUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
defaultHook func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
history []StoreGetUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockStore) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (m *MockStore) GetUploads(v0 context.Context, v1 shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
r0, r1, r2 := m.GetUploadsFunc.nextHook()(v0, v1)
|
||||
m.GetUploadsFunc.appendCall(StoreGetUploadsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -3878,7 +3879,7 @@ func (m *MockStore) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) (
|
||||
|
||||
// SetDefaultHook sets function that is called when the GetUploads method of
|
||||
// the parent MockStore instance is invoked and the hook queue is empty.
|
||||
func (f *StoreGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *StoreGetUploadsFunc) SetDefaultHook(hook func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -3886,7 +3887,7 @@ func (f *StoreGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.Ge
|
||||
// GetUploads method of the parent MockStore instance invokes the hook at
|
||||
// the front of the queue and discards it. After the queue is empty, the
|
||||
// default hook function is invoked for any future action.
|
||||
func (f *StoreGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *StoreGetUploadsFunc) PushHook(hook func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -3895,19 +3896,19 @@ func (f *StoreGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploa
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *StoreGetUploadsFunc) SetDefaultReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *StoreGetUploadsFunc) PushReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *StoreGetUploadsFunc) nextHook() func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (f *StoreGetUploadsFunc) nextHook() func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -3945,7 +3946,7 @@ type StoreGetUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetUploadsOptions
|
||||
Arg1 shared.GetUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Upload
|
||||
@ -11173,7 +11174,7 @@ type MockPolicyService struct {
|
||||
func NewMockPolicyService() *MockPolicyService {
|
||||
return &MockPolicyService{
|
||||
GetConfigurationPoliciesFunc: &PolicyServiceGetConfigurationPoliciesFunc{
|
||||
defaultHook: func(context.Context, types.GetConfigurationPoliciesOptions) (r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared2.GetConfigurationPoliciesOptions) (r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -11185,7 +11186,7 @@ func NewMockPolicyService() *MockPolicyService {
|
||||
func NewStrictMockPolicyService() *MockPolicyService {
|
||||
return &MockPolicyService{
|
||||
GetConfigurationPoliciesFunc: &PolicyServiceGetConfigurationPoliciesFunc{
|
||||
defaultHook: func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
defaultHook: func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
panic("unexpected invocation of MockPolicyService.GetConfigurationPolicies")
|
||||
},
|
||||
},
|
||||
@ -11207,15 +11208,15 @@ func NewMockPolicyServiceFrom(i PolicyService) *MockPolicyService {
|
||||
// GetConfigurationPolicies method of the parent MockPolicyService instance
|
||||
// is invoked.
|
||||
type PolicyServiceGetConfigurationPoliciesFunc struct {
|
||||
defaultHook func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
hooks []func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
defaultHook func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
hooks []func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)
|
||||
history []PolicyServiceGetConfigurationPoliciesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetConfigurationPolicies delegates to the next hook function in the queue
|
||||
// and stores the parameter and result values of this invocation.
|
||||
func (m *MockPolicyService) GetConfigurationPolicies(v0 context.Context, v1 types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
func (m *MockPolicyService) GetConfigurationPolicies(v0 context.Context, v1 shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
r0, r1, r2 := m.GetConfigurationPoliciesFunc.nextHook()(v0, v1)
|
||||
m.GetConfigurationPoliciesFunc.appendCall(PolicyServiceGetConfigurationPoliciesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -11224,7 +11225,7 @@ func (m *MockPolicyService) GetConfigurationPolicies(v0 context.Context, v1 type
|
||||
// SetDefaultHook sets function that is called when the
|
||||
// GetConfigurationPolicies method of the parent MockPolicyService instance
|
||||
// is invoked and the hook queue is empty.
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) SetDefaultHook(hook func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) SetDefaultHook(hook func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -11233,7 +11234,7 @@ func (f *PolicyServiceGetConfigurationPoliciesFunc) SetDefaultHook(hook func(con
|
||||
// invokes the hook at the front of the queue and discards it. After the
|
||||
// queue is empty, the default hook function is invoked for any future
|
||||
// action.
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) PushHook(hook func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) PushHook(hook func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -11242,19 +11243,19 @@ func (f *PolicyServiceGetConfigurationPoliciesFunc) PushHook(hook func(context.C
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) SetDefaultReturn(r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) PushReturn(r0 []types.ConfigurationPolicy, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
f.PushHook(func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) nextHook() func(context.Context, types.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
func (f *PolicyServiceGetConfigurationPoliciesFunc) nextHook() func(context.Context, shared2.GetConfigurationPoliciesOptions) ([]types.ConfigurationPolicy, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -11294,7 +11295,7 @@ type PolicyServiceGetConfigurationPoliciesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetConfigurationPoliciesOptions
|
||||
Arg1 shared2.GetConfigurationPoliciesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.ConfigurationPolicy
|
||||
@ -12559,7 +12560,7 @@ func NewMockUploadServiceForExpiration() *MockUploadServiceForExpiration {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadServiceForExpirationGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -12592,7 +12593,7 @@ func NewStrictMockUploadServiceForExpiration() *MockUploadServiceForExpiration {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadServiceForExpirationGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
panic("unexpected invocation of MockUploadServiceForExpiration.GetUploads")
|
||||
},
|
||||
},
|
||||
@ -12868,15 +12869,15 @@ func (c UploadServiceForExpirationGetCommitsVisibleToUploadFuncCall) Results() [
|
||||
// GetUploads method of the parent MockUploadServiceForExpiration instance
|
||||
// is invoked.
|
||||
type UploadServiceForExpirationGetUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
defaultHook func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
history []UploadServiceForExpirationGetUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockUploadServiceForExpiration) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (m *MockUploadServiceForExpiration) GetUploads(v0 context.Context, v1 shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
r0, r1, r2 := m.GetUploadsFunc.nextHook()(v0, v1)
|
||||
m.GetUploadsFunc.appendCall(UploadServiceForExpirationGetUploadsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -12885,7 +12886,7 @@ func (m *MockUploadServiceForExpiration) GetUploads(v0 context.Context, v1 types
|
||||
// SetDefaultHook sets function that is called when the GetUploads method of
|
||||
// the parent MockUploadServiceForExpiration instance is invoked and the
|
||||
// hook queue is empty.
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) SetDefaultHook(hook func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -12894,7 +12895,7 @@ func (f *UploadServiceForExpirationGetUploadsFunc) SetDefaultHook(hook func(cont
|
||||
// invokes the hook at the front of the queue and discards it. After the
|
||||
// queue is empty, the default hook function is invoked for any future
|
||||
// action.
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) PushHook(hook func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -12903,19 +12904,19 @@ func (f *UploadServiceForExpirationGetUploadsFunc) PushHook(hook func(context.Co
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) SetDefaultReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) PushReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) nextHook() func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (f *UploadServiceForExpirationGetUploadsFunc) nextHook() func(context.Context, shared.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -12955,7 +12956,7 @@ type UploadServiceForExpirationGetUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetUploadsOptions
|
||||
Arg1 shared.GetUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Upload
|
||||
|
||||
@ -121,7 +121,7 @@ func (s *Service) GetDirtyRepositories(ctx context.Context) (_ map[int]int, err
|
||||
return s.store.GetDirtyRepositories(ctx)
|
||||
}
|
||||
|
||||
func (s *Service) GetUploads(ctx context.Context, opts types.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error) {
|
||||
func (s *Service) GetUploads(ctx context.Context, opts shared.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error) {
|
||||
ctx, _, endObservation := s.operations.getUploads.With(ctx, &err, observation.Args{
|
||||
LogFields: []log.Field{log.Int("repositoryID", opts.RepositoryID), log.String("state", opts.State), log.String("term", opts.Term)},
|
||||
})
|
||||
@ -168,7 +168,7 @@ func (s *Service) DeleteUploadByID(ctx context.Context, id int) (_ bool, err err
|
||||
return s.store.DeleteUploadByID(ctx, id)
|
||||
}
|
||||
|
||||
func (s *Service) DeleteUploads(ctx context.Context, opts types.DeleteUploadsOptions) (err error) {
|
||||
func (s *Service) DeleteUploads(ctx context.Context, opts shared.DeleteUploadsOptions) (err error) {
|
||||
ctx, _, endObservation := s.operations.deleteUploadByID.With(ctx, &err, observation.Args{})
|
||||
defer endObservation(1, observation.Args{})
|
||||
|
||||
|
||||
@ -2,13 +2,10 @@ package shared
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
)
|
||||
|
||||
type SourcedCommits struct {
|
||||
@ -41,6 +38,7 @@ type GetUploadsOptions struct {
|
||||
}
|
||||
|
||||
type DeleteUploadsOptions struct {
|
||||
RepositoryID int
|
||||
State string
|
||||
Term string
|
||||
VisibleAtTip bool
|
||||
@ -191,71 +189,3 @@ type UploadLog struct {
|
||||
Reason *string
|
||||
Operation string
|
||||
}
|
||||
|
||||
// Index is a subset of the lsif_indexes table and stores both processed and unprocessed
|
||||
// records.
|
||||
type Index struct {
|
||||
ID int `json:"id"`
|
||||
Commit string `json:"commit"`
|
||||
QueuedAt time.Time `json:"queuedAt"`
|
||||
State string `json:"state"`
|
||||
FailureMessage *string `json:"failureMessage"`
|
||||
StartedAt *time.Time `json:"startedAt"`
|
||||
FinishedAt *time.Time `json:"finishedAt"`
|
||||
ProcessAfter *time.Time `json:"processAfter"`
|
||||
NumResets int `json:"numResets"`
|
||||
NumFailures int `json:"numFailures"`
|
||||
RepositoryID int `json:"repositoryId"`
|
||||
LocalSteps []string `json:"local_steps"`
|
||||
RepositoryName string `json:"repositoryName"`
|
||||
DockerSteps []DockerStep `json:"docker_steps"`
|
||||
Root string `json:"root"`
|
||||
Indexer string `json:"indexer"`
|
||||
IndexerArgs []string `json:"indexer_args"` // TODO - convert this to `IndexCommand string`
|
||||
Outfile string `json:"outfile"`
|
||||
ExecutionLogs []ExecutionLogEntry `json:"execution_logs"`
|
||||
Rank *int `json:"placeInQueue"`
|
||||
AssociatedUploadID *int `json:"associatedUpload"`
|
||||
}
|
||||
|
||||
type DockerStep struct {
|
||||
Root string `json:"root"`
|
||||
Image string `json:"image"`
|
||||
Commands []string `json:"commands"`
|
||||
}
|
||||
|
||||
func (s *DockerStep) Scan(value any) error {
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return errors.Errorf("value is not []byte: %T", value)
|
||||
}
|
||||
|
||||
return json.Unmarshal(b, &s)
|
||||
}
|
||||
|
||||
func (s DockerStep) Value() (driver.Value, error) {
|
||||
return json.Marshal(s)
|
||||
}
|
||||
|
||||
// ExecutionLogEntry represents a command run by the executor.
|
||||
type ExecutionLogEntry struct {
|
||||
Key string `json:"key"`
|
||||
Command []string `json:"command"`
|
||||
StartTime time.Time `json:"startTime"`
|
||||
ExitCode *int `json:"exitCode,omitempty"`
|
||||
Out string `json:"out,omitempty"`
|
||||
DurationMs *int `json:"durationMs,omitempty"`
|
||||
}
|
||||
|
||||
func (e *ExecutionLogEntry) Scan(value any) error {
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return errors.Errorf("value is not []byte: %T", value)
|
||||
}
|
||||
|
||||
return json.Unmarshal(b, &e)
|
||||
}
|
||||
|
||||
func (e ExecutionLogEntry) Value() (driver.Value, error) {
|
||||
return json.Marshal(e)
|
||||
}
|
||||
|
||||
@ -5,7 +5,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
uploadsshared "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
)
|
||||
@ -15,15 +17,15 @@ type UploadService interface {
|
||||
GetAuditLogsForUpload(ctx context.Context, uploadID int) (_ []types.UploadLog, err error)
|
||||
GetListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
GetUploadDocumentsForPath(ctx context.Context, bundleID int, pathPattern string) (_ []string, _ int, err error)
|
||||
GetUploads(ctx context.Context, opts types.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetUploads(ctx context.Context, opts uploadsshared.GetUploadsOptions) (uploads []types.Upload, totalCount int, err error)
|
||||
GetUploadsByIDs(ctx context.Context, ids ...int) (_ []types.Upload, err error)
|
||||
DeleteUploadByID(ctx context.Context, id int) (_ bool, err error)
|
||||
DeleteUploads(ctx context.Context, opts types.DeleteUploadsOptions) (err error)
|
||||
DeleteUploads(ctx context.Context, opts uploadsshared.DeleteUploadsOptions) (err error)
|
||||
}
|
||||
|
||||
type AutoIndexingService interface {
|
||||
GetIndexByID(ctx context.Context, id int) (_ types.Index, _ bool, err error)
|
||||
GetIndexes(ctx context.Context, opts types.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexes(ctx context.Context, opts shared.GetIndexesOptions) (_ []types.Index, _ int, err error)
|
||||
GetIndexesByIDs(ctx context.Context, ids ...int) (_ []types.Index, err error)
|
||||
GetListTags(ctx context.Context, repo api.RepoName, commitObjs ...string) (_ []*gitdomain.Tag, err error)
|
||||
GetUnsafeDB() database.DB
|
||||
|
||||
@ -12,7 +12,9 @@ import (
|
||||
"time"
|
||||
|
||||
api "github.com/sourcegraph/sourcegraph/internal/api"
|
||||
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared"
|
||||
types "github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
shared1 "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
database "github.com/sourcegraph/sourcegraph/internal/database"
|
||||
gitdomain "github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
|
||||
)
|
||||
@ -50,7 +52,7 @@ func NewMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) (r0 []types.Index, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -83,7 +85,7 @@ func NewStrictMockAutoIndexingService() *MockAutoIndexingService {
|
||||
},
|
||||
},
|
||||
GetIndexesFunc: &AutoIndexingServiceGetIndexesFunc{
|
||||
defaultHook: func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
defaultHook: func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
panic("unexpected invocation of MockAutoIndexingService.GetIndexes")
|
||||
},
|
||||
},
|
||||
@ -246,15 +248,15 @@ func (c AutoIndexingServiceGetIndexByIDFuncCall) Results() []interface{} {
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance is
|
||||
// invoked.
|
||||
type AutoIndexingServiceGetIndexesFunc struct {
|
||||
defaultHook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)
|
||||
defaultHook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
hooks []func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)
|
||||
history []AutoIndexingServiceGetIndexesFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetIndexes delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
r0, r1, r2 := m.GetIndexesFunc.nextHook()(v0, v1)
|
||||
m.GetIndexesFunc.appendCall(AutoIndexingServiceGetIndexesFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -263,7 +265,7 @@ func (m *MockAutoIndexingService) GetIndexes(v0 context.Context, v1 types.GetInd
|
||||
// SetDefaultHook sets function that is called when the GetIndexes method of
|
||||
// the parent MockAutoIndexingService instance is invoked and the hook queue
|
||||
// is empty.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -271,7 +273,7 @@ func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultHook(hook func(context.Con
|
||||
// GetIndexes method of the parent MockAutoIndexingService instance invokes
|
||||
// the hook at the front of the queue and discards it. After the queue is
|
||||
// empty, the default hook function is invoked for any future action.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -280,19 +282,19 @@ func (f *AutoIndexingServiceGetIndexesFunc) PushHook(hook func(context.Context,
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) SetDefaultReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) PushReturn(r0 []types.Index, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.PushHook(func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, types.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
func (f *AutoIndexingServiceGetIndexesFunc) nextHook() func(context.Context, shared.GetIndexesOptions) ([]types.Index, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -331,7 +333,7 @@ type AutoIndexingServiceGetIndexesFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetIndexesOptions
|
||||
Arg1 shared.GetIndexesOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Index
|
||||
@ -912,7 +914,7 @@ func NewMockUploadService() *MockUploadService {
|
||||
},
|
||||
},
|
||||
DeleteUploadsFunc: &UploadServiceDeleteUploadsFunc{
|
||||
defaultHook: func(context.Context, types.DeleteUploadsOptions) (r0 error) {
|
||||
defaultHook: func(context.Context, shared1.DeleteUploadsOptions) (r0 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -937,7 +939,7 @@ func NewMockUploadService() *MockUploadService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
defaultHook: func(context.Context, shared1.GetUploadsOptions) (r0 []types.Upload, r1 int, r2 error) {
|
||||
return
|
||||
},
|
||||
},
|
||||
@ -959,7 +961,7 @@ func NewStrictMockUploadService() *MockUploadService {
|
||||
},
|
||||
},
|
||||
DeleteUploadsFunc: &UploadServiceDeleteUploadsFunc{
|
||||
defaultHook: func(context.Context, types.DeleteUploadsOptions) error {
|
||||
defaultHook: func(context.Context, shared1.DeleteUploadsOptions) error {
|
||||
panic("unexpected invocation of MockUploadService.DeleteUploads")
|
||||
},
|
||||
},
|
||||
@ -984,7 +986,7 @@ func NewStrictMockUploadService() *MockUploadService {
|
||||
},
|
||||
},
|
||||
GetUploadsFunc: &UploadServiceGetUploadsFunc{
|
||||
defaultHook: func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
defaultHook: func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
panic("unexpected invocation of MockUploadService.GetUploads")
|
||||
},
|
||||
},
|
||||
@ -1141,15 +1143,15 @@ func (c UploadServiceDeleteUploadByIDFuncCall) Results() []interface{} {
|
||||
// UploadServiceDeleteUploadsFunc describes the behavior when the
|
||||
// DeleteUploads method of the parent MockUploadService instance is invoked.
|
||||
type UploadServiceDeleteUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.DeleteUploadsOptions) error
|
||||
hooks []func(context.Context, types.DeleteUploadsOptions) error
|
||||
defaultHook func(context.Context, shared1.DeleteUploadsOptions) error
|
||||
hooks []func(context.Context, shared1.DeleteUploadsOptions) error
|
||||
history []UploadServiceDeleteUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// DeleteUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockUploadService) DeleteUploads(v0 context.Context, v1 types.DeleteUploadsOptions) error {
|
||||
func (m *MockUploadService) DeleteUploads(v0 context.Context, v1 shared1.DeleteUploadsOptions) error {
|
||||
r0 := m.DeleteUploadsFunc.nextHook()(v0, v1)
|
||||
m.DeleteUploadsFunc.appendCall(UploadServiceDeleteUploadsFuncCall{v0, v1, r0})
|
||||
return r0
|
||||
@ -1158,7 +1160,7 @@ func (m *MockUploadService) DeleteUploads(v0 context.Context, v1 types.DeleteUpl
|
||||
// SetDefaultHook sets function that is called when the DeleteUploads method
|
||||
// of the parent MockUploadService instance is invoked and the hook queue is
|
||||
// empty.
|
||||
func (f *UploadServiceDeleteUploadsFunc) SetDefaultHook(hook func(context.Context, types.DeleteUploadsOptions) error) {
|
||||
func (f *UploadServiceDeleteUploadsFunc) SetDefaultHook(hook func(context.Context, shared1.DeleteUploadsOptions) error) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1166,7 +1168,7 @@ func (f *UploadServiceDeleteUploadsFunc) SetDefaultHook(hook func(context.Contex
|
||||
// DeleteUploads method of the parent MockUploadService instance invokes the
|
||||
// hook at the front of the queue and discards it. After the queue is empty,
|
||||
// the default hook function is invoked for any future action.
|
||||
func (f *UploadServiceDeleteUploadsFunc) PushHook(hook func(context.Context, types.DeleteUploadsOptions) error) {
|
||||
func (f *UploadServiceDeleteUploadsFunc) PushHook(hook func(context.Context, shared1.DeleteUploadsOptions) error) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1175,19 +1177,19 @@ func (f *UploadServiceDeleteUploadsFunc) PushHook(hook func(context.Context, typ
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *UploadServiceDeleteUploadsFunc) SetDefaultReturn(r0 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.DeleteUploadsOptions) error {
|
||||
f.SetDefaultHook(func(context.Context, shared1.DeleteUploadsOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *UploadServiceDeleteUploadsFunc) PushReturn(r0 error) {
|
||||
f.PushHook(func(context.Context, types.DeleteUploadsOptions) error {
|
||||
f.PushHook(func(context.Context, shared1.DeleteUploadsOptions) error {
|
||||
return r0
|
||||
})
|
||||
}
|
||||
|
||||
func (f *UploadServiceDeleteUploadsFunc) nextHook() func(context.Context, types.DeleteUploadsOptions) error {
|
||||
func (f *UploadServiceDeleteUploadsFunc) nextHook() func(context.Context, shared1.DeleteUploadsOptions) error {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1225,7 +1227,7 @@ type UploadServiceDeleteUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.DeleteUploadsOptions
|
||||
Arg1 shared1.DeleteUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 error
|
||||
@ -1707,15 +1709,15 @@ func (c UploadServiceGetUploadDocumentsForPathFuncCall) Results() []interface{}
|
||||
// UploadServiceGetUploadsFunc describes the behavior when the GetUploads
|
||||
// method of the parent MockUploadService instance is invoked.
|
||||
type UploadServiceGetUploadsFunc struct {
|
||||
defaultHook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
defaultHook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
hooks []func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)
|
||||
history []UploadServiceGetUploadsFuncCall
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetUploads delegates to the next hook function in the queue and stores
|
||||
// the parameter and result values of this invocation.
|
||||
func (m *MockUploadService) GetUploads(v0 context.Context, v1 types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (m *MockUploadService) GetUploads(v0 context.Context, v1 shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
r0, r1, r2 := m.GetUploadsFunc.nextHook()(v0, v1)
|
||||
m.GetUploadsFunc.appendCall(UploadServiceGetUploadsFuncCall{v0, v1, r0, r1, r2})
|
||||
return r0, r1, r2
|
||||
@ -1724,7 +1726,7 @@ func (m *MockUploadService) GetUploads(v0 context.Context, v1 types.GetUploadsOp
|
||||
// SetDefaultHook sets function that is called when the GetUploads method of
|
||||
// the parent MockUploadService instance is invoked and the hook queue is
|
||||
// empty.
|
||||
func (f *UploadServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.defaultHook = hook
|
||||
}
|
||||
|
||||
@ -1732,7 +1734,7 @@ func (f *UploadServiceGetUploadsFunc) SetDefaultHook(hook func(context.Context,
|
||||
// GetUploads method of the parent MockUploadService instance invokes the
|
||||
// hook at the front of the queue and discards it. After the queue is empty,
|
||||
// the default hook function is invoked for any future action.
|
||||
func (f *UploadServiceGetUploadsFunc) PushHook(hook func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
func (f *UploadServiceGetUploadsFunc) PushHook(hook func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error)) {
|
||||
f.mutex.Lock()
|
||||
f.hooks = append(f.hooks, hook)
|
||||
f.mutex.Unlock()
|
||||
@ -1741,19 +1743,19 @@ func (f *UploadServiceGetUploadsFunc) PushHook(hook func(context.Context, types.
|
||||
// SetDefaultReturn calls SetDefaultHook with a function that returns the
|
||||
// given values.
|
||||
func (f *UploadServiceGetUploadsFunc) SetDefaultReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.SetDefaultHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.SetDefaultHook(func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
// PushReturn calls PushHook with a function that returns the given values.
|
||||
func (f *UploadServiceGetUploadsFunc) PushReturn(r0 []types.Upload, r1 int, r2 error) {
|
||||
f.PushHook(func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.PushHook(func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
return r0, r1, r2
|
||||
})
|
||||
}
|
||||
|
||||
func (f *UploadServiceGetUploadsFunc) nextHook() func(context.Context, types.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
func (f *UploadServiceGetUploadsFunc) nextHook() func(context.Context, shared1.GetUploadsOptions) ([]types.Upload, int, error) {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
@ -1791,7 +1793,7 @@ type UploadServiceGetUploadsFuncCall struct {
|
||||
Arg0 context.Context
|
||||
// Arg1 is the value of the 2nd argument passed to this method
|
||||
// invocation.
|
||||
Arg1 types.GetUploadsOptions
|
||||
Arg1 shared1.GetUploadsOptions
|
||||
// Result0 is the value of the 1st result returned from this method
|
||||
// invocation.
|
||||
Result0 []types.Upload
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/graph-gophers/graphql-go/relay"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/api"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
"github.com/sourcegraph/sourcegraph/internal/database"
|
||||
"github.com/sourcegraph/sourcegraph/lib/errors"
|
||||
)
|
||||
@ -79,17 +79,17 @@ const DefaultUploadPageSize = 50
|
||||
|
||||
// makeGetUploadsOptions translates the given GraphQL arguments into options defined by the
|
||||
// store.GetUploads operations.
|
||||
func makeGetUploadsOptions(args *LSIFRepositoryUploadsQueryArgs) (types.GetUploadsOptions, error) {
|
||||
func makeGetUploadsOptions(args *LSIFRepositoryUploadsQueryArgs) (shared.GetUploadsOptions, error) {
|
||||
repositoryID, err := resolveRepositoryID(args.RepositoryID)
|
||||
if err != nil {
|
||||
return types.GetUploadsOptions{}, err
|
||||
return shared.GetUploadsOptions{}, err
|
||||
}
|
||||
|
||||
var dependencyOf int64
|
||||
if args.DependencyOf != nil {
|
||||
dependencyOf, err = unmarshalLSIFUploadGQLID(*args.DependencyOf)
|
||||
if err != nil {
|
||||
return types.GetUploadsOptions{}, err
|
||||
return shared.GetUploadsOptions{}, err
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,16 +97,16 @@ func makeGetUploadsOptions(args *LSIFRepositoryUploadsQueryArgs) (types.GetUploa
|
||||
if args.DependentOf != nil {
|
||||
dependentOf, err = unmarshalLSIFUploadGQLID(*args.DependentOf)
|
||||
if err != nil {
|
||||
return types.GetUploadsOptions{}, err
|
||||
return shared.GetUploadsOptions{}, err
|
||||
}
|
||||
}
|
||||
|
||||
offset, err := decodeIntCursor(args.After)
|
||||
if err != nil {
|
||||
return types.GetUploadsOptions{}, err
|
||||
return shared.GetUploadsOptions{}, err
|
||||
}
|
||||
|
||||
return types.GetUploadsOptions{
|
||||
return shared.GetUploadsOptions{
|
||||
RepositoryID: repositoryID,
|
||||
State: strings.ToLower(derefString(args.State, "")),
|
||||
Term: derefString(args.Query, ""),
|
||||
@ -122,17 +122,17 @@ func makeGetUploadsOptions(args *LSIFRepositoryUploadsQueryArgs) (types.GetUploa
|
||||
|
||||
// makeDeleteUploadsOptions translates the given GraphQL arguments into options defined by the
|
||||
// store.DeleteUploads operations.
|
||||
func makeDeleteUploadsOptions(args *DeleteLSIFUploadsArgs) (types.DeleteUploadsOptions, error) {
|
||||
func makeDeleteUploadsOptions(args *DeleteLSIFUploadsArgs) (shared.DeleteUploadsOptions, error) {
|
||||
var repository int
|
||||
if args.Repository != nil {
|
||||
var err error
|
||||
repository, err = resolveRepositoryID(*args.Repository)
|
||||
if err != nil {
|
||||
return types.DeleteUploadsOptions{}, err
|
||||
return shared.DeleteUploadsOptions{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return types.DeleteUploadsOptions{
|
||||
return shared.DeleteUploadsOptions{
|
||||
State: strings.ToLower(derefString(args.State, "")),
|
||||
Term: derefString(args.Query, ""),
|
||||
VisibleAtTip: derefBool(args.IsLatestForRepo, false),
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"github.com/graph-gophers/graphql-go"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend/graphqlutil"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/shared/types"
|
||||
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
|
||||
)
|
||||
|
||||
func TestMakeGetUploadsOptions(t *testing.T) {
|
||||
@ -28,7 +28,7 @@ func TestMakeGetUploadsOptions(t *testing.T) {
|
||||
t.Fatalf("unexpected error making options: %s", err)
|
||||
}
|
||||
|
||||
expected := types.GetUploadsOptions{
|
||||
expected := shared.GetUploadsOptions{
|
||||
RepositoryID: 50,
|
||||
State: "s",
|
||||
Term: "q",
|
||||
@ -50,7 +50,7 @@ func TestMakeGetUploadsOptionsDefaults(t *testing.T) {
|
||||
t.Fatalf("unexpected error making options: %s", err)
|
||||
}
|
||||
|
||||
expected := types.GetUploadsOptions{
|
||||
expected := shared.GetUploadsOptions{
|
||||
RepositoryID: 0,
|
||||
State: "",
|
||||
Term: "",
|
||||
|
||||
@ -77,17 +77,17 @@
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/store
|
||||
interfaces:
|
||||
- Store
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared
|
||||
interfaces:
|
||||
- RepoUpdaterClient
|
||||
- GitServerClient
|
||||
- UploadService
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/background
|
||||
interfaces:
|
||||
- DependenciesService
|
||||
- ReposStore
|
||||
- ExternalServiceStore
|
||||
- GitserverRepoStore
|
||||
- PolicyMatcher
|
||||
- RepoUpdaterClient
|
||||
- GitserverClient
|
||||
- InferenceService
|
||||
- UploadService
|
||||
- AutoIndexingService
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared
|
||||
interfaces:
|
||||
@ -107,14 +107,13 @@
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/store
|
||||
interfaces:
|
||||
- Store
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/shared
|
||||
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing
|
||||
interfaces:
|
||||
- GitServerClient
|
||||
- GitserverClient
|
||||
- RepoUpdaterClient
|
||||
- InferenceService
|
||||
- UploadService
|
||||
|
||||
|
||||
- filename: internal/codeintel/autoindexing/internal/inference/mocks_test.go
|
||||
path: github.com/sourcegraph/sourcegraph/internal/codeintel/autoindexing/internal/inference
|
||||
interfaces:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user