Move own codebase to enterprise (#48408)

After adding a pattern to inject enterprise search jobs, we can now move
the whole own codebase into enterprise 🎊


Closes https://github.com/sourcegraph/sourcegraph/issues/48490
Closes https://github.com/sourcegraph/sourcegraph/issues/48489
This commit is contained in:
Erik Seliger 2023-03-02 16:25:02 +01:00 committed by GitHub
parent 956596daa1
commit 905e01111a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 164 additions and 92 deletions

View File

@ -23,7 +23,6 @@ go_library(
"//internal/honey",
"//internal/honey/search",
"//internal/lazyregexp",
"//internal/own/codeowners",
"//internal/search",
"//internal/search/client",
"//internal/search/job/jobutil",

View File

@ -28,7 +28,6 @@ import (
"github.com/sourcegraph/sourcegraph/internal/honey"
searchhoney "github.com/sourcegraph/sourcegraph/internal/honey/search"
"github.com/sourcegraph/sourcegraph/internal/lazyregexp"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
"github.com/sourcegraph/sourcegraph/internal/search"
"github.com/sourcegraph/sourcegraph/internal/search/client"
"github.com/sourcegraph/sourcegraph/internal/search/job/jobutil"
@ -521,7 +520,7 @@ func fromCommit(commit *result.CommitMatch, repoCache map[api.RepoID]*types.Sear
func fromOwner(owner *result.OwnerMatch) streamhttp.EventMatch {
switch v := owner.ResolvedOwner.(type) {
case *codeowners.Person:
case *result.OwnerPerson:
person := &streamhttp.EventPersonMatch{
Type: streamhttp.PersonMatchType,
Handle: v.Handle,
@ -535,7 +534,7 @@ func fromOwner(owner *result.OwnerMatch) streamhttp.EventMatch {
}
}
return person
case *codeowners.Team:
case *result.OwnerTeam:
return &streamhttp.EventTeamMatch{
Type: streamhttp.TeamMatchType,
Handle: v.Handle,

View File

@ -9,10 +9,10 @@ go_library(
"//cmd/frontend/enterprise",
"//enterprise/cmd/frontend/internal/own/resolvers",
"//enterprise/internal/codeintel",
"//enterprise/internal/own",
"//internal/conf/conftypes",
"//internal/database",
"//internal/gitserver",
"//internal/observation",
"//internal/own",
],
)

View File

@ -6,11 +6,11 @@ import (
"github.com/sourcegraph/sourcegraph/cmd/frontend/enterprise"
"github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/own/resolvers"
"github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own"
"github.com/sourcegraph/sourcegraph/internal/conf/conftypes"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/observation"
"github.com/sourcegraph/sourcegraph/internal/own"
)
// Init initializes the given enterpriseServices to include the required

View File

@ -8,10 +8,10 @@ go_library(
deps = [
"//cmd/frontend/graphqlbackend",
"//cmd/frontend/graphqlbackend/graphqlutil",
"//enterprise/internal/own",
"//enterprise/internal/own/codeowners",
"//internal/api",
"//internal/database",
"//internal/own",
"//internal/own/codeowners",
],
)
@ -22,14 +22,14 @@ go_test(
":resolvers",
"//cmd/frontend/backend",
"//cmd/frontend/graphqlbackend",
"//enterprise/internal/own/codeowners",
"//enterprise/internal/own/codeowners/v1:codeowners",
"//internal/actor",
"//internal/api",
"//internal/authz",
"//internal/database",
"//internal/database/fakedb",
"//internal/gitserver",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/types",
"@com_github_graph_gophers_graphql_go//relay",
],

View File

@ -7,10 +7,10 @@ import (
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend"
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend/graphqlutil"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/own"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
)
func New(db database.DB, ownService own.Service) *ownResolver {

View File

@ -10,16 +10,15 @@ import (
"github.com/sourcegraph/sourcegraph/cmd/frontend/backend"
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend"
"github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/own/resolvers"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/actor"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/authz"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/database/fakedb"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
"github.com/sourcegraph/sourcegraph/internal/types"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
)
// userCtx returns a context where give user ID identifies logged in user.

View File

@ -29,6 +29,8 @@ go_library(
"//enterprise/internal/authz/github",
"//enterprise/internal/authz/gitlab",
"//enterprise/internal/authz/perforce",
"//enterprise/internal/own/codeowners/v1:codeowners",
"//enterprise/internal/own/types",
"//internal/actor",
"//internal/api",
"//internal/authz",
@ -40,7 +42,6 @@ go_library(
"//internal/database/dbutil",
"//internal/encryption",
"//internal/extsvc",
"//internal/own/codeowners/v1:codeowners",
"//internal/search/result",
"//internal/timeutil",
"//internal/trace",
@ -85,6 +86,8 @@ go_test(
deps = [
"//cmd/frontend/globals",
"//enterprise/internal/licensing",
"//enterprise/internal/own/codeowners/v1:codeowners",
"//enterprise/internal/own/types",
"//internal/actor",
"//internal/api",
"//internal/authz",
@ -94,7 +97,6 @@ go_test(
"//internal/database/dbtest",
"//internal/database/dbutil",
"//internal/extsvc",
"//internal/own/codeowners/v1:codeowners",
"//internal/search/result",
"//internal/timeutil",
"//internal/types",

View File

@ -8,13 +8,13 @@ import (
"github.com/keegancsmith/sqlf"
"google.golang.org/protobuf/proto"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/types"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
"github.com/sourcegraph/sourcegraph/internal/database/dbutil"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/timeutil"
"github.com/sourcegraph/sourcegraph/internal/types"
"github.com/sourcegraph/sourcegraph/lib/errors"
)
@ -99,7 +99,7 @@ var codeownersColumns = []*sqlf.Query{
}
const createCodeownersQueryFmtStr = `
INSERT INTO codeowners
INSERT INTO codeowners
(%s)
VALUES (%s, %s, %s, %s, %s)
`
@ -143,12 +143,12 @@ func (s *codeownersStore) UpdateCodeownersFile(ctx context.Context, file *types.
}
const updateCodeownersQueryFmtStr = `
UPDATE codeowners
SET
UPDATE codeowners
SET
contents = %s,
contents_proto = %s,
updated_at = %s
WHERE
WHERE
%s
`
@ -170,7 +170,7 @@ func (s *codeownersStore) GetCodeownersForRepo(ctx context.Context, id api.RepoI
const getCodeownersFileQueryFmtStr = `
SELECT %s
FROM codeowners
FROM codeowners
WHERE %s
LIMIT 1
`
@ -199,7 +199,7 @@ func (s *codeownersStore) DeleteCodeownersForRepo(ctx context.Context, id api.Re
}
const deleteCodeownersFileQueryFmtStr = `
DELETE FROM codeowners
DELETE FROM codeowners
WHERE %s
`
@ -240,10 +240,10 @@ func (s *codeownersStore) ListCodeowners(ctx context.Context, opts ListCodeowner
const listCodeownersFilesQueryFmtStr = `
SELECT %s
FROM codeowners
FROM codeowners
WHERE %s
ORDER BY
repo_id ASC
ORDER BY
repo_id ASC
%s
`

View File

@ -10,10 +10,11 @@ import (
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/testing/protocmp"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
owntypes "github.com/sourcegraph/sourcegraph/enterprise/internal/own/types"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/database/dbtest"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/timeutil"
"github.com/sourcegraph/sourcegraph/internal/types"
)
@ -109,7 +110,7 @@ func TestCodeowners_GetList(t *testing.T) {
store := db.Codeowners()
createFile := func(file *types.CodeownersFile) *types.CodeownersFile {
createFile := func(file *owntypes.CodeownersFile) *owntypes.CodeownersFile {
if err := store.CreateCodeownersFile(ctx, file); err != nil {
t.Fatal(err)
}
@ -158,7 +159,7 @@ func TestCodeowners_GetList(t *testing.T) {
})
t.Run("list", func(t *testing.T) {
all := []*types.CodeownersFile{repo1Codeowners, repo2Codeowners}
all := []*owntypes.CodeownersFile{repo1Codeowners, repo2Codeowners}
// List all
have, cursor, err := store.ListCodeowners(ctx, ListCodeownersOpts{})
@ -192,8 +193,8 @@ func TestCodeowners_GetList(t *testing.T) {
}
// newCodeownersFile returns a simple test Codeowners file with one pattern and one owner.
func newCodeownersFile(pattern, handle string, repoID api.RepoID) *types.CodeownersFile {
return &types.CodeownersFile{
func newCodeownersFile(pattern, handle string, repoID api.RepoID) *owntypes.CodeownersFile {
return &owntypes.CodeownersFile{
Contents: fmt.Sprintf("%s @%s", pattern, handle),
Proto: &codeownerspb.File{
Rule: []*codeownerspb.Rule{

View File

@ -3,16 +3,16 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "own",
srcs = ["service.go"],
importpath = "github.com/sourcegraph/sourcegraph/internal/own",
visibility = ["//:__subpackages__"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/own",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/own/codeowners",
"//enterprise/internal/own/codeowners/v1:codeowners",
"//internal/api",
"//internal/authz",
"//internal/database",
"//internal/errcode",
"//internal/gitserver",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/types",
],
)
@ -22,12 +22,12 @@ go_test(
srcs = ["service_test.go"],
deps = [
":own",
"//enterprise/internal/own/codeowners",
"//enterprise/internal/own/codeowners/v1:codeowners",
"//internal/api",
"//internal/authz",
"//internal/database",
"//internal/gitserver",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/types",
"//lib/errors",
"@com_github_stretchr_testify//assert",

View File

@ -9,11 +9,11 @@ go_library(
"parse.go",
"repr.go",
],
importpath = "github.com/sourcegraph/sourcegraph/internal/own/codeowners",
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners",
visibility = ["//:__subpackages__"],
deps = [
"//enterprise/internal/own/codeowners/v1:codeowners",
"//internal/lazyregexp",
"//internal/own/codeowners/v1:codeowners",
"//internal/types",
"//lib/errors",
"@com_github_becheran_wildmatch_go//:wildmatch-go",
@ -28,7 +28,7 @@ go_test(
],
deps = [
":codeowners",
"//internal/own/codeowners/v1:codeowners",
"//enterprise/internal/own/codeowners/v1:codeowners",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],

View File

@ -3,7 +3,7 @@ package codeowners
import (
"sync"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
)
type Ruleset struct {

View File

@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
)
type testCase struct {

View File

@ -6,8 +6,8 @@ import (
"net/mail"
"strings"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/lazyregexp"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/lib/errors"
)

View File

@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
)
func TestParseGithubExample(t *testing.T) {

View File

@ -14,7 +14,7 @@ proto_library(
go_library(
name = "codeowners",
srcs = ["codeowners.pb.go"],
importpath = "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1",
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1",
visibility = ["//:__subpackages__"],
deps = [
"@org_golang_google_protobuf//reflect/protoreflect",

View File

@ -280,12 +280,12 @@ var file_codeowners_proto_rawDesc = []byte{
0x72, 0x22, 0x35, 0x0a, 0x05, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x61,
0x6e, 0x64, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x61, 0x6e, 0x64,
0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68,
0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61,
0x70, 0x68, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x69,
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6f, 0x77, 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65,
0x6f, 0x77, 0x6e, 0x65, 0x72, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x70, 0x68, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x65,
0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
0x61, 0x6c, 0x2f, 0x6f, 0x77, 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x6f, 0x77, 0x6e, 0x65, 0x72,
0x73, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -6,7 +6,7 @@ syntax = "proto3";
package own.codeowners.v1;
option go_package = "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1";
option go_package = "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1";
// File represents the contents of a single CODEOWNERS file.
// As specified by various CODEOWNERS implementations the following apply:

View File

@ -53,15 +53,15 @@ go_library(
"rules_cache.go",
"select_job.go",
],
importpath = "github.com/sourcegraph/sourcegraph/internal/own/search",
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/own/search",
visibility = ["//:__subpackages__"],
deps = [
"//enterprise/internal/own",
"//enterprise/internal/own/codeowners",
"//enterprise/internal/own/codeowners/v1:codeowners",
"//internal/api",
"//internal/database",
"//internal/gitserver",
"//internal/own",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/search",
"//internal/search/job",
"//internal/search/result",
@ -84,7 +84,6 @@ go_test(
"//internal/authz",
"//internal/database",
"//internal/gitserver",
"//internal/own/codeowners",
"//internal/search/result",
"//internal/types",
"@com_github_hexops_autogold_v2//:autogold",

View File

@ -7,7 +7,7 @@ import (
otlog "github.com/opentracing/opentracing-go/log"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/search"
"github.com/sourcegraph/sourcegraph/internal/search/job"
"github.com/sourcegraph/sourcegraph/internal/search/result"

View File

@ -4,12 +4,12 @@ import (
"context"
"sync"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/own"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
)
type RulesKey struct {

View File

@ -6,6 +6,7 @@ import (
otlog "github.com/opentracing/opentracing-go/log"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
"github.com/sourcegraph/sourcegraph/internal/search"
"github.com/sourcegraph/sourcegraph/internal/search/job"
"github.com/sourcegraph/sourcegraph/internal/search/result"
@ -107,7 +108,7 @@ matchesLoop:
}
for _, o := range resolvedOwners {
ownerMatch := &result.OwnerMatch{
ResolvedOwner: o,
ResolvedOwner: ownerToResult(o),
InputRev: mm.InputRev,
Repo: mm.Repo,
CommitID: mm.CommitID,
@ -117,3 +118,21 @@ matchesLoop:
}
return ownerMatches, errs
}
func ownerToResult(o codeowners.ResolvedOwner) result.Owner {
if v, ok := o.(*codeowners.Person); ok {
return &result.OwnerPerson{
Handle: v.Handle,
Email: v.Email,
User: v.User,
}
}
if v, ok := o.(*codeowners.Team); ok {
return &result.OwnerTeam{
Handle: v.Handle,
Email: v.Email,
Team: v.Team,
}
}
panic("unimplemented resolved owner in ownerToResult")
}

View File

@ -13,7 +13,6 @@ import (
"github.com/sourcegraph/sourcegraph/internal/authz"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
"github.com/sourcegraph/sourcegraph/internal/search/result"
"github.com/sourcegraph/sourcegraph/internal/types"
)
@ -123,28 +122,28 @@ func TestGetCodeOwnersFromMatches(t *testing.T) {
}
want := []result.Match{
&result.OwnerMatch{
ResolvedOwner: &codeowners.Person{User: personOwnerByEmail, Email: "user@email.com"},
ResolvedOwner: &result.OwnerPerson{User: personOwnerByEmail, Email: "user@email.com"},
InputRev: nil,
Repo: types.MinimalRepo{},
CommitID: "",
LimitHit: 0,
},
&result.OwnerMatch{
ResolvedOwner: &codeowners.Person{Handle: "unknown"},
ResolvedOwner: &result.OwnerPerson{Handle: "unknown"},
InputRev: nil,
Repo: types.MinimalRepo{},
CommitID: "",
LimitHit: 0,
},
&result.OwnerMatch{
ResolvedOwner: &codeowners.Person{User: personOwnerByHandle, Handle: "testUserHandle"},
ResolvedOwner: &result.OwnerPerson{User: personOwnerByHandle, Handle: "testUserHandle"},
InputRev: nil,
Repo: types.MinimalRepo{},
CommitID: "",
LimitHit: 0,
},
&result.OwnerMatch{
ResolvedOwner: &codeowners.Team{Team: teamOwner, Handle: "testTeamHandle"},
ResolvedOwner: &result.OwnerTeam{Team: teamOwner, Handle: "testTeamHandle"},
InputRev: nil,
Repo: types.MinimalRepo{},
CommitID: "",

View File

@ -6,13 +6,13 @@ import (
"os"
"sync"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/authz"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/errcode"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/types"
)

View File

@ -9,13 +9,13 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/authz"
"github.com/sourcegraph/sourcegraph/internal/database"
"github.com/sourcegraph/sourcegraph/internal/gitserver"
"github.com/sourcegraph/sourcegraph/internal/own"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/types"
"github.com/sourcegraph/sourcegraph/lib/errors"
)

View File

@ -0,0 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "types",
srcs = ["types.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/own/types",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/own/codeowners/v1:codeowners",
"//internal/api",
],
)

View File

@ -0,0 +1,17 @@
package types
import (
"time"
codeownerspb "github.com/sourcegraph/sourcegraph/enterprise/internal/own/codeowners/v1"
"github.com/sourcegraph/sourcegraph/internal/api"
)
type CodeownersFile struct {
CreatedAt time.Time
UpdatedAt time.Time
RepoID api.RepoID
Contents string
Proto *codeownerspb.File
}

View File

@ -6,7 +6,7 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/search",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//internal/own/search",
"//enterprise/internal/own/search",
"//internal/search/job",
"//internal/search/job/jobutil",
],

View File

@ -1,7 +1,7 @@
package search
import (
"github.com/sourcegraph/sourcegraph/internal/own/search"
"github.com/sourcegraph/sourcegraph/enterprise/internal/own/search"
"github.com/sourcegraph/sourcegraph/internal/search/job"
"github.com/sourcegraph/sourcegraph/internal/search/job/jobutil"
)

View File

@ -24,7 +24,6 @@ go_library(
"//internal/api",
"//internal/gitserver/gitdomain",
"//internal/lazyregexp",
"//internal/own/codeowners",
"//internal/search/filter",
"//internal/types",
"//lib/errors",

View File

@ -2,13 +2,45 @@ package result
import (
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/own/codeowners"
"github.com/sourcegraph/sourcegraph/internal/search/filter"
"github.com/sourcegraph/sourcegraph/internal/types"
)
type Owner interface {
Type() string
Identifier() string
}
type OwnerPerson struct {
Handle string
Email string
User *types.User
}
func (o OwnerPerson) Identifier() string {
return "Person:" + o.Handle + o.Email
}
func (o OwnerPerson) Type() string {
return "person"
}
type OwnerTeam struct {
Handle string
Email string
Team *types.Team
}
func (o OwnerTeam) Identifier() string {
return "Team:" + o.Team.Name
}
func (o OwnerTeam) Type() string {
return "team"
}
type OwnerMatch struct {
ResolvedOwner codeowners.ResolvedOwner
ResolvedOwner Owner
// The following contain information about what search the owner was matched from.
InputRev *string `json:"-"`
@ -53,7 +85,7 @@ func (om *OwnerMatch) Key() Key {
Commit: om.CommitID,
}
if om.ResolvedOwner != nil {
k.OwnerMetadata = string(om.ResolvedOwner.Type()) + om.ResolvedOwner.Identifier()
k.OwnerMetadata = om.ResolvedOwner.Type() + om.ResolvedOwner.Identifier()
}
if om.InputRev != nil {
k.Rev = *om.InputRev

View File

@ -24,7 +24,6 @@ go_library(
"//internal/executor",
"//internal/extsvc",
"//internal/jsonc",
"//internal/own/codeowners/v1:codeowners",
"//lib/errors",
"//schema",
"@com_github_google_uuid//:uuid",

View File

@ -15,7 +15,6 @@ import (
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/encryption"
"github.com/sourcegraph/sourcegraph/internal/extsvc"
codeownerspb "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1"
)
// BatchChangeSource represents how a batch change can be created
@ -1888,15 +1887,6 @@ type TeamMember struct {
UpdatedAt time.Time
}
type CodeownersFile struct {
CreatedAt time.Time
UpdatedAt time.Time
RepoID api.RepoID
Contents string
Proto *codeownerspb.File
}
type AccessRequestStatus string
type AccessRequest struct {

View File

@ -733,6 +733,12 @@ go_library(
"frontend/1677627566_add_index_to_reference_scan_column/down.sql",
"frontend/1677627566_add_index_to_reference_scan_column/metadata.yaml",
"frontend/1677627566_add_index_to_reference_scan_column/up.sql",
"frontend/1677694168_add_vulnerability_tables/down.sql",
"frontend/1677694168_add_vulnerability_tables/metadata.yaml",
"frontend/1677694168_add_vulnerability_tables/up.sql",
"frontend/1677694170_add_vulnerability_match_tables/down.sql",
"frontend/1677694170_add_vulnerability_match_tables/metadata.yaml",
"frontend/1677694170_add_vulnerability_match_tables/up.sql",
],
importpath = "github.com/sourcegraph/sourcegraph/migrations",
visibility = ["//visibility:public"],