mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 16:51:55 +00:00
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:
parent
956596daa1
commit
905e01111a
@ -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",
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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",
|
||||
],
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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
|
||||
`
|
||||
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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",
|
||||
@ -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",
|
||||
],
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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) {
|
||||
@ -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",
|
||||
@ -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 (
|
||||
@ -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:
|
||||
@ -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",
|
||||
@ -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"
|
||||
@ -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 {
|
||||
@ -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")
|
||||
}
|
||||
@ -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: "",
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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"
|
||||
)
|
||||
12
enterprise/internal/own/types/BUILD.bazel
Normal file
12
enterprise/internal/own/types/BUILD.bazel
Normal 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",
|
||||
],
|
||||
)
|
||||
17
enterprise/internal/own/types/types.go
Normal file
17
enterprise/internal/own/types/types.go
Normal 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
|
||||
}
|
||||
@ -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",
|
||||
],
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -24,7 +24,6 @@ go_library(
|
||||
"//internal/api",
|
||||
"//internal/gitserver/gitdomain",
|
||||
"//internal/lazyregexp",
|
||||
"//internal/own/codeowners",
|
||||
"//internal/search/filter",
|
||||
"//internal/types",
|
||||
"//lib/errors",
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user