Skip to content

Commit

Permalink
codeintel: Add blocklist for autoindexing (#51578)
Browse files Browse the repository at this point in the history
  • Loading branch information
efritz committed May 9, 2023
1 parent ceb39ed commit d6250d3
Show file tree
Hide file tree
Showing 17 changed files with 795 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ All notable changes to Sourcegraph are documented in this file.
- Login form can now be configured with ordering and limit of auth providers. [See docs](https://docs.sourcegraph.com/admin/auth/login_form). [#50586](https://github.com/sourcegraph/sourcegraph/pull/50586), [50284](https://github.com/sourcegraph/sourcegraph/pull/50284) and [#50705](https://github.com/sourcegraph/sourcegraph/pull/50705)
- When creating a new batch change, spaces are automatically replaced with dashes in the name field. [#50825](https://github.com/sourcegraph/sourcegraph/pull/50825) and [51071](https://github.com/sourcegraph/sourcegraph/pull/51071)
- Support for custom HTML injection behind an environment variable (`ENABLE_INJECT_HTML`). This allows users to enable or disable HTML customization as needed, which is now disabled by default. [#51400](https://github.com/sourcegraph/sourcegraph/pull/51400)
- Added the ability to block auto-indexing scheduling and inference via the `codeintel_autoindexing_exceptions` Postgres table. [#51578](https://github.com/sourcegraph/sourcegraph/pull/51578)

### Changed

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func (s *JobSelector) InferIndexJobsFromRepositoryStructure(ctx context.Context,
script = localOverrideScript
}

if _, canInfer, err := s.store.RepositoryExceptions(ctx, repositoryID); err != nil {
return nil, err
} else if !canInfer {
s.logger.Warn("Auto-indexing job inference for this repo is disabled", log.Int("repositoryID", repositoryID), log.String("repoName", string(repo.Name)))
return nil, nil
}

indexes, err := s.inferenceSvc.InferIndexJobs(ctx, repo.Name, commit, script)
if err != nil {
return nil, err
Expand All @@ -78,7 +85,14 @@ func (s *JobSelector) InferIndexJobsFromRepositoryStructure(ctx context.Context,
}

// inferIndexJobsFromRepositoryStructure collects the result of InferIndexJobHints over all registered recognizers.
func (s *JobSelector) InferIndexJobHintsFromRepositoryStructure(ctx context.Context, repoName api.RepoName, commit string) ([]config.IndexJobHint, error) {
func (s *JobSelector) InferIndexJobHintsFromRepositoryStructure(ctx context.Context, repositoryID int, repoName api.RepoName, commit string) ([]config.IndexJobHint, error) {
if _, canInfer, err := s.store.RepositoryExceptions(ctx, repositoryID); err != nil {
return nil, err
} else if !canInfer {
s.logger.Warn("Auto-indexing job inference for this repo is disabled", log.Int("repositoryID", repositoryID), log.String("repoName", string(repoName)))
return nil, nil
}

indexes, err := s.inferenceSvc.InferIndexJobHints(ctx, repoName, commit, overrideScript)
if err != nil {
return nil, err
Expand All @@ -97,6 +111,13 @@ type configurationFactoryFunc func(ctx context.Context, repositoryID int, commit
// - committed to `sourcegraph.yaml` in the repository
// - inferred from the repository structure
func (s *JobSelector) GetIndexRecords(ctx context.Context, repositoryID int, commit, configuration string, bypassLimit bool) ([]uploadsshared.Index, error) {
if canSchedule, _, err := s.store.RepositoryExceptions(ctx, repositoryID); err != nil {
return nil, err
} else if !canSchedule {
s.logger.Warn("Auto-indexing scheduling for this repo is disabled", log.Int("repositoryID", repositoryID))
return nil, nil
}

fns := []configurationFactoryFunc{
makeExplicitConfigurationFactory(configuration),
s.getIndexRecordsFromConfigurationInDatabase,
Expand Down
Loading

0 comments on commit d6250d3

Please sign in to comment.