Backport 63870 to 5.5.x (#63882)

See  https://github.com/sourcegraph/sourcegraph/pull/63870

cc @sourcegraph/release

## Test plan

Covered by existing tests

## Changelog

- Adds an experimental feature `commitGraphUpdates` to control how
upload visibility is calculated.
This commit is contained in:
Varun Gandhi 2024-07-18 01:45:36 +08:00 committed by GitHub
parent 21247e44ac
commit 6b8d334563
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 659 additions and 553 deletions

View File

@ -50,6 +50,7 @@ go_test(
tags = [TAG_PLATFORM_GRAPH],
deps = [
"//internal/api",
"//internal/codeintel/core",
"//internal/codeintel/policies/shared",
"//internal/codeintel/uploads/internal/commitgraph",
"//internal/codeintel/uploads/internal/lsifstore",

View File

@ -33,6 +33,7 @@ go_test(
tags = [TAG_PLATFORM_GRAPH],
deps = [
"//internal/api",
"//internal/codeintel/core",
"//internal/codeintel/uploads/internal/commitgraph",
"//internal/codeintel/uploads/internal/store",
"//internal/codeintel/uploads/shared",

View File

@ -12,6 +12,7 @@ import (
"time"
api "github.com/sourcegraph/sourcegraph/internal/api"
core "github.com/sourcegraph/sourcegraph/internal/codeintel/core"
commitgraph "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/commitgraph"
store "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/store"
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
@ -75,6 +76,10 @@ type MockStore struct {
// GetAuditLogsForUploadFunc is an instance of a mock function object
// controlling the behavior of the method GetAuditLogsForUpload.
GetAuditLogsForUploadFunc *StoreGetAuditLogsForUploadFunc
// GetCommitAndDateForOldestUploadFunc is an instance of a mock function
// object controlling the behavior of the method
// GetCommitAndDateForOldestUpload.
GetCommitAndDateForOldestUploadFunc *StoreGetCommitAndDateForOldestUploadFunc
// GetCommitGraphMetadataFunc is an instance of a mock function object
// controlling the behavior of the method GetCommitGraphMetadata.
GetCommitGraphMetadataFunc *StoreGetCommitGraphMetadataFunc
@ -108,9 +113,6 @@ type MockStore struct {
// function object controlling the behavior of the method
// GetLastUploadRetentionScanForRepository.
GetLastUploadRetentionScanForRepositoryFunc *StoreGetLastUploadRetentionScanForRepositoryFunc
// GetOldestCommitDateFunc is an instance of a mock function object
// controlling the behavior of the method GetOldestCommitDate.
GetOldestCommitDateFunc *StoreGetOldestCommitDateFunc
// GetRecentIndexesSummaryFunc is an instance of a mock function object
// controlling the behavior of the method GetRecentIndexesSummary.
GetRecentIndexesSummaryFunc *StoreGetRecentIndexesSummaryFunc
@ -315,6 +317,11 @@ func NewMockStore() *MockStore {
return
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (r0 core.Option[store.CommitWithDate], r1 error) {
return
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (r0 bool, r1 *time.Time, r2 error) {
return
@ -365,11 +372,6 @@ func NewMockStore() *MockStore {
return
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (r0 time.Time, r1 bool, r2 error) {
return
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) (r0 []shared.IndexesWithRepositoryNamespace, r1 error) {
return
@ -642,6 +644,11 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetAuditLogsForUpload")
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (core.Option[store.CommitWithDate], error) {
panic("unexpected invocation of MockStore.GetCommitAndDateForOldestUpload")
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (bool, *time.Time, error) {
panic("unexpected invocation of MockStore.GetCommitGraphMetadata")
@ -692,11 +699,6 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetLastUploadRetentionScanForRepository")
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (time.Time, bool, error) {
panic("unexpected invocation of MockStore.GetOldestCommitDate")
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) ([]shared.IndexesWithRepositoryNamespace, error) {
panic("unexpected invocation of MockStore.GetRecentIndexesSummary")
@ -941,6 +943,9 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetAuditLogsForUploadFunc: &StoreGetAuditLogsForUploadFunc{
defaultHook: i.GetAuditLogsForUpload,
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: i.GetCommitAndDateForOldestUpload,
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: i.GetCommitGraphMetadata,
},
@ -971,9 +976,6 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetLastUploadRetentionScanForRepositoryFunc: &StoreGetLastUploadRetentionScanForRepositoryFunc{
defaultHook: i.GetLastUploadRetentionScanForRepository,
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: i.GetOldestCommitDate,
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: i.GetRecentIndexesSummary,
},
@ -2651,6 +2653,118 @@ func (c StoreGetAuditLogsForUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitAndDateForOldestUploadFunc describes the behavior when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked.
type StoreGetCommitAndDateForOldestUploadFunc struct {
defaultHook func(context.Context, int) (core.Option[store.CommitWithDate], error)
hooks []func(context.Context, int) (core.Option[store.CommitWithDate], error)
history []StoreGetCommitAndDateForOldestUploadFuncCall
mutex sync.Mutex
}
// GetCommitAndDateForOldestUpload delegates to the next hook function in
// the queue and stores the parameter and result values of this invocation.
func (m *MockStore) GetCommitAndDateForOldestUpload(v0 context.Context, v1 int) (core.Option[store.CommitWithDate], error) {
r0, r1 := m.GetCommitAndDateForOldestUploadFunc.nextHook()(v0, v1)
m.GetCommitAndDateForOldestUploadFunc.appendCall(StoreGetCommitAndDateForOldestUploadFuncCall{v0, v1, r0, r1})
return r0, r1
}
// SetDefaultHook sets function that is called when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked and the hook queue is empty.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetCommitAndDateForOldestUpload 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 *StoreGetCommitAndDateForOldestUploadFunc) PushHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.SetDefaultHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) PushReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.PushHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) nextHook() func(context.Context, int) (core.Option[store.CommitWithDate], error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) appendCall(r0 StoreGetCommitAndDateForOldestUploadFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of
// StoreGetCommitAndDateForOldestUploadFuncCall objects describing the
// invocations of this function.
func (f *StoreGetCommitAndDateForOldestUploadFunc) History() []StoreGetCommitAndDateForOldestUploadFuncCall {
f.mutex.Lock()
history := make([]StoreGetCommitAndDateForOldestUploadFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetCommitAndDateForOldestUploadFuncCall is an object that describes
// an invocation of method GetCommitAndDateForOldestUpload on an instance of
// MockStore.
type StoreGetCommitAndDateForOldestUploadFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 core.Option[store.CommitWithDate]
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitGraphMetadataFunc describes the behavior when the
// GetCommitGraphMetadata method of the parent MockStore instance is
// invoked.
@ -3766,117 +3880,6 @@ func (c StoreGetLastUploadRetentionScanForRepositoryFuncCall) Results() []interf
return []interface{}{c.Result0, c.Result1}
}
// StoreGetOldestCommitDateFunc describes the behavior when the
// GetOldestCommitDate method of the parent MockStore instance is invoked.
type StoreGetOldestCommitDateFunc struct {
defaultHook func(context.Context, int) (time.Time, bool, error)
hooks []func(context.Context, int) (time.Time, bool, error)
history []StoreGetOldestCommitDateFuncCall
mutex sync.Mutex
}
// GetOldestCommitDate delegates to the next hook function in the queue and
// stores the parameter and result values of this invocation.
func (m *MockStore) GetOldestCommitDate(v0 context.Context, v1 int) (time.Time, bool, error) {
r0, r1, r2 := m.GetOldestCommitDateFunc.nextHook()(v0, v1)
m.GetOldestCommitDateFunc.appendCall(StoreGetOldestCommitDateFuncCall{v0, v1, r0, r1, r2})
return r0, r1, r2
}
// SetDefaultHook sets function that is called when the GetOldestCommitDate
// method of the parent MockStore instance is invoked and the hook queue is
// empty.
func (f *StoreGetOldestCommitDateFunc) SetDefaultHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetOldestCommitDate 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 *StoreGetOldestCommitDateFunc) PushHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetOldestCommitDateFunc) SetDefaultReturn(r0 time.Time, r1 bool, r2 error) {
f.SetDefaultHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetOldestCommitDateFunc) PushReturn(r0 time.Time, r1 bool, r2 error) {
f.PushHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
func (f *StoreGetOldestCommitDateFunc) nextHook() func(context.Context, int) (time.Time, bool, error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetOldestCommitDateFunc) appendCall(r0 StoreGetOldestCommitDateFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of StoreGetOldestCommitDateFuncCall objects
// describing the invocations of this function.
func (f *StoreGetOldestCommitDateFunc) History() []StoreGetOldestCommitDateFuncCall {
f.mutex.Lock()
history := make([]StoreGetOldestCommitDateFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetOldestCommitDateFuncCall is an object that describes an
// invocation of method GetOldestCommitDate on an instance of MockStore.
type StoreGetOldestCommitDateFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 time.Time
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 bool
// Result2 is the value of the 3rd result returned from this method
// invocation.
Result2 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1, c.Result2}
}
// StoreGetRecentIndexesSummaryFunc describes the behavior when the
// GetRecentIndexesSummary method of the parent MockStore instance is
// invoked.

View File

@ -15,11 +15,14 @@ go_library(
"//internal/api",
"//internal/codeintel/uploads/internal/commitgraph",
"//internal/codeintel/uploads/internal/store",
"//internal/conf",
"//internal/database/locker",
"//internal/env",
"//internal/gitserver",
"//internal/gitserver/gitdomain",
"//internal/goroutine",
"//lib/errors",
"@com_github_grafana_regexp//:regexp",
"@com_github_life4_genesis//slices",
],
)

View File

@ -2,12 +2,17 @@ package commitgraph
import (
"context"
"fmt"
"time"
"github.com/grafana/regexp"
genslices "github.com/life4/genesis/slices"
"github.com/sourcegraph/sourcegraph/internal/actor"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/commitgraph"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/store"
"github.com/sourcegraph/sourcegraph/internal/conf"
"github.com/sourcegraph/sourcegraph/internal/database/locker"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/gitserver/gitdomain"
@ -126,6 +131,13 @@ func mapRefsToCommits(refs []gitdomain.Ref) map[string][]gitdomain.Ref {
return commitsByRef
}
type CommitGraphRefreshStrategy string
const (
HeadTopoOnly CommitGraphRefreshStrategy = "head-topo-only"
AllRefsSince CommitGraphRefreshStrategy = "all-refs-since"
)
// getCommitGraph builds a partial commit graph that includes the most recent commits on each branch
// extending back as as the date of the oldest commit for which we have a processed upload for this
// repository.
@ -138,25 +150,53 @@ func mapRefsToCommits(refs []gitdomain.Ref) map[string][]gitdomain.Ref {
// accelerating rate, as we routinely expire old information for active repositories in a janitor
// process.
func (s *commitGraphUpdater) getCommitGraph(ctx context.Context, repositoryID int, repo api.RepoName) (*commitgraph.CommitGraph, error) {
commitDate, ok, err := s.store.GetOldestCommitDate(ctx, repositoryID)
optCommitWithDate, err := s.store.GetCommitAndDateForOldestUpload(ctx, repositoryID)
if err != nil {
return nil, err
}
commitWithDate, ok := optCommitWithDate.Get()
if !ok {
// No uploads exist for this repository
return commitgraph.ParseCommitGraph(nil), nil
}
// The --since flag for git log is exclusive, but we want to include the commit where the
// oldest dump is defined. This flag only has second resolution, so we shouldn't be pulling
// back any more data than we wanted.
commitDate = commitDate.Add(-time.Second)
siteConfig := conf.SiteConfig()
exptFeatures := siteConfig.ExperimentalFeatures
var strat CommitGraphRefreshStrategy = AllRefsSince
var defaultBranchRef string
if exptFeatures != nil && exptFeatures.CommitGraphUpdates != nil {
match := genslices.Any(exptFeatures.CommitGraphUpdates.DefaultBranchOnly, func(repoPattern string) bool {
matched, err := regexp.MatchString(repoPattern, string(repo))
return err == nil && matched
})
if match {
if refName, _, err := s.gitserverClient.GetDefaultBranch(ctx, repo, false); err == nil {
defaultBranchRef = refName
strat = HeadTopoOnly
}
}
}
commits, err := s.gitserverClient.Commits(ctx, repo, gitserver.CommitsOptions{
AllRefs: true,
Order: gitserver.CommitsOrderTopoDate,
After: commitDate,
})
var opts gitserver.CommitsOptions
switch strat {
case HeadTopoOnly:
opts = gitserver.CommitsOptions{
Ranges: []string{string(commitWithDate.Commit) + ".." + defaultBranchRef},
Order: gitserver.CommitsOrderTopoDate,
}
case AllRefsSince:
opts = gitserver.CommitsOptions{
AllRefs: true,
Order: gitserver.CommitsOrderTopoDate,
// The --since flag for git log is exclusive, but we want to include the commit where the
// oldest dump is defined. This flag only has second resolution, so we shouldn't be pulling
// back any more data than we wanted.
After: commitWithDate.CommitterDate.Add(-time.Second),
}
default:
panic(fmt.Sprintf("Unhandled case for strategy: %q", strat))
}
commits, err := s.gitserverClient.Commits(ctx, repo, opts)
if err != nil {
return nil, errors.Wrap(err, "gitserver.Commits")
}

View File

@ -42,6 +42,7 @@ go_test(
tags = [TAG_PLATFORM_GRAPH],
deps = [
"//internal/api",
"//internal/codeintel/core",
"//internal/codeintel/policies",
"//internal/codeintel/policies/shared",
"//internal/codeintel/uploads/internal/commitgraph",

View File

@ -14,6 +14,7 @@ import (
sqlf "github.com/keegancsmith/sqlf"
scip "github.com/sourcegraph/scip/bindings/go/scip"
api "github.com/sourcegraph/sourcegraph/internal/api"
core "github.com/sourcegraph/sourcegraph/internal/codeintel/core"
policies "github.com/sourcegraph/sourcegraph/internal/codeintel/policies"
shared "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
commitgraph "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/commitgraph"
@ -418,6 +419,10 @@ type MockStore struct {
// GetAuditLogsForUploadFunc is an instance of a mock function object
// controlling the behavior of the method GetAuditLogsForUpload.
GetAuditLogsForUploadFunc *StoreGetAuditLogsForUploadFunc
// GetCommitAndDateForOldestUploadFunc is an instance of a mock function
// object controlling the behavior of the method
// GetCommitAndDateForOldestUpload.
GetCommitAndDateForOldestUploadFunc *StoreGetCommitAndDateForOldestUploadFunc
// GetCommitGraphMetadataFunc is an instance of a mock function object
// controlling the behavior of the method GetCommitGraphMetadata.
GetCommitGraphMetadataFunc *StoreGetCommitGraphMetadataFunc
@ -451,9 +456,6 @@ type MockStore struct {
// function object controlling the behavior of the method
// GetLastUploadRetentionScanForRepository.
GetLastUploadRetentionScanForRepositoryFunc *StoreGetLastUploadRetentionScanForRepositoryFunc
// GetOldestCommitDateFunc is an instance of a mock function object
// controlling the behavior of the method GetOldestCommitDate.
GetOldestCommitDateFunc *StoreGetOldestCommitDateFunc
// GetRecentIndexesSummaryFunc is an instance of a mock function object
// controlling the behavior of the method GetRecentIndexesSummary.
GetRecentIndexesSummaryFunc *StoreGetRecentIndexesSummaryFunc
@ -658,6 +660,11 @@ func NewMockStore() *MockStore {
return
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (r0 core.Option[store.CommitWithDate], r1 error) {
return
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (r0 bool, r1 *time.Time, r2 error) {
return
@ -708,11 +715,6 @@ func NewMockStore() *MockStore {
return
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (r0 time.Time, r1 bool, r2 error) {
return
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) (r0 []shared1.IndexesWithRepositoryNamespace, r1 error) {
return
@ -985,6 +987,11 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetAuditLogsForUpload")
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (core.Option[store.CommitWithDate], error) {
panic("unexpected invocation of MockStore.GetCommitAndDateForOldestUpload")
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (bool, *time.Time, error) {
panic("unexpected invocation of MockStore.GetCommitGraphMetadata")
@ -1035,11 +1042,6 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetLastUploadRetentionScanForRepository")
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (time.Time, bool, error) {
panic("unexpected invocation of MockStore.GetOldestCommitDate")
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) ([]shared1.IndexesWithRepositoryNamespace, error) {
panic("unexpected invocation of MockStore.GetRecentIndexesSummary")
@ -1284,6 +1286,9 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetAuditLogsForUploadFunc: &StoreGetAuditLogsForUploadFunc{
defaultHook: i.GetAuditLogsForUpload,
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: i.GetCommitAndDateForOldestUpload,
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: i.GetCommitGraphMetadata,
},
@ -1314,9 +1319,6 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetLastUploadRetentionScanForRepositoryFunc: &StoreGetLastUploadRetentionScanForRepositoryFunc{
defaultHook: i.GetLastUploadRetentionScanForRepository,
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: i.GetOldestCommitDate,
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: i.GetRecentIndexesSummary,
},
@ -2994,6 +2996,118 @@ func (c StoreGetAuditLogsForUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitAndDateForOldestUploadFunc describes the behavior when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked.
type StoreGetCommitAndDateForOldestUploadFunc struct {
defaultHook func(context.Context, int) (core.Option[store.CommitWithDate], error)
hooks []func(context.Context, int) (core.Option[store.CommitWithDate], error)
history []StoreGetCommitAndDateForOldestUploadFuncCall
mutex sync.Mutex
}
// GetCommitAndDateForOldestUpload delegates to the next hook function in
// the queue and stores the parameter and result values of this invocation.
func (m *MockStore) GetCommitAndDateForOldestUpload(v0 context.Context, v1 int) (core.Option[store.CommitWithDate], error) {
r0, r1 := m.GetCommitAndDateForOldestUploadFunc.nextHook()(v0, v1)
m.GetCommitAndDateForOldestUploadFunc.appendCall(StoreGetCommitAndDateForOldestUploadFuncCall{v0, v1, r0, r1})
return r0, r1
}
// SetDefaultHook sets function that is called when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked and the hook queue is empty.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetCommitAndDateForOldestUpload 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 *StoreGetCommitAndDateForOldestUploadFunc) PushHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.SetDefaultHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) PushReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.PushHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) nextHook() func(context.Context, int) (core.Option[store.CommitWithDate], error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) appendCall(r0 StoreGetCommitAndDateForOldestUploadFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of
// StoreGetCommitAndDateForOldestUploadFuncCall objects describing the
// invocations of this function.
func (f *StoreGetCommitAndDateForOldestUploadFunc) History() []StoreGetCommitAndDateForOldestUploadFuncCall {
f.mutex.Lock()
history := make([]StoreGetCommitAndDateForOldestUploadFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetCommitAndDateForOldestUploadFuncCall is an object that describes
// an invocation of method GetCommitAndDateForOldestUpload on an instance of
// MockStore.
type StoreGetCommitAndDateForOldestUploadFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 core.Option[store.CommitWithDate]
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitGraphMetadataFunc describes the behavior when the
// GetCommitGraphMetadata method of the parent MockStore instance is
// invoked.
@ -4109,117 +4223,6 @@ func (c StoreGetLastUploadRetentionScanForRepositoryFuncCall) Results() []interf
return []interface{}{c.Result0, c.Result1}
}
// StoreGetOldestCommitDateFunc describes the behavior when the
// GetOldestCommitDate method of the parent MockStore instance is invoked.
type StoreGetOldestCommitDateFunc struct {
defaultHook func(context.Context, int) (time.Time, bool, error)
hooks []func(context.Context, int) (time.Time, bool, error)
history []StoreGetOldestCommitDateFuncCall
mutex sync.Mutex
}
// GetOldestCommitDate delegates to the next hook function in the queue and
// stores the parameter and result values of this invocation.
func (m *MockStore) GetOldestCommitDate(v0 context.Context, v1 int) (time.Time, bool, error) {
r0, r1, r2 := m.GetOldestCommitDateFunc.nextHook()(v0, v1)
m.GetOldestCommitDateFunc.appendCall(StoreGetOldestCommitDateFuncCall{v0, v1, r0, r1, r2})
return r0, r1, r2
}
// SetDefaultHook sets function that is called when the GetOldestCommitDate
// method of the parent MockStore instance is invoked and the hook queue is
// empty.
func (f *StoreGetOldestCommitDateFunc) SetDefaultHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetOldestCommitDate 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 *StoreGetOldestCommitDateFunc) PushHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetOldestCommitDateFunc) SetDefaultReturn(r0 time.Time, r1 bool, r2 error) {
f.SetDefaultHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetOldestCommitDateFunc) PushReturn(r0 time.Time, r1 bool, r2 error) {
f.PushHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
func (f *StoreGetOldestCommitDateFunc) nextHook() func(context.Context, int) (time.Time, bool, error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetOldestCommitDateFunc) appendCall(r0 StoreGetOldestCommitDateFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of StoreGetOldestCommitDateFuncCall objects
// describing the invocations of this function.
func (f *StoreGetOldestCommitDateFunc) History() []StoreGetOldestCommitDateFuncCall {
f.mutex.Lock()
history := make([]StoreGetOldestCommitDateFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetOldestCommitDateFuncCall is an object that describes an
// invocation of method GetOldestCommitDate on an instance of MockStore.
type StoreGetOldestCommitDateFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 time.Time
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 bool
// Result2 is the value of the 3rd result returned from this method
// invocation.
Result2 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1, c.Result2}
}
// StoreGetRecentIndexesSummaryFunc describes the behavior when the
// GetRecentIndexesSummary method of the parent MockStore instance is
// invoked.

View File

@ -58,6 +58,7 @@ go_test(
deps = [
"//cmd/frontend/backend",
"//internal/api",
"//internal/codeintel/core",
"//internal/codeintel/uploads/internal/commitgraph",
"//internal/codeintel/uploads/internal/lsifstore",
"//internal/codeintel/uploads/internal/store",

View File

@ -14,6 +14,7 @@ import (
sqlf "github.com/keegancsmith/sqlf"
scip "github.com/sourcegraph/scip/bindings/go/scip"
api "github.com/sourcegraph/sourcegraph/internal/api"
core "github.com/sourcegraph/sourcegraph/internal/codeintel/core"
commitgraph "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/commitgraph"
lsifstore "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/lsifstore"
store "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/store"
@ -232,6 +233,10 @@ type MockStore struct {
// GetAuditLogsForUploadFunc is an instance of a mock function object
// controlling the behavior of the method GetAuditLogsForUpload.
GetAuditLogsForUploadFunc *StoreGetAuditLogsForUploadFunc
// GetCommitAndDateForOldestUploadFunc is an instance of a mock function
// object controlling the behavior of the method
// GetCommitAndDateForOldestUpload.
GetCommitAndDateForOldestUploadFunc *StoreGetCommitAndDateForOldestUploadFunc
// GetCommitGraphMetadataFunc is an instance of a mock function object
// controlling the behavior of the method GetCommitGraphMetadata.
GetCommitGraphMetadataFunc *StoreGetCommitGraphMetadataFunc
@ -265,9 +270,6 @@ type MockStore struct {
// function object controlling the behavior of the method
// GetLastUploadRetentionScanForRepository.
GetLastUploadRetentionScanForRepositoryFunc *StoreGetLastUploadRetentionScanForRepositoryFunc
// GetOldestCommitDateFunc is an instance of a mock function object
// controlling the behavior of the method GetOldestCommitDate.
GetOldestCommitDateFunc *StoreGetOldestCommitDateFunc
// GetRecentIndexesSummaryFunc is an instance of a mock function object
// controlling the behavior of the method GetRecentIndexesSummary.
GetRecentIndexesSummaryFunc *StoreGetRecentIndexesSummaryFunc
@ -472,6 +474,11 @@ func NewMockStore() *MockStore {
return
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (r0 core.Option[store.CommitWithDate], r1 error) {
return
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (r0 bool, r1 *time.Time, r2 error) {
return
@ -522,11 +529,6 @@ func NewMockStore() *MockStore {
return
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (r0 time.Time, r1 bool, r2 error) {
return
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) (r0 []shared.IndexesWithRepositoryNamespace, r1 error) {
return
@ -799,6 +801,11 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetAuditLogsForUpload")
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (core.Option[store.CommitWithDate], error) {
panic("unexpected invocation of MockStore.GetCommitAndDateForOldestUpload")
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (bool, *time.Time, error) {
panic("unexpected invocation of MockStore.GetCommitGraphMetadata")
@ -849,11 +856,6 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetLastUploadRetentionScanForRepository")
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (time.Time, bool, error) {
panic("unexpected invocation of MockStore.GetOldestCommitDate")
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) ([]shared.IndexesWithRepositoryNamespace, error) {
panic("unexpected invocation of MockStore.GetRecentIndexesSummary")
@ -1098,6 +1100,9 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetAuditLogsForUploadFunc: &StoreGetAuditLogsForUploadFunc{
defaultHook: i.GetAuditLogsForUpload,
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: i.GetCommitAndDateForOldestUpload,
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: i.GetCommitGraphMetadata,
},
@ -1128,9 +1133,6 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetLastUploadRetentionScanForRepositoryFunc: &StoreGetLastUploadRetentionScanForRepositoryFunc{
defaultHook: i.GetLastUploadRetentionScanForRepository,
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: i.GetOldestCommitDate,
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: i.GetRecentIndexesSummary,
},
@ -2808,6 +2810,118 @@ func (c StoreGetAuditLogsForUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitAndDateForOldestUploadFunc describes the behavior when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked.
type StoreGetCommitAndDateForOldestUploadFunc struct {
defaultHook func(context.Context, int) (core.Option[store.CommitWithDate], error)
hooks []func(context.Context, int) (core.Option[store.CommitWithDate], error)
history []StoreGetCommitAndDateForOldestUploadFuncCall
mutex sync.Mutex
}
// GetCommitAndDateForOldestUpload delegates to the next hook function in
// the queue and stores the parameter and result values of this invocation.
func (m *MockStore) GetCommitAndDateForOldestUpload(v0 context.Context, v1 int) (core.Option[store.CommitWithDate], error) {
r0, r1 := m.GetCommitAndDateForOldestUploadFunc.nextHook()(v0, v1)
m.GetCommitAndDateForOldestUploadFunc.appendCall(StoreGetCommitAndDateForOldestUploadFuncCall{v0, v1, r0, r1})
return r0, r1
}
// SetDefaultHook sets function that is called when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked and the hook queue is empty.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetCommitAndDateForOldestUpload 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 *StoreGetCommitAndDateForOldestUploadFunc) PushHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.SetDefaultHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) PushReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.PushHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) nextHook() func(context.Context, int) (core.Option[store.CommitWithDate], error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) appendCall(r0 StoreGetCommitAndDateForOldestUploadFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of
// StoreGetCommitAndDateForOldestUploadFuncCall objects describing the
// invocations of this function.
func (f *StoreGetCommitAndDateForOldestUploadFunc) History() []StoreGetCommitAndDateForOldestUploadFuncCall {
f.mutex.Lock()
history := make([]StoreGetCommitAndDateForOldestUploadFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetCommitAndDateForOldestUploadFuncCall is an object that describes
// an invocation of method GetCommitAndDateForOldestUpload on an instance of
// MockStore.
type StoreGetCommitAndDateForOldestUploadFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 core.Option[store.CommitWithDate]
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitGraphMetadataFunc describes the behavior when the
// GetCommitGraphMetadata method of the parent MockStore instance is
// invoked.
@ -3923,117 +4037,6 @@ func (c StoreGetLastUploadRetentionScanForRepositoryFuncCall) Results() []interf
return []interface{}{c.Result0, c.Result1}
}
// StoreGetOldestCommitDateFunc describes the behavior when the
// GetOldestCommitDate method of the parent MockStore instance is invoked.
type StoreGetOldestCommitDateFunc struct {
defaultHook func(context.Context, int) (time.Time, bool, error)
hooks []func(context.Context, int) (time.Time, bool, error)
history []StoreGetOldestCommitDateFuncCall
mutex sync.Mutex
}
// GetOldestCommitDate delegates to the next hook function in the queue and
// stores the parameter and result values of this invocation.
func (m *MockStore) GetOldestCommitDate(v0 context.Context, v1 int) (time.Time, bool, error) {
r0, r1, r2 := m.GetOldestCommitDateFunc.nextHook()(v0, v1)
m.GetOldestCommitDateFunc.appendCall(StoreGetOldestCommitDateFuncCall{v0, v1, r0, r1, r2})
return r0, r1, r2
}
// SetDefaultHook sets function that is called when the GetOldestCommitDate
// method of the parent MockStore instance is invoked and the hook queue is
// empty.
func (f *StoreGetOldestCommitDateFunc) SetDefaultHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetOldestCommitDate 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 *StoreGetOldestCommitDateFunc) PushHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetOldestCommitDateFunc) SetDefaultReturn(r0 time.Time, r1 bool, r2 error) {
f.SetDefaultHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetOldestCommitDateFunc) PushReturn(r0 time.Time, r1 bool, r2 error) {
f.PushHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
func (f *StoreGetOldestCommitDateFunc) nextHook() func(context.Context, int) (time.Time, bool, error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetOldestCommitDateFunc) appendCall(r0 StoreGetOldestCommitDateFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of StoreGetOldestCommitDateFuncCall objects
// describing the invocations of this function.
func (f *StoreGetOldestCommitDateFunc) History() []StoreGetOldestCommitDateFuncCall {
f.mutex.Lock()
history := make([]StoreGetOldestCommitDateFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetOldestCommitDateFuncCall is an object that describes an
// invocation of method GetOldestCommitDate on an instance of MockStore.
type StoreGetOldestCommitDateFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 time.Time
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 bool
// Result2 is the value of the 3rd result returned from this method
// invocation.
Result2 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1, c.Result2}
}
// StoreGetRecentIndexesSummaryFunc describes the behavior when the
// GetRecentIndexesSummary method of the parent MockStore instance is
// invoked.

View File

@ -23,6 +23,7 @@ go_library(
visibility = ["//:__subpackages__"],
deps = [
"//internal/api",
"//internal/codeintel/core",
"//internal/codeintel/uploads/internal/commitgraph",
"//internal/codeintel/uploads/shared",
"//internal/database",
@ -92,5 +93,6 @@ go_test(
"@com_github_lib_pq//:pq",
"@com_github_sourcegraph_log//:log",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//require",
],
)

View File

@ -8,38 +8,56 @@ import (
"github.com/keegancsmith/sqlf"
"go.opentelemetry.io/otel/attribute"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/codeintel/core"
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
"github.com/sourcegraph/sourcegraph/internal/database/dbutil"
"github.com/sourcegraph/sourcegraph/internal/observation"
)
// GetOldestCommitDate returns the oldest commit date for all uploads for the given repository. If there are no
// non-nil values, a false-valued flag is returned. If there are any null values, the commit date backfill job
// has not yet completed and an error is returned to prevent downstream expiration errors being made due to
// outdated commit graph data.
func (s *store) GetOldestCommitDate(ctx context.Context, repositoryID int) (_ time.Time, _ bool, err error) {
ctx, _, endObservation := s.operations.getOldestCommitDate.With(ctx, &err, observation.Args{Attrs: []attribute.KeyValue{
type CommitWithDate struct {
Commit api.CommitID
CommitterDate time.Time
}
// GetCommitDateForOldestUpload returns the oldest commit date for all uploads for the given repository.
// - If there are any null values, the commit date backfill job has not yet completed and
// an error is returned to prevent downstream expiration errors being made due to outdated commit graph data.
// - Otherwise if there are no non-nil timestamps, Some is returned.
func (s *store) GetCommitAndDateForOldestUpload(ctx context.Context, repositoryID int) (_ core.Option[CommitWithDate], err error) {
ctx, _, endObservation := s.operations.getCommitAndDateForOldestUpload.With(ctx, &err, observation.Args{Attrs: []attribute.KeyValue{
attribute.Int("repositoryID", repositoryID),
}})
defer endObservation(1, observation.Args{})
t, ok, err := basestore.ScanFirstNullTime(s.db.Query(ctx, sqlf.Sprintf(getOldestCommitDateQuery, repositoryID)))
if err != nil || !ok {
return time.Time{}, false, err
var none = core.None[CommitWithDate]()
type commitWithNullDate struct {
commit string
t *time.Time
}
if t == nil {
return time.Time{}, false, &backfillIncompleteError{repositoryID}
data, ok, err := basestore.NewFirstScanner(func(scanner dbutil.Scanner) (commitWithNullDate, error) {
var commit string
var t *time.Time
err := scanner.Scan(&commit, &t)
return commitWithNullDate{commit, t}, err
})(s.db.Query(ctx, sqlf.Sprintf(getCommitAndDateForOldestUploadQuery, repositoryID)))
if err != nil || !ok {
return none, err
}
if data.t == nil {
return none, &backfillIncompleteError{repositoryID}
}
return *t, true, nil
return core.Some(CommitWithDate{Commit: api.CommitID(data.commit), CommitterDate: *data.t}), nil
}
// Note: we check against '-infinity' here, as the backfill operation will use this sentinel value in the case
// that the commit is no longer know by gitserver. This allows the backfill migration to make progress without
// having pristine database.
const getOldestCommitDateQuery = `
const getCommitAndDateForOldestUploadQuery = `
SELECT
cd.committed_at
u.commit, cd.committed_at
FROM lsif_uploads u
LEFT JOIN codeintel_commit_dates cd ON cd.repository_id = u.repository_id AND cd.commit_bytea = decode(u.commit, 'hex')
WHERE

View File

@ -7,7 +7,9 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/sourcegraph/log/logtest"
"github.com/stretchr/testify/require"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/database/dbtest"
@ -53,7 +55,7 @@ func TestGetOldestCommitDate(t *testing.T) {
}
}
if _, _, err := store.GetOldestCommitDate(context.Background(), 50); err == nil {
if _, err := store.GetCommitAndDateForOldestUpload(context.Background(), 50); err == nil {
t.Fatalf("expected error getting oldest commit date")
} else if !errors.Is(err, &backfillIncompleteError{50}) {
t.Fatalf("unexpected backfill error, got %q", err)
@ -64,12 +66,12 @@ func TestGetOldestCommitDate(t *testing.T) {
t.Fatalf("unexpected error updating commit date %s", err)
}
if commitDate, ok, err := store.GetOldestCommitDate(context.Background(), 50); err != nil {
if commitWithDate, err := store.GetCommitAndDateForOldestUpload(context.Background(), 50); err != nil {
t.Fatalf("unexpected error getting oldest commit date: %s", err)
} else if !ok {
} else if commitWithDate.IsNone() {
t.Fatalf("expected commit date for repository")
} else if !commitDate.Equal(t3) {
t.Fatalf("unexpected commit date. want=%s have=%s", t3, commitDate)
} else {
require.Equal(t, CommitWithDate{Commit: api.CommitID(makeCommit(1)), CommitterDate: t3}, commitWithDate.Unwrap())
}
// Repo 51
@ -83,18 +85,18 @@ func TestGetOldestCommitDate(t *testing.T) {
}
}
if commitDate, ok, err := store.GetOldestCommitDate(context.Background(), 51); err != nil {
if commitAndDate, err := store.GetCommitAndDateForOldestUpload(context.Background(), 51); err != nil {
t.Fatalf("unexpected error getting oldest commit date: %s", err)
} else if !ok {
} else if commitAndDate.IsNone() {
t.Fatalf("expected commit date for repository")
} else if !commitDate.Equal(t2) {
t.Fatalf("unexpected commit date. want=%s have=%s", t2, commitDate)
} else {
require.Equal(t, CommitWithDate{Commit: api.CommitID(makeCommit(6)), CommitterDate: t2}, commitAndDate.Unwrap())
}
// Missing repository
if _, ok, err := store.GetOldestCommitDate(context.Background(), 52); err != nil {
if commitDate, err := store.GetCommitAndDateForOldestUpload(context.Background(), 52); err != nil {
t.Fatalf("unexpected error getting oldest commit date: %s", err)
} else if ok {
} else if commitDate.IsSome() {
t.Fatalf("unexpected commit date for repository")
}
}

View File

@ -16,7 +16,7 @@ type operations struct {
deleteSourcedCommits *observation.Operation
updateSourcedCommits *observation.Operation
getCommitsVisibleToUpload *observation.Operation
getOldestCommitDate *observation.Operation
getCommitAndDateForOldestUpload *observation.Operation
getCommitGraphMetadata *observation.Operation
hasCommit *observation.Operation
repositoryIDsWithErrors *observation.Operation
@ -121,13 +121,13 @@ func newOperations(observationCtx *observation.Context) *operations {
list: op("List"),
// Commits
getCommitsVisibleToUpload: op("CommitsVisibleToUploads"),
getOldestCommitDate: op("GetOldestCommitDate"),
getStaleSourcedCommits: op("GetStaleSourcedCommits"),
getCommitGraphMetadata: op("GetCommitGraphMetadata"),
deleteSourcedCommits: op("DeleteSourcedCommits"),
updateSourcedCommits: op("UpdateSourcedCommits"),
hasCommit: op("HasCommit"),
getCommitsVisibleToUpload: op("CommitsVisibleToUploads"),
getCommitAndDateForOldestUpload: op("GetCommitAndDateForOldestUpload"),
getStaleSourcedCommits: op("GetStaleSourcedCommits"),
getCommitGraphMetadata: op("GetCommitGraphMetadata"),
deleteSourcedCommits: op("DeleteSourcedCommits"),
updateSourcedCommits: op("UpdateSourcedCommits"),
hasCommit: op("HasCommit"),
// Repositories
getRepositoriesForIndexScan: op("GetRepositoriesForIndexScan"),

View File

@ -7,6 +7,7 @@ import (
logger "github.com/sourcegraph/log"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/codeintel/core"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/commitgraph"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
"github.com/sourcegraph/sourcegraph/internal/database"
@ -87,7 +88,7 @@ type Store interface {
SoftDeleteExpiredUploadsViaTraversal(ctx context.Context, maxTraversal int) (int, int, error)
// Commit date
GetOldestCommitDate(ctx context.Context, repositoryID int) (time.Time, bool, error)
GetCommitAndDateForOldestUpload(ctx context.Context, repositoryID int) (core.Option[CommitWithDate], error)
UpdateCommittedAt(ctx context.Context, repositoryID int, commit, commitDateString string) error
SourcedCommitsWithoutCommittedAt(ctx context.Context, batchSize int) ([]SourcedCommits, error)

View File

@ -13,6 +13,7 @@ import (
sqlf "github.com/keegancsmith/sqlf"
api "github.com/sourcegraph/sourcegraph/internal/api"
core "github.com/sourcegraph/sourcegraph/internal/codeintel/core"
shared1 "github.com/sourcegraph/sourcegraph/internal/codeintel/policies/shared"
commitgraph "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/commitgraph"
lsifstore "github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/lsifstore"
@ -81,6 +82,10 @@ type MockStore struct {
// GetAuditLogsForUploadFunc is an instance of a mock function object
// controlling the behavior of the method GetAuditLogsForUpload.
GetAuditLogsForUploadFunc *StoreGetAuditLogsForUploadFunc
// GetCommitAndDateForOldestUploadFunc is an instance of a mock function
// object controlling the behavior of the method
// GetCommitAndDateForOldestUpload.
GetCommitAndDateForOldestUploadFunc *StoreGetCommitAndDateForOldestUploadFunc
// GetCommitGraphMetadataFunc is an instance of a mock function object
// controlling the behavior of the method GetCommitGraphMetadata.
GetCommitGraphMetadataFunc *StoreGetCommitGraphMetadataFunc
@ -114,9 +119,6 @@ type MockStore struct {
// function object controlling the behavior of the method
// GetLastUploadRetentionScanForRepository.
GetLastUploadRetentionScanForRepositoryFunc *StoreGetLastUploadRetentionScanForRepositoryFunc
// GetOldestCommitDateFunc is an instance of a mock function object
// controlling the behavior of the method GetOldestCommitDate.
GetOldestCommitDateFunc *StoreGetOldestCommitDateFunc
// GetRecentIndexesSummaryFunc is an instance of a mock function object
// controlling the behavior of the method GetRecentIndexesSummary.
GetRecentIndexesSummaryFunc *StoreGetRecentIndexesSummaryFunc
@ -321,6 +323,11 @@ func NewMockStore() *MockStore {
return
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (r0 core.Option[store.CommitWithDate], r1 error) {
return
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (r0 bool, r1 *time.Time, r2 error) {
return
@ -371,11 +378,6 @@ func NewMockStore() *MockStore {
return
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (r0 time.Time, r1 bool, r2 error) {
return
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) (r0 []shared.IndexesWithRepositoryNamespace, r1 error) {
return
@ -648,6 +650,11 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetAuditLogsForUpload")
},
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: func(context.Context, int) (core.Option[store.CommitWithDate], error) {
panic("unexpected invocation of MockStore.GetCommitAndDateForOldestUpload")
},
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: func(context.Context, int) (bool, *time.Time, error) {
panic("unexpected invocation of MockStore.GetCommitGraphMetadata")
@ -698,11 +705,6 @@ func NewStrictMockStore() *MockStore {
panic("unexpected invocation of MockStore.GetLastUploadRetentionScanForRepository")
},
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: func(context.Context, int) (time.Time, bool, error) {
panic("unexpected invocation of MockStore.GetOldestCommitDate")
},
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: func(context.Context, int) ([]shared.IndexesWithRepositoryNamespace, error) {
panic("unexpected invocation of MockStore.GetRecentIndexesSummary")
@ -947,6 +949,9 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetAuditLogsForUploadFunc: &StoreGetAuditLogsForUploadFunc{
defaultHook: i.GetAuditLogsForUpload,
},
GetCommitAndDateForOldestUploadFunc: &StoreGetCommitAndDateForOldestUploadFunc{
defaultHook: i.GetCommitAndDateForOldestUpload,
},
GetCommitGraphMetadataFunc: &StoreGetCommitGraphMetadataFunc{
defaultHook: i.GetCommitGraphMetadata,
},
@ -977,9 +982,6 @@ func NewMockStoreFrom(i store.Store) *MockStore {
GetLastUploadRetentionScanForRepositoryFunc: &StoreGetLastUploadRetentionScanForRepositoryFunc{
defaultHook: i.GetLastUploadRetentionScanForRepository,
},
GetOldestCommitDateFunc: &StoreGetOldestCommitDateFunc{
defaultHook: i.GetOldestCommitDate,
},
GetRecentIndexesSummaryFunc: &StoreGetRecentIndexesSummaryFunc{
defaultHook: i.GetRecentIndexesSummary,
},
@ -2657,6 +2659,118 @@ func (c StoreGetAuditLogsForUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitAndDateForOldestUploadFunc describes the behavior when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked.
type StoreGetCommitAndDateForOldestUploadFunc struct {
defaultHook func(context.Context, int) (core.Option[store.CommitWithDate], error)
hooks []func(context.Context, int) (core.Option[store.CommitWithDate], error)
history []StoreGetCommitAndDateForOldestUploadFuncCall
mutex sync.Mutex
}
// GetCommitAndDateForOldestUpload delegates to the next hook function in
// the queue and stores the parameter and result values of this invocation.
func (m *MockStore) GetCommitAndDateForOldestUpload(v0 context.Context, v1 int) (core.Option[store.CommitWithDate], error) {
r0, r1 := m.GetCommitAndDateForOldestUploadFunc.nextHook()(v0, v1)
m.GetCommitAndDateForOldestUploadFunc.appendCall(StoreGetCommitAndDateForOldestUploadFuncCall{v0, v1, r0, r1})
return r0, r1
}
// SetDefaultHook sets function that is called when the
// GetCommitAndDateForOldestUpload method of the parent MockStore instance
// is invoked and the hook queue is empty.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetCommitAndDateForOldestUpload 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 *StoreGetCommitAndDateForOldestUploadFunc) PushHook(hook func(context.Context, int) (core.Option[store.CommitWithDate], error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) SetDefaultReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.SetDefaultHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetCommitAndDateForOldestUploadFunc) PushReturn(r0 core.Option[store.CommitWithDate], r1 error) {
f.PushHook(func(context.Context, int) (core.Option[store.CommitWithDate], error) {
return r0, r1
})
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) nextHook() func(context.Context, int) (core.Option[store.CommitWithDate], error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetCommitAndDateForOldestUploadFunc) appendCall(r0 StoreGetCommitAndDateForOldestUploadFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of
// StoreGetCommitAndDateForOldestUploadFuncCall objects describing the
// invocations of this function.
func (f *StoreGetCommitAndDateForOldestUploadFunc) History() []StoreGetCommitAndDateForOldestUploadFuncCall {
f.mutex.Lock()
history := make([]StoreGetCommitAndDateForOldestUploadFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetCommitAndDateForOldestUploadFuncCall is an object that describes
// an invocation of method GetCommitAndDateForOldestUpload on an instance of
// MockStore.
type StoreGetCommitAndDateForOldestUploadFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 core.Option[store.CommitWithDate]
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetCommitAndDateForOldestUploadFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1}
}
// StoreGetCommitGraphMetadataFunc describes the behavior when the
// GetCommitGraphMetadata method of the parent MockStore instance is
// invoked.
@ -3772,117 +3886,6 @@ func (c StoreGetLastUploadRetentionScanForRepositoryFuncCall) Results() []interf
return []interface{}{c.Result0, c.Result1}
}
// StoreGetOldestCommitDateFunc describes the behavior when the
// GetOldestCommitDate method of the parent MockStore instance is invoked.
type StoreGetOldestCommitDateFunc struct {
defaultHook func(context.Context, int) (time.Time, bool, error)
hooks []func(context.Context, int) (time.Time, bool, error)
history []StoreGetOldestCommitDateFuncCall
mutex sync.Mutex
}
// GetOldestCommitDate delegates to the next hook function in the queue and
// stores the parameter and result values of this invocation.
func (m *MockStore) GetOldestCommitDate(v0 context.Context, v1 int) (time.Time, bool, error) {
r0, r1, r2 := m.GetOldestCommitDateFunc.nextHook()(v0, v1)
m.GetOldestCommitDateFunc.appendCall(StoreGetOldestCommitDateFuncCall{v0, v1, r0, r1, r2})
return r0, r1, r2
}
// SetDefaultHook sets function that is called when the GetOldestCommitDate
// method of the parent MockStore instance is invoked and the hook queue is
// empty.
func (f *StoreGetOldestCommitDateFunc) SetDefaultHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.defaultHook = hook
}
// PushHook adds a function to the end of hook queue. Each invocation of the
// GetOldestCommitDate 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 *StoreGetOldestCommitDateFunc) PushHook(hook func(context.Context, int) (time.Time, bool, error)) {
f.mutex.Lock()
f.hooks = append(f.hooks, hook)
f.mutex.Unlock()
}
// SetDefaultReturn calls SetDefaultHook with a function that returns the
// given values.
func (f *StoreGetOldestCommitDateFunc) SetDefaultReturn(r0 time.Time, r1 bool, r2 error) {
f.SetDefaultHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
// PushReturn calls PushHook with a function that returns the given values.
func (f *StoreGetOldestCommitDateFunc) PushReturn(r0 time.Time, r1 bool, r2 error) {
f.PushHook(func(context.Context, int) (time.Time, bool, error) {
return r0, r1, r2
})
}
func (f *StoreGetOldestCommitDateFunc) nextHook() func(context.Context, int) (time.Time, bool, error) {
f.mutex.Lock()
defer f.mutex.Unlock()
if len(f.hooks) == 0 {
return f.defaultHook
}
hook := f.hooks[0]
f.hooks = f.hooks[1:]
return hook
}
func (f *StoreGetOldestCommitDateFunc) appendCall(r0 StoreGetOldestCommitDateFuncCall) {
f.mutex.Lock()
f.history = append(f.history, r0)
f.mutex.Unlock()
}
// History returns a sequence of StoreGetOldestCommitDateFuncCall objects
// describing the invocations of this function.
func (f *StoreGetOldestCommitDateFunc) History() []StoreGetOldestCommitDateFuncCall {
f.mutex.Lock()
history := make([]StoreGetOldestCommitDateFuncCall, len(f.history))
copy(history, f.history)
f.mutex.Unlock()
return history
}
// StoreGetOldestCommitDateFuncCall is an object that describes an
// invocation of method GetOldestCommitDate on an instance of MockStore.
type StoreGetOldestCommitDateFuncCall struct {
// Arg0 is the value of the 1st argument passed to this method
// invocation.
Arg0 context.Context
// Arg1 is the value of the 2nd argument passed to this method
// invocation.
Arg1 int
// Result0 is the value of the 1st result returned from this method
// invocation.
Result0 time.Time
// Result1 is the value of the 2nd result returned from this method
// invocation.
Result1 bool
// Result2 is the value of the 3rd result returned from this method
// invocation.
Result2 error
}
// Args returns an interface slice containing the arguments of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Args() []interface{} {
return []interface{}{c.Arg0, c.Arg1}
}
// Results returns an interface slice containing the results of this
// invocation.
func (c StoreGetOldestCommitDateFuncCall) Results() []interface{} {
return []interface{}{c.Result0, c.Result1, c.Result2}
}
// StoreGetRecentIndexesSummaryFunc describes the behavior when the
// GetRecentIndexesSummary method of the parent MockStore instance is
// invoked.

View File

@ -670,6 +670,12 @@ type CodyProConfig struct {
UseEmbeddedUI bool `json:"useEmbeddedUI,omitempty"`
}
// CommitGraphUpdates description: Customize strategy used for commit graph updates
type CommitGraphUpdates struct {
// DefaultBranchOnly description: Disables precise code nav on non-default branches. Specify repo names using regex syntax.
DefaultBranchOnly []string `json:"defaultBranchOnly,omitempty"`
}
// Completions description: Configuration for the completions service.
type Completions struct {
// AccessToken description: The access token used to authenticate with the external completions provider. If using the default provider 'sourcegraph', and if 'licenseKey' is set, a default access token is generated.
@ -1039,6 +1045,8 @@ type ExperimentalFeatures struct {
CodeintelSyntacticIndexingEnabled bool `json:"codeintelSyntacticIndexing.enabled,omitempty"`
// CodyContextIgnore description: Enabled filtering of remote Cody context based on repositories ./cody/ignore file
CodyContextIgnore *bool `json:"codyContextIgnore,omitempty"`
// CommitGraphUpdates description: Customize strategy used for commit graph updates
CommitGraphUpdates *CommitGraphUpdates `json:"commitGraphUpdates,omitempty"`
// CustomGitFetch description: JSON array of configuration that maps from Git clone URL domain/path to custom git fetch command. To enable this feature set environment variable `ENABLE_CUSTOM_GIT_FETCH` as `true` on gitserver.
CustomGitFetch []*CustomGitFetchMapping `json:"customGitFetch,omitempty"`
// DebugLog description: Turns on debug logging for specific debugging scenarios.
@ -1138,6 +1146,7 @@ func (v *ExperimentalFeatures) UnmarshalJSON(data []byte) error {
delete(m, "batchChanges.enablePerforce")
delete(m, "codeintelSyntacticIndexing.enabled")
delete(m, "codyContextIgnore")
delete(m, "commitGraphUpdates")
delete(m, "customGitFetch")
delete(m, "debug.log")
delete(m, "enableGithubInternalRepoVisibility")

View File

@ -175,6 +175,21 @@
"type": "object",
"additionalProperties": true,
"properties": {
"commitGraphUpdates": {
"description": "Customize strategy used for commit graph updates",
"type": "object",
"additionalProperties": false,
"properties": {
"defaultBranchOnly": {
"description": "Disables precise code nav on non-default branches. Specify repo names using regex syntax.",
"type": "array",
"items": {
"type": "string",
"examples": ["github.com/myorg/huge-monorepo", "github.com/other-org/.*"]
}
}
}
},
"scipBasedAPIs": {
"description": "Enable usage of new CodeGraph and usagesForSymbol APIs",
"type": "boolean",