diff options
277 files changed, 2106 insertions, 2214 deletions
diff --git a/_support/vendor-gitaly-proto b/_support/vendor-gitaly-proto index fc4c36f51..d2b1f4f0f 100755 --- a/_support/vendor-gitaly-proto +++ b/_support/vendor-gitaly-proto @@ -7,7 +7,7 @@ USAGE = "Usage: #{PROGNAME} [--fork GITALY_PROTO_FORK_REPO] REVISION" ORIGIN = 'gitlab.com/gitlab-org/gitaly-proto' def main(revision, repo:) - run!(%W[govendor fetch #{ORIGIN}/go::#{repo}/go@#{revision}]) + run!(%W[govendor fetch #{ORIGIN}/go/gitalypb::#{repo}/go/gitalypb@#{revision}]) end options = ARGV.getopts(nil, 'fork:') diff --git a/changelogs/unreleased/zj-rename-pb-gitalypb.yml b/changelogs/unreleased/zj-rename-pb-gitalypb.yml new file mode 100644 index 000000000..4bc2818d9 --- /dev/null +++ b/changelogs/unreleased/zj-rename-pb-gitalypb.yml @@ -0,0 +1,5 @@ +--- +title: Rename gitaly proto import to gitalypb +merge_request: 895 +author: +type: other diff --git a/client/receive_pack.go b/client/receive_pack.go index 84dbe8895..3d33acb55 100644 --- a/client/receive_pack.go +++ b/client/receive_pack.go @@ -3,20 +3,19 @@ package client import ( "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc" ) // ReceivePack proxies an SSH git-receive-pack (git push) session to Gitaly -func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, stdout, stderr io.Writer, req *pb.SSHReceivePackRequest) (int32, error) { +func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, stdout, stderr io.Writer, req *gitalypb.SSHReceivePackRequest) (int32, error) { ctx2, cancel := context.WithCancel(ctx) defer cancel() - ssh := pb.NewSSHServiceClient(conn) + ssh := gitalypb.NewSSHServiceClient(conn) stream, err := ssh.SSHReceivePack(ctx2) if err != nil { return 0, err @@ -27,7 +26,7 @@ func ReceivePack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, st } inWriter := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHReceivePackRequest{Stdin: p}) + return stream.Send(&gitalypb.SSHReceivePackRequest{Stdin: p}) }) return streamHandler(func() (stdoutStderrResponse, error) { diff --git a/client/std_stream.go b/client/std_stream.go index 83d2589bf..157aef4a6 100644 --- a/client/std_stream.go +++ b/client/std_stream.go @@ -4,11 +4,11 @@ import ( "fmt" "io" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) type stdoutStderrResponse interface { - GetExitStatus() *pb.ExitStatus + GetExitStatus() *gitalypb.ExitStatus GetStderr() []byte GetStdout() []byte } diff --git a/client/upload_archive.go b/client/upload_archive.go index 6b4d68216..9bcc9fc82 100644 --- a/client/upload_archive.go +++ b/client/upload_archive.go @@ -3,20 +3,19 @@ package client import ( "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc" ) // UploadArchive proxies an SSH git-upload-archive (git archive --remote) session to Gitaly -func UploadArchive(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, stdout, stderr io.Writer, req *pb.SSHUploadArchiveRequest) (int32, error) { +func UploadArchive(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, stdout, stderr io.Writer, req *gitalypb.SSHUploadArchiveRequest) (int32, error) { ctx2, cancel := context.WithCancel(ctx) defer cancel() - ssh := pb.NewSSHServiceClient(conn) + ssh := gitalypb.NewSSHServiceClient(conn) stream, err := ssh.SSHUploadArchive(ctx2) if err != nil { return 0, err @@ -27,7 +26,7 @@ func UploadArchive(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, } inWriter := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHUploadArchiveRequest{Stdin: p}) + return stream.Send(&gitalypb.SSHUploadArchiveRequest{Stdin: p}) }) return streamHandler(func() (stdoutStderrResponse, error) { diff --git a/client/upload_pack.go b/client/upload_pack.go index 690ae6556..ed3dd796c 100644 --- a/client/upload_pack.go +++ b/client/upload_pack.go @@ -3,20 +3,19 @@ package client import ( "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc" ) // UploadPack proxies an SSH git-upload-pack (git fetch) session to Gitaly -func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, stdout, stderr io.Writer, req *pb.SSHUploadPackRequest) (int32, error) { +func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, stdout, stderr io.Writer, req *gitalypb.SSHUploadPackRequest) (int32, error) { ctx2, cancel := context.WithCancel(ctx) defer cancel() - ssh := pb.NewSSHServiceClient(conn) + ssh := gitalypb.NewSSHServiceClient(conn) stream, err := ssh.SSHUploadPack(ctx2) if err != nil { return 0, err @@ -27,7 +26,7 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std } inWriter := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHUploadPackRequest{Stdin: p}) + return stream.Send(&gitalypb.SSHUploadPackRequest{Stdin: p}) }) return streamHandler(func() (stdoutStderrResponse, error) { diff --git a/cmd/gitaly-ssh/receive_pack.go b/cmd/gitaly-ssh/receive_pack.go index 5b6489d67..7008ee19a 100644 --- a/cmd/gitaly-ssh/receive_pack.go +++ b/cmd/gitaly-ssh/receive_pack.go @@ -6,13 +6,12 @@ import ( "os" "github.com/golang/protobuf/jsonpb" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/client" ) func receivePack(url, req string) (int32, error) { - var request pb.SSHReceivePackRequest + var request gitalypb.SSHReceivePackRequest if err := jsonpb.UnmarshalString(req, &request); err != nil { return 0, fmt.Errorf("json unmarshal: %v", err) } diff --git a/cmd/gitaly-ssh/upload_archive.go b/cmd/gitaly-ssh/upload_archive.go index 0e5c3d3df..c7fa7356e 100644 --- a/cmd/gitaly-ssh/upload_archive.go +++ b/cmd/gitaly-ssh/upload_archive.go @@ -6,13 +6,12 @@ import ( "os" "github.com/golang/protobuf/jsonpb" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/client" ) func uploadArchive(url, req string) (int32, error) { - var request pb.SSHUploadArchiveRequest + var request gitalypb.SSHUploadArchiveRequest if err := jsonpb.UnmarshalString(req, &request); err != nil { return 0, fmt.Errorf("json unmarshal: %v", err) } diff --git a/cmd/gitaly-ssh/upload_pack.go b/cmd/gitaly-ssh/upload_pack.go index 9526ea295..cd3a26d83 100644 --- a/cmd/gitaly-ssh/upload_pack.go +++ b/cmd/gitaly-ssh/upload_pack.go @@ -6,13 +6,12 @@ import ( "os" "github.com/golang/protobuf/jsonpb" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/client" ) func uploadPack(url, req string) (int32, error) { - var request pb.SSHUploadPackRequest + var request gitalypb.SSHUploadPackRequest if err := jsonpb.UnmarshalString(req, &request); err != nil { return 0, fmt.Errorf("json unmarshal: %v", err) } diff --git a/internal/git/alternates/alternates.go b/internal/git/alternates/alternates.go index 5d2de1fc4..25ac0cf3e 100644 --- a/internal/git/alternates/alternates.go +++ b/internal/git/alternates/alternates.go @@ -5,14 +5,14 @@ import ( "path" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" ) // PathAndEnv finds the disk path to a repository, and returns the // alternate object directory environment variables encoded in the -// pb.Repository instance. -func PathAndEnv(repo *pb.Repository) (string, []string, error) { +// gitalypb.Repository instance. +func PathAndEnv(repo *gitalypb.Repository) (string, []string, error) { repoPath, err := helper.GetRepoPath(repo) if err != nil { return "", nil, err diff --git a/internal/git/catfile/catfile.go b/internal/git/catfile/catfile.go index 328579fa3..a100ed306 100644 --- a/internal/git/catfile/catfile.go +++ b/internal/git/catfile/catfile.go @@ -4,7 +4,7 @@ import ( "context" "io" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/alternates" ) @@ -52,7 +52,7 @@ func (c *Batch) Blob(revspec string) (io.Reader, error) { // New returns a new Batch instance. It is important that ctx gets canceled // somewhere, because if it doesn't the cat-file processes spawned by // New() never terminate. -func New(ctx context.Context, repo *pb.Repository) (*Batch, error) { +func New(ctx context.Context, repo *gitalypb.Repository) (*Batch, error) { if ctx.Done() == nil { panic("empty ctx.Done() in catfile.Batch.New()") } diff --git a/internal/git/command.go b/internal/git/command.go index ae9fe2675..45f569c37 100644 --- a/internal/git/command.go +++ b/internal/git/command.go @@ -4,14 +4,13 @@ import ( "context" "os/exec" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git/alternates" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) // Command creates a git.Command with the given args -func Command(ctx context.Context, repo *pb.Repository, args ...string) (*command.Command, error) { +func Command(ctx context.Context, repo *gitalypb.Repository, args ...string) (*command.Command, error) { repoPath, env, err := alternates.PathAndEnv(repo) if err != nil { return nil, err diff --git a/internal/git/log/commit.go b/internal/git/log/commit.go index ddb093834..6c84090a5 100644 --- a/internal/git/log/commit.go +++ b/internal/git/log/commit.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -18,7 +18,7 @@ import ( // GetCommit tries to resolve revision to a Git commit. Returns nil if // no object is found at revision. -func GetCommit(ctx context.Context, repo *pb.Repository, revision string) (*pb.GitCommit, error) { +func GetCommit(ctx context.Context, repo *gitalypb.Repository, revision string) (*gitalypb.GitCommit, error) { c, err := catfile.New(ctx, repo) if err != nil { return nil, err @@ -28,7 +28,7 @@ func GetCommit(ctx context.Context, repo *pb.Repository, revision string) (*pb.G } // GetCommitCatfile looks up a commit by revision using an existing *catfile.Batch instance. -func GetCommitCatfile(c *catfile.Batch, revision string) (*pb.GitCommit, error) { +func GetCommitCatfile(c *catfile.Batch, revision string) (*gitalypb.GitCommit, error) { info, err := c.Info(revision + "^{commit}") if err != nil { if catfile.IsNotFound(err) { @@ -51,7 +51,7 @@ func GetCommitCatfile(c *catfile.Batch, revision string) (*pb.GitCommit, error) return parseRawCommit(raw, info) } -func parseRawCommit(raw []byte, info *catfile.ObjectInfo) (*pb.GitCommit, error) { +func parseRawCommit(raw []byte, info *catfile.ObjectInfo) (*gitalypb.GitCommit, error) { split := bytes.SplitN(raw, []byte("\n\n"), 2) header := split[0] @@ -60,7 +60,7 @@ func parseRawCommit(raw []byte, info *catfile.ObjectInfo) (*pb.GitCommit, error) body = split[1] } - commit := &pb.GitCommit{ + commit := &gitalypb.GitCommit{ Id: info.Oid, Body: body, Subject: subjectFromBody(body), @@ -100,8 +100,8 @@ func parseRawCommit(raw []byte, info *catfile.ObjectInfo) (*pb.GitCommit, error) const maxUnixCommitDate = 1 << 53 -func parseCommitAuthor(line string) *pb.CommitAuthor { - author := &pb.CommitAuthor{} +func parseCommitAuthor(line string) *gitalypb.CommitAuthor { + author := &gitalypb.CommitAuthor{} splitName := strings.SplitN(line, "<", 2) author.Name = []byte(strings.TrimSuffix(splitName[0], " ")) diff --git a/internal/git/log/commit_test.go b/internal/git/log/commit_test.go index 5d0b93a3b..b3144aced 100644 --- a/internal/git/log/commit_test.go +++ b/internal/git/log/commit_test.go @@ -5,7 +5,7 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" ) @@ -25,51 +25,51 @@ func TestParseRawCommit(t *testing.T) { testCases := []struct { desc string in []byte - out *pb.GitCommit + out *gitalypb.GitCommit }{ { desc: "empty commit object", in: []byte{}, - out: &pb.GitCommit{Id: info.Oid}, + out: &gitalypb.GitCommit{Id: info.Oid}, }, { desc: "no email", in: []byte("author Jane Doe"), - out: &pb.GitCommit{ + out: &gitalypb.GitCommit{ Id: info.Oid, - Author: &pb.CommitAuthor{Name: []byte("Jane Doe")}, + Author: &gitalypb.CommitAuthor{Name: []byte("Jane Doe")}, }, }, { desc: "unmatched <", in: []byte("author Jane Doe <janedoe@example.com"), - out: &pb.GitCommit{ + out: &gitalypb.GitCommit{ Id: info.Oid, - Author: &pb.CommitAuthor{Name: []byte("Jane Doe")}, + Author: &gitalypb.CommitAuthor{Name: []byte("Jane Doe")}, }, }, { desc: "unmatched >", in: []byte("author Jane Doe janedoe@example.com>"), - out: &pb.GitCommit{ + out: &gitalypb.GitCommit{ Id: info.Oid, - Author: &pb.CommitAuthor{Name: []byte("Jane Doe janedoe@example.com>")}, + Author: &gitalypb.CommitAuthor{Name: []byte("Jane Doe janedoe@example.com>")}, }, }, { desc: "missing date", in: []byte("author Jane Doe <janedoe@example.com> "), - out: &pb.GitCommit{ + out: &gitalypb.GitCommit{ Id: info.Oid, - Author: &pb.CommitAuthor{Name: []byte("Jane Doe"), Email: []byte("janedoe@example.com")}, + Author: &gitalypb.CommitAuthor{Name: []byte("Jane Doe"), Email: []byte("janedoe@example.com")}, }, }, { desc: "date too high", in: []byte("author Jane Doe <janedoe@example.com> 9007199254740993 +0200"), - out: &pb.GitCommit{ + out: &gitalypb.GitCommit{ Id: info.Oid, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Jane Doe"), Email: []byte("janedoe@example.com"), Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, @@ -79,9 +79,9 @@ func TestParseRawCommit(t *testing.T) { { desc: "date negative", in: []byte("author Jane Doe <janedoe@example.com> -1 +0200"), - out: &pb.GitCommit{ + out: &gitalypb.GitCommit{ Id: info.Oid, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Jane Doe"), Email: []byte("janedoe@example.com"), Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, diff --git a/internal/git/log/last_commit.go b/internal/git/log/last_commit.go index 950b2eefb..40346659b 100644 --- a/internal/git/log/last_commit.go +++ b/internal/git/log/last_commit.go @@ -5,17 +5,16 @@ import ( "io/ioutil" "strings" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" ) // LastCommitForPath returns the last commit which modified path. -func LastCommitForPath(ctx context.Context, repo *pb.Repository, revision string, path string) (*pb.GitCommit, error) { +func LastCommitForPath(ctx context.Context, repo *gitalypb.Repository, revision string, path string) (*gitalypb.GitCommit, error) { cmd, err := git.Command(ctx, repo, "log", "--format=%H", "--max-count=1", revision, "--", path) if err != nil { return nil, err @@ -30,7 +29,7 @@ func LastCommitForPath(ctx context.Context, repo *pb.Repository, revision string } // GitLogCommand returns a Command that executes git log with the given the arguments -func GitLogCommand(ctx context.Context, repo *pb.Repository, revisions []string, paths []string, extraArgs ...string) (*command.Command, error) { +func GitLogCommand(ctx context.Context, repo *gitalypb.Repository, revisions []string, paths []string, extraArgs ...string) (*command.Command, error) { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "Revisions": revisions, }).Debug("GitLog") diff --git a/internal/git/log/log.go b/internal/git/log/log.go index da8c8f4cc..70887aada 100644 --- a/internal/git/log/log.go +++ b/internal/git/log/log.go @@ -6,20 +6,20 @@ import ( "fmt" "io" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" ) // Parser holds necessary state for parsing a git log stream type Parser struct { scanner *bufio.Scanner - currentCommit *pb.GitCommit + currentCommit *gitalypb.GitCommit err error c *catfile.Batch } // NewLogParser returns a new Parser -func NewLogParser(ctx context.Context, repo *pb.Repository, src io.Reader) (*Parser, error) { +func NewLogParser(ctx context.Context, repo *gitalypb.Repository, src io.Reader) (*Parser, error) { c, err := catfile.New(ctx, repo) if err != nil { return nil, err @@ -60,7 +60,7 @@ func (parser *Parser) Parse() bool { // Commit returns a successfully parsed git log line. It should be called only when Parser.Parse() // returns true. -func (parser *Parser) Commit() *pb.GitCommit { +func (parser *Parser) Commit() *gitalypb.GitCommit { return parser.currentCommit } diff --git a/internal/git/ref.go b/internal/git/ref.go index 2f5ec6f08..2b45a619e 100644 --- a/internal/git/ref.go +++ b/internal/git/ref.go @@ -3,11 +3,11 @@ package git import ( "context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) // IsValidRef checks if a ref in a repo is valid -func IsValidRef(ctx context.Context, repo *pb.Repository, ref string) bool { +func IsValidRef(ctx context.Context, repo *gitalypb.Repository, ref string) bool { if ref == "" { return false } diff --git a/internal/helper/fieldextractors/fieldextractor.go b/internal/helper/fieldextractors/fieldextractor.go index 07e51e20d..78b1db7dd 100644 --- a/internal/helper/fieldextractors/fieldextractor.go +++ b/internal/helper/fieldextractors/fieldextractor.go @@ -3,11 +3,11 @@ package fieldextractors import ( "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) type repositoryBasedRequest interface { - GetRepository() *pb.Repository + GetRepository() *gitalypb.Repository } type namespaceBasedRequest interface { @@ -19,7 +19,7 @@ type storageBasedRequest interface { GetStorageName() string } -func formatRepoRequest(repo *pb.Repository) map[string]interface{} { +func formatRepoRequest(repo *gitalypb.Repository) map[string]interface{} { if repo == nil { // Signals that the client did not send a repo through, which // will be useful for logging @@ -63,7 +63,7 @@ func formatNamespaceRequest(namespaceReq namespaceBasedRequest) map[string]inter } } -func formatRenameNamespaceRequest(renameReq pb.RenameNamespaceRequest) map[string]interface{} { +func formatRenameNamespaceRequest(renameReq gitalypb.RenameNamespaceRequest) map[string]interface{} { return map[string]interface{}{ "StorageName": renameReq.GetStorageName(), "From": renameReq.GetFrom(), @@ -78,8 +78,8 @@ func FieldExtractor(fullMethod string, req interface{}) map[string]interface{} { } switch req.(type) { - case pb.RenameNamespaceRequest: - return formatRenameNamespaceRequest(req.(pb.RenameNamespaceRequest)) + case gitalypb.RenameNamespaceRequest: + return formatRenameNamespaceRequest(req.(gitalypb.RenameNamespaceRequest)) case repositoryBasedRequest: return formatRepoRequest(req.(repositoryBasedRequest).GetRepository()) case namespaceBasedRequest: diff --git a/internal/helper/repo.go b/internal/helper/repo.go index cccc9d7d0..33a893421 100644 --- a/internal/helper/repo.go +++ b/internal/helper/repo.go @@ -4,10 +4,9 @@ import ( "os" "path" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -16,7 +15,7 @@ import ( // RPC Repository message. The errors returned are gRPC errors with // relevant error codes and should be passed back to gRPC without further // decoration. -func GetRepoPath(repo *pb.Repository) (string, error) { +func GetRepoPath(repo *gitalypb.Repository) (string, error) { repoPath, err := GetPath(repo) if err != nil { return "", err @@ -36,7 +35,7 @@ func GetRepoPath(repo *pb.Repository) (string, error) { // GetPath returns the path of the repo passed as first argument. An error is // returned when either the storage can't be found or the path includes // constructs trying to perform directory traversal. -func GetPath(repo *pb.Repository) (string, error) { +func GetPath(repo *gitalypb.Repository) (string, error) { storagePath, err := GetStorageByName(repo.GetStorageName()) if err != nil { return "", err diff --git a/internal/helper/repo_test.go b/internal/helper/repo_test.go index 53188000e..037831f23 100644 --- a/internal/helper/repo_test.go +++ b/internal/helper/repo_test.go @@ -5,11 +5,10 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" ) @@ -34,19 +33,19 @@ func TestGetRepoPath(t *testing.T) { testCases := []struct { desc string storages []config.Storage - repo *pb.Repository + repo *gitalypb.Repository path string err codes.Code }{ { desc: "storages configured", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath}, path: repoPath, }, { desc: "no storage config, storage name provided", - repo: &pb.Repository{StorageName: "does not exist", RelativePath: testhelper.TestRelativePath}, + repo: &gitalypb.Repository{StorageName: "does not exist", RelativePath: testhelper.TestRelativePath}, err: codes.InvalidArgument, }, { @@ -56,66 +55,66 @@ func TestGetRepoPath(t *testing.T) { { desc: "storage config provided, empty repo", storages: exampleStorages, - repo: &pb.Repository{}, + repo: &gitalypb.Repository{}, err: codes.InvalidArgument, }, { desc: "no storage config, empty repo", - repo: &pb.Repository{}, + repo: &gitalypb.Repository{}, err: codes.InvalidArgument, }, { desc: "non existing repo", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "made/up/path.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "made/up/path.git"}, err: codes.NotFound, }, { desc: "non existing storage", storages: exampleStorages, - repo: &pb.Repository{StorageName: "does not exists", RelativePath: testhelper.TestRelativePath}, + repo: &gitalypb.Repository{StorageName: "does not exists", RelativePath: testhelper.TestRelativePath}, err: codes.InvalidArgument, }, { desc: "storage defined but storage dir does not exist", storages: []config.Storage{{Name: "default", Path: "/does/not/exist"}}, - repo: &pb.Repository{StorageName: "default", RelativePath: "foobar.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "foobar.git"}, err: codes.Internal, }, { desc: "relative path with directory traversal", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "../bazqux.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "../bazqux.git"}, err: codes.InvalidArgument, }, { desc: "valid path with ..", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "foo../bazqux.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "foo../bazqux.git"}, err: codes.NotFound, // Because the directory doesn't exist }, { desc: "relative path with sneaky directory traversal", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "/../bazqux.git"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "/../bazqux.git"}, err: codes.InvalidArgument, }, { desc: "relative path with one level traversal at the end", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/.."}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/.."}, err: codes.InvalidArgument, }, { desc: "relative path with one level dashed traversal at the end", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/../"}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: testhelper.TestRelativePath + "/../"}, err: codes.InvalidArgument, }, { desc: "relative path with deep traversal at the end", storages: exampleStorages, - repo: &pb.Repository{StorageName: "default", RelativePath: "bazqux.git/../.."}, + repo: &gitalypb.Repository{StorageName: "default", RelativePath: "bazqux.git/../.."}, err: codes.InvalidArgument, }, } @@ -140,7 +139,7 @@ func TestGetRepoPath(t *testing.T) { } } -func assertInvalidRepoWithoutFile(t *testing.T, repo *pb.Repository, repoPath, file string) { +func assertInvalidRepoWithoutFile(t *testing.T, repo *gitalypb.Repository, repoPath, file string) { oldRoute := path.Join(repoPath, file) renamedRoute := path.Join(repoPath, file+"moved") os.Rename(oldRoute, renamedRoute) diff --git a/internal/rubyserver/proxy.go b/internal/rubyserver/proxy.go index 29aa97814..0888506ef 100644 --- a/internal/rubyserver/proxy.go +++ b/internal/rubyserver/proxy.go @@ -6,7 +6,7 @@ import ( "os" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "google.golang.org/grpc/metadata" @@ -27,16 +27,16 @@ const ( // path to the repository. It is not an error if the repository does not // yet exist. This can be used on RPC calls that will create a // repository. -func SetHeadersWithoutRepoCheck(ctx context.Context, repo *pb.Repository) (context.Context, error) { +func SetHeadersWithoutRepoCheck(ctx context.Context, repo *gitalypb.Repository) (context.Context, error) { return setHeaders(ctx, repo, false) } // SetHeaders adds headers that tell gitaly-ruby the full path to the repository. -func SetHeaders(ctx context.Context, repo *pb.Repository) (context.Context, error) { +func SetHeaders(ctx context.Context, repo *gitalypb.Repository) (context.Context, error) { return setHeaders(ctx, repo, true) } -func setHeaders(ctx context.Context, repo *pb.Repository, mustExist bool) (context.Context, error) { +func setHeaders(ctx context.Context, repo *gitalypb.Repository, mustExist bool) (context.Context, error) { storagePath, err := helper.GetStorageByName(repo.GetStorageName()) if err != nil { return nil, err diff --git a/internal/rubyserver/rubyserver.go b/internal/rubyserver/rubyserver.go index 44cbbd8fc..7b7cedbbd 100644 --- a/internal/rubyserver/rubyserver.go +++ b/internal/rubyserver/rubyserver.go @@ -11,6 +11,7 @@ import ( "sync" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -19,8 +20,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/version" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/grpc-ecosystem/go-grpc-prometheus" log "github.com/sirupsen/logrus" "golang.org/x/net/context" @@ -145,73 +144,73 @@ func Start() (*Server, error) { // CommitServiceClient returns a CommitServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) CommitServiceClient(ctx context.Context) (pb.CommitServiceClient, error) { +func (s *Server) CommitServiceClient(ctx context.Context) (gitalypb.CommitServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewCommitServiceClient(conn), err + return gitalypb.NewCommitServiceClient(conn), err } // DiffServiceClient returns a DiffServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) DiffServiceClient(ctx context.Context) (pb.DiffServiceClient, error) { +func (s *Server) DiffServiceClient(ctx context.Context) (gitalypb.DiffServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewDiffServiceClient(conn), err + return gitalypb.NewDiffServiceClient(conn), err } // RefServiceClient returns a RefServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) RefServiceClient(ctx context.Context) (pb.RefServiceClient, error) { +func (s *Server) RefServiceClient(ctx context.Context) (gitalypb.RefServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewRefServiceClient(conn), err + return gitalypb.NewRefServiceClient(conn), err } // OperationServiceClient returns a OperationServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) OperationServiceClient(ctx context.Context) (pb.OperationServiceClient, error) { +func (s *Server) OperationServiceClient(ctx context.Context) (gitalypb.OperationServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewOperationServiceClient(conn), err + return gitalypb.NewOperationServiceClient(conn), err } // RepositoryServiceClient returns a RefServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) RepositoryServiceClient(ctx context.Context) (pb.RepositoryServiceClient, error) { +func (s *Server) RepositoryServiceClient(ctx context.Context) (gitalypb.RepositoryServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewRepositoryServiceClient(conn), err + return gitalypb.NewRepositoryServiceClient(conn), err } // WikiServiceClient returns a WikiServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) WikiServiceClient(ctx context.Context) (pb.WikiServiceClient, error) { +func (s *Server) WikiServiceClient(ctx context.Context) (gitalypb.WikiServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewWikiServiceClient(conn), err + return gitalypb.NewWikiServiceClient(conn), err } // ConflictsServiceClient returns a ConflictsServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) ConflictsServiceClient(ctx context.Context) (pb.ConflictsServiceClient, error) { +func (s *Server) ConflictsServiceClient(ctx context.Context) (gitalypb.ConflictsServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewConflictsServiceClient(conn), err + return gitalypb.NewConflictsServiceClient(conn), err } // RemoteServiceClient returns a RemoteServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) RemoteServiceClient(ctx context.Context) (pb.RemoteServiceClient, error) { +func (s *Server) RemoteServiceClient(ctx context.Context) (gitalypb.RemoteServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewRemoteServiceClient(conn), err + return gitalypb.NewRemoteServiceClient(conn), err } // BlobServiceClient returns a BlobServiceClient instance that is // configured to connect to the running Ruby server. This assumes Start() // has been called already. -func (s *Server) BlobServiceClient(ctx context.Context) (pb.BlobServiceClient, error) { +func (s *Server) BlobServiceClient(ctx context.Context) (gitalypb.BlobServiceClient, error) { conn, err := s.getConnection(ctx) - return pb.NewBlobServiceClient(conn), err + return gitalypb.NewBlobServiceClient(conn), err } func (s *Server) getConnection(ctx context.Context) (*grpc.ClientConn, error) { diff --git a/internal/rubyserver/rubyserver_test.go b/internal/rubyserver/rubyserver_test.go index bc0d100b5..2e598fe8b 100644 --- a/internal/rubyserver/rubyserver_test.go +++ b/internal/rubyserver/rubyserver_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" @@ -29,19 +29,19 @@ func TestSetHeaders(t *testing.T) { testCases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository errType codes.Code - setter func(context.Context, *pb.Repository) (context.Context, error) + setter func(context.Context, *gitalypb.Repository) (context.Context, error) }{ { desc: "SetHeaders invalid storage", - repo: &pb.Repository{StorageName: "foo", RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar.git"}, errType: codes.InvalidArgument, setter: SetHeaders, }, { desc: "SetHeaders invalid rel path", - repo: &pb.Repository{StorageName: testRepo.StorageName, RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: testRepo.StorageName, RelativePath: "bar.git"}, errType: codes.NotFound, setter: SetHeaders, }, @@ -53,13 +53,13 @@ func TestSetHeaders(t *testing.T) { }, { desc: "SetHeadersWithoutRepoCheck invalid storage", - repo: &pb.Repository{StorageName: "foo", RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar.git"}, errType: codes.InvalidArgument, setter: SetHeadersWithoutRepoCheck, }, { desc: "SetHeadersWithoutRepoCheck invalid relative path", - repo: &pb.Repository{StorageName: testRepo.StorageName, RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: testRepo.StorageName, RelativePath: "bar.git"}, errType: codes.OK, setter: SetHeadersWithoutRepoCheck, }, diff --git a/internal/service/blob/get_blob.go b/internal/service/blob/get_blob.go index d37ab2f77..eb52e2ad3 100644 --- a/internal/service/blob/get_blob.go +++ b/internal/service/blob/get_blob.go @@ -4,17 +4,17 @@ import ( "fmt" "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) GetBlob(in *pb.GetBlobRequest, stream pb.BlobService_GetBlobServer) error { +func (s *server) GetBlob(in *gitalypb.GetBlobRequest, stream gitalypb.BlobService_GetBlobServer) error { if err := validateRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "GetBlob: %v", err) } @@ -29,14 +29,14 @@ func (s *server) GetBlob(in *pb.GetBlobRequest, stream pb.BlobService_GetBlobSer return status.Errorf(codes.Internal, "GetBlob: %v", err) } if catfile.IsNotFound(err) || objectInfo.Type != "blob" { - return helper.DecorateError(codes.Unavailable, stream.Send(&pb.GetBlobResponse{})) + return helper.DecorateError(codes.Unavailable, stream.Send(&gitalypb.GetBlobResponse{})) } readLimit := objectInfo.Size if in.Limit >= 0 && in.Limit < readLimit { readLimit = in.Limit } - firstMessage := &pb.GetBlobResponse{ + firstMessage := &gitalypb.GetBlobResponse{ Size: objectInfo.Size, Oid: objectInfo.Oid, } @@ -51,7 +51,7 @@ func (s *server) GetBlob(in *pb.GetBlobRequest, stream pb.BlobService_GetBlobSer } sw := streamio.NewWriter(func(p []byte) error { - msg := &pb.GetBlobResponse{} + msg := &gitalypb.GetBlobResponse{} if firstMessage != nil { msg = firstMessage firstMessage = nil @@ -68,7 +68,7 @@ func (s *server) GetBlob(in *pb.GetBlobRequest, stream pb.BlobService_GetBlobSer return nil } -func validateRequest(in *pb.GetBlobRequest) error { +func validateRequest(in *gitalypb.GetBlobRequest) error { if len(in.GetOid()) == 0 { return fmt.Errorf("empty Oid") } diff --git a/internal/service/blob/get_blob_test.go b/internal/service/blob/get_blob_test.go index bcccb1855..08f7d0c86 100644 --- a/internal/service/blob/get_blob_test.go +++ b/internal/service/blob/get_blob_test.go @@ -6,7 +6,7 @@ import ( "io" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -67,7 +67,7 @@ func TestSuccessfulGetBlob(t *testing.T) { } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - request := &pb.GetBlobRequest{ + request := &gitalypb.GetBlobRequest{ Repository: testRepo, Oid: tc.oid, Limit: int64(tc.limit), @@ -100,7 +100,7 @@ func TestGetBlobNotFound(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.GetBlobRequest{ + request := &gitalypb.GetBlobRequest{ Repository: testRepo, Oid: "doesnotexist", } @@ -119,7 +119,7 @@ func TestGetBlobNotFound(t *testing.T) { require.Zero(t, len(data)) } -func getBlob(stream pb.BlobService_GetBlobClient) (int64, string, []byte, error) { +func getBlob(stream gitalypb.BlobService_GetBlobClient) (int64, string, []byte, error) { firstResponse, err := stream.Recv() if err != nil { return 0, "", nil, err @@ -157,8 +157,8 @@ func TestFailedGetBlobRequestDueToValidationError(t *testing.T) { defer conn.Close() oid := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72" - rpcRequests := []pb.GetBlobRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, Oid: oid}, // Repository doesn't exist + rpcRequests := []gitalypb.GetBlobRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, Oid: oid}, // Repository doesn't exist {Repository: nil, Oid: oid}, // Repository is nil {Repository: testRepo}, // Oid is empty } diff --git a/internal/service/blob/get_blobs.go b/internal/service/blob/get_blobs.go index e52170bec..8b40bf2d7 100644 --- a/internal/service/blob/get_blobs.go +++ b/internal/service/blob/get_blobs.go @@ -4,17 +4,16 @@ import ( "io" "io/ioutil" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/service/commit" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func sendGetBlobsResponse(req *pb.GetBlobsRequest, stream pb.BlobService_GetBlobsServer, c *catfile.Batch) error { +func sendGetBlobsResponse(req *gitalypb.GetBlobsRequest, stream gitalypb.BlobService_GetBlobsServer, c *catfile.Batch) error { for _, revisionPath := range req.RevisionPaths { revision := revisionPath.Revision path := revisionPath.Path @@ -24,7 +23,7 @@ func sendGetBlobsResponse(req *pb.GetBlobsRequest, stream pb.BlobService_GetBlob return err } - response := &pb.GetBlobsResponse{Revision: revision, Path: path} + response := &gitalypb.GetBlobsResponse{Revision: revision, Path: path} if treeEntry == nil || len(treeEntry.Oid) == 0 { if err := stream.Send(response); err != nil { @@ -37,7 +36,7 @@ func sendGetBlobsResponse(req *pb.GetBlobsRequest, stream pb.BlobService_GetBlob response.Mode = treeEntry.Mode response.Oid = treeEntry.Oid - if treeEntry.Type == pb.TreeEntry_COMMIT { + if treeEntry.Type == gitalypb.TreeEntry_COMMIT { response.IsSubmodule = true if err := stream.Send(response); err != nil { @@ -80,7 +79,7 @@ func sendGetBlobsResponse(req *pb.GetBlobsRequest, stream pb.BlobService_GetBlob } sw := streamio.NewWriter(func(p []byte) error { - msg := &pb.GetBlobsResponse{} + msg := &gitalypb.GetBlobsResponse{} if response != nil { msg = response response = nil @@ -104,7 +103,7 @@ func sendGetBlobsResponse(req *pb.GetBlobsRequest, stream pb.BlobService_GetBlob return nil } -func (*server) GetBlobs(req *pb.GetBlobsRequest, stream pb.BlobService_GetBlobsServer) error { +func (*server) GetBlobs(req *gitalypb.GetBlobsRequest, stream gitalypb.BlobService_GetBlobsServer) error { if req.Repository == nil { return status.Errorf(codes.InvalidArgument, "GetBlobs: empty Repository") } diff --git a/internal/service/blob/get_blobs_test.go b/internal/service/blob/get_blobs_test.go index c678b3ab6..d00ec631c 100644 --- a/internal/service/blob/get_blobs_test.go +++ b/internal/service/blob/get_blobs_test.go @@ -6,10 +6,9 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -24,7 +23,7 @@ func TestSuccessfulGetBlobsRequest(t *testing.T) { client, conn := newBlobClient(t, serverSocketPath) defer conn.Close() - expectedBlobs := []*pb.GetBlobsResponse{ + expectedBlobs := []*gitalypb.GetBlobsResponse{ { Path: []byte("CHANGELOG"), Size: 22846, @@ -56,13 +55,13 @@ func TestSuccessfulGetBlobsRequest(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "worktree", "add", "blobs-sandbox", revision) - var revisionPaths []*pb.GetBlobsRequest_RevisionPath + var revisionPaths []*gitalypb.GetBlobsRequest_RevisionPath for _, blob := range expectedBlobs { - revisionPaths = append(revisionPaths, &pb.GetBlobsRequest_RevisionPath{Revision: revision, Path: blob.Path}) + revisionPaths = append(revisionPaths, &gitalypb.GetBlobsRequest_RevisionPath{Revision: revision, Path: blob.Path}) } revisionPaths = append(revisionPaths, - &pb.GetBlobsRequest_RevisionPath{Revision: "does-not-exist", Path: []byte("CHANGELOG")}, - &pb.GetBlobsRequest_RevisionPath{Revision: revision, Path: []byte("file-that-does-not-exist")}, + &gitalypb.GetBlobsRequest_RevisionPath{Revision: "does-not-exist", Path: []byte("CHANGELOG")}, + &gitalypb.GetBlobsRequest_RevisionPath{Revision: revision, Path: []byte("file-that-does-not-exist")}, ) for _, limit := range limits { @@ -70,7 +69,7 @@ func TestSuccessfulGetBlobsRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.GetBlobsRequest{ + request := &gitalypb.GetBlobsRequest{ Repository: testRepo, RevisionPaths: revisionPaths, Limit: int64(limit), @@ -79,8 +78,8 @@ func TestSuccessfulGetBlobsRequest(t *testing.T) { c, err := client.GetBlobs(ctx, request) require.NoError(t, err) - var receivedBlobs []*pb.GetBlobsResponse - var nonExistentBlobs []*pb.GetBlobsResponse + var receivedBlobs []*gitalypb.GetBlobsResponse + var nonExistentBlobs []*gitalypb.GetBlobsResponse for { response, err := c.Recv() @@ -134,13 +133,13 @@ func TestFailedGetBlobsRequestDueToValidation(t *testing.T) { testCases := []struct { desc string - request *pb.GetBlobsRequest + request *gitalypb.GetBlobsRequest code codes.Code }{ { desc: "empty Repository", - request: &pb.GetBlobsRequest{ - RevisionPaths: []*pb.GetBlobsRequest_RevisionPath{ + request: &gitalypb.GetBlobsRequest{ + RevisionPaths: []*gitalypb.GetBlobsRequest_RevisionPath{ {Revision: "does-not-exist", Path: []byte("file")}, }, }, @@ -148,7 +147,7 @@ func TestFailedGetBlobsRequestDueToValidation(t *testing.T) { }, { desc: "empty RevisionPaths", - request: &pb.GetBlobsRequest{ + request: &gitalypb.GetBlobsRequest{ Repository: testRepo, }, code: codes.InvalidArgument, diff --git a/internal/service/blob/lfs_pointers.go b/internal/service/blob/lfs_pointers.go index 573e658da..4e012cfde 100644 --- a/internal/service/blob/lfs_pointers.go +++ b/internal/service/blob/lfs_pointers.go @@ -3,21 +3,20 @@ package blob import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) type getLFSPointerByRevisionRequest interface { - GetRepository() *pb.Repository + GetRepository() *gitalypb.Repository GetRevision() []byte } -func (s *server) GetLFSPointers(req *pb.GetLFSPointersRequest, stream pb.BlobService_GetLFSPointersServer) error { +func (s *server) GetLFSPointers(req *gitalypb.GetLFSPointersRequest, stream gitalypb.BlobService_GetLFSPointersServer) error { ctx := stream.Context() if err := validateGetLFSPointersRequest(req); err != nil { @@ -50,7 +49,7 @@ func (s *server) GetLFSPointers(req *pb.GetLFSPointersRequest, stream pb.BlobSer }) } -func validateGetLFSPointersRequest(req *pb.GetLFSPointersRequest) error { +func validateGetLFSPointersRequest(req *gitalypb.GetLFSPointersRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } @@ -62,7 +61,7 @@ func validateGetLFSPointersRequest(req *pb.GetLFSPointersRequest) error { return nil } -func (s *server) GetNewLFSPointers(in *pb.GetNewLFSPointersRequest, stream pb.BlobService_GetNewLFSPointersServer) error { +func (s *server) GetNewLFSPointers(in *gitalypb.GetNewLFSPointersRequest, stream gitalypb.BlobService_GetNewLFSPointersServer) error { ctx := stream.Context() if err := validateGetLfsPointersByRevisionRequest(in); err != nil { @@ -95,7 +94,7 @@ func (s *server) GetNewLFSPointers(in *pb.GetNewLFSPointersRequest, stream pb.Bl }) } -func (s *server) GetAllLFSPointers(in *pb.GetAllLFSPointersRequest, stream pb.BlobService_GetAllLFSPointersServer) error { +func (s *server) GetAllLFSPointers(in *gitalypb.GetAllLFSPointersRequest, stream gitalypb.BlobService_GetAllLFSPointersServer) error { ctx := stream.Context() if err := validateGetLfsPointersByRevisionRequest(in); err != nil { diff --git a/internal/service/blob/lfs_pointers_test.go b/internal/service/blob/lfs_pointers_test.go index 0d25a5fb0..4a741f148 100644 --- a/internal/service/blob/lfs_pointers_test.go +++ b/internal/service/blob/lfs_pointers_test.go @@ -5,10 +5,9 @@ import ( "os/exec" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -36,7 +35,7 @@ func TestSuccessfulGetLFSPointersRequest(t *testing.T) { "60ecb67744cb56576c30214ff52294f8ce2def98", // commit } - expectedLFSPointers := []*pb.LFSPointer{ + expectedLFSPointers := []*gitalypb.LFSPointer{ { Size: 133, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897\nsize 1575078\n\n"), @@ -54,7 +53,7 @@ func TestSuccessfulGetLFSPointersRequest(t *testing.T) { }, } - request := &pb.GetLFSPointersRequest{ + request := &gitalypb.GetLFSPointersRequest{ Repository: testRepo, BlobIds: append(lfsPointerIds, otherObjectIds...), } @@ -62,7 +61,7 @@ func TestSuccessfulGetLFSPointersRequest(t *testing.T) { stream, err := client.GetLFSPointers(ctx, request) require.NoError(t, err) - var receivedLFSPointers []*pb.LFSPointer + var receivedLFSPointers []*gitalypb.LFSPointer for { resp, err := stream.Recv() if err == io.EOF { @@ -89,12 +88,12 @@ func TestFailedGetLFSPointersRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.GetLFSPointersRequest + request *gitalypb.GetLFSPointersRequest code codes.Code }{ { desc: "empty Repository", - request: &pb.GetLFSPointersRequest{ + request: &gitalypb.GetLFSPointersRequest{ Repository: nil, BlobIds: []string{"f00"}, }, @@ -102,7 +101,7 @@ func TestFailedGetLFSPointersRequestDueToValidations(t *testing.T) { }, { desc: "empty BlobIds", - request: &pb.GetLFSPointersRequest{ + request: &gitalypb.GetLFSPointersRequest{ Repository: testRepo, BlobIds: nil, }, @@ -148,16 +147,16 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { testCases := []struct { desc string - request *pb.GetNewLFSPointersRequest - expectedLFSPointers []*pb.LFSPointer + request *gitalypb.GetNewLFSPointersRequest + expectedLFSPointers []*gitalypb.LFSPointer }{ { desc: "standard request", - request: &pb.GetNewLFSPointersRequest{ + request: &gitalypb.GetNewLFSPointersRequest{ Repository: testRepo, Revision: revision, }, - expectedLFSPointers: []*pb.LFSPointer{ + expectedLFSPointers: []*gitalypb.LFSPointer{ { Size: 133, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897\nsize 1575078\n\n"), @@ -177,11 +176,11 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { }, { desc: "request with revision in alternate directory", - request: &pb.GetNewLFSPointersRequest{ + request: &gitalypb.GetNewLFSPointersRequest{ Repository: testRepo, Revision: altDirsCommit, }, - expectedLFSPointers: []*pb.LFSPointer{ + expectedLFSPointers: []*gitalypb.LFSPointer{ { Size: 133, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897\nsize 1575078\n\n"), @@ -201,7 +200,7 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { }, { desc: "request with limit", - request: &pb.GetNewLFSPointersRequest{ + request: &gitalypb.GetNewLFSPointersRequest{ Repository: testRepo, Revision: revision, // This is limiting the amount of lines processed from the @@ -212,7 +211,7 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { // way the current implementation works ¯\_(ツ)_/¯ Limit: 19, }, - expectedLFSPointers: []*pb.LFSPointer{ + expectedLFSPointers: []*gitalypb.LFSPointer{ { Size: 127, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:bad71f905b60729f502ca339f7c9f001281a3d12c68a5da7f15de8009f4bd63d\nsize 18\n"), @@ -227,12 +226,12 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { }, { desc: "with NotInAll true", - request: &pb.GetNewLFSPointersRequest{ + request: &gitalypb.GetNewLFSPointersRequest{ Repository: testRepo, Revision: newRevision, NotInAll: true, }, - expectedLFSPointers: []*pb.LFSPointer{ + expectedLFSPointers: []*gitalypb.LFSPointer{ { Size: 133, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897\nsize 1575078\n\n"), @@ -242,12 +241,12 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { }, { desc: "with some NotInRefs elements", - request: &pb.GetNewLFSPointersRequest{ + request: &gitalypb.GetNewLFSPointersRequest{ Repository: testRepo, Revision: revision, NotInRefs: [][]byte{[]byte("048721d90c449b244b7b4c53a9186b04330174ec")}, }, - expectedLFSPointers: []*pb.LFSPointer{ + expectedLFSPointers: []*gitalypb.LFSPointer{ { Size: 127, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:bad71f905b60729f502ca339f7c9f001281a3d12c68a5da7f15de8009f4bd63d\nsize 18\n"), @@ -271,7 +270,7 @@ func TestSuccessfulGetNewLFSPointersRequest(t *testing.T) { stream, err := client.GetNewLFSPointers(ctx, tc.request) require.NoError(t, err) - var receivedLFSPointers []*pb.LFSPointer + var receivedLFSPointers []*gitalypb.LFSPointer for { resp, err := stream.Recv() if err == io.EOF { @@ -300,7 +299,7 @@ func TestFailedGetNewLFSPointersRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - repository *pb.Repository + repository *gitalypb.Repository revision []byte }{ { @@ -322,7 +321,7 @@ func TestFailedGetNewLFSPointersRequestDueToValidations(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - request := &pb.GetNewLFSPointersRequest{ + request := &gitalypb.GetNewLFSPointersRequest{ Repository: tc.repository, Revision: tc.revision, } @@ -340,7 +339,7 @@ func TestFailedGetNewLFSPointersRequestDueToValidations(t *testing.T) { } } -func drainNewPointers(c pb.BlobService_GetNewLFSPointersClient) error { +func drainNewPointers(c gitalypb.BlobService_GetNewLFSPointersClient) error { for { _, err := c.Recv() if err != nil { @@ -362,7 +361,7 @@ func TestSuccessfulGetAllLFSPointersRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.GetAllLFSPointersRequest{ + request := &gitalypb.GetAllLFSPointersRequest{ Repository: testRepo, Revision: []byte("54fcc214b94e78d7a41a9a8fe6d87a5e59500e51"), } @@ -370,7 +369,7 @@ func TestSuccessfulGetAllLFSPointersRequest(t *testing.T) { c, err := client.GetAllLFSPointers(ctx, request) require.NoError(t, err) - expectedLFSPointers := []*pb.LFSPointer{ + expectedLFSPointers := []*gitalypb.LFSPointer{ { Size: 133, Data: []byte("version https://git-lfs.github.com/spec/v1\noid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897\nsize 1575078\n\n"), @@ -390,8 +389,8 @@ func TestSuccessfulGetAllLFSPointersRequest(t *testing.T) { require.ElementsMatch(t, getAllPointers(t, c), expectedLFSPointers) } -func getAllPointers(t *testing.T, c pb.BlobService_GetAllLFSPointersClient) []*pb.LFSPointer { - var receivedLFSPointers []*pb.LFSPointer +func getAllPointers(t *testing.T, c gitalypb.BlobService_GetAllLFSPointersClient) []*gitalypb.LFSPointer { + var receivedLFSPointers []*gitalypb.LFSPointer for { resp, err := c.Recv() if err == io.EOF { @@ -420,7 +419,7 @@ func TestFailedGetAllLFSPointersRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - repository *pb.Repository + repository *gitalypb.Repository revision []byte }{ { @@ -442,7 +441,7 @@ func TestFailedGetAllLFSPointersRequestDueToValidations(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - request := &pb.GetAllLFSPointersRequest{ + request := &gitalypb.GetAllLFSPointersRequest{ Repository: tc.repository, Revision: tc.revision, } @@ -457,7 +456,7 @@ func TestFailedGetAllLFSPointersRequestDueToValidations(t *testing.T) { } } -func drainAllPointers(c pb.BlobService_GetAllLFSPointersClient) error { +func drainAllPointers(c gitalypb.BlobService_GetAllLFSPointersClient) error { for { _, err := c.Recv() if err != nil { diff --git a/internal/service/blob/server.go b/internal/service/blob/server.go index 3100a5fa9..52b04e3ac 100644 --- a/internal/service/blob/server.go +++ b/internal/service/blob/server.go @@ -1,9 +1,8 @@ package blob import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) type server struct { @@ -11,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a grpc BlobServer -func NewServer(rs *rubyserver.Server) pb.BlobServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.BlobServiceServer { return &server{rs} } diff --git a/internal/service/blob/testhelper_test.go b/internal/service/blob/testhelper_test.go index 26559f3ae..f566d43af 100644 --- a/internal/service/blob/testhelper_test.go +++ b/internal/service/blob/testhelper_test.go @@ -7,13 +7,12 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc" "google.golang.org/grpc/reflection" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) var rubyServer *rubyserver.Server @@ -46,7 +45,7 @@ func runBlobServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterBlobServiceServer(grpcServer, &server{rubyServer}) + gitalypb.RegisterBlobServiceServer(grpcServer, &server{rubyServer}) reflection.Register(grpcServer) go grpcServer.Serve(listener) @@ -54,7 +53,7 @@ func runBlobServer(t *testing.T) (*grpc.Server, string) { return grpcServer, serverSocketPath } -func newBlobClient(t *testing.T, serverSocketPath string) (pb.BlobServiceClient, *grpc.ClientConn) { +func newBlobClient(t *testing.T, serverSocketPath string) (gitalypb.BlobServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -66,5 +65,5 @@ func newBlobClient(t *testing.T, serverSocketPath string) (pb.BlobServiceClient, t.Fatal(err) } - return pb.NewBlobServiceClient(conn), conn + return gitalypb.NewBlobServiceClient(conn), conn } diff --git a/internal/service/commit/between.go b/internal/service/commit/between.go index 6fc186828..be761556e 100644 --- a/internal/service/commit/between.go +++ b/internal/service/commit/between.go @@ -3,17 +3,17 @@ package commit import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) type commitsBetweenSender struct { - stream pb.CommitService_CommitsBetweenServer + stream gitalypb.CommitService_CommitsBetweenServer } -func (s *server) CommitsBetween(in *pb.CommitsBetweenRequest, stream pb.CommitService_CommitsBetweenServer) error { +func (s *server) CommitsBetween(in *gitalypb.CommitsBetweenRequest, stream gitalypb.CommitService_CommitsBetweenServer) error { if err := git.ValidateRevision(in.GetFrom()); err != nil { return status.Errorf(codes.InvalidArgument, "CommitsBetween: from: %v", err) } @@ -27,6 +27,6 @@ func (s *server) CommitsBetween(in *pb.CommitsBetweenRequest, stream pb.CommitSe return sendCommits(stream.Context(), sender, in.GetRepository(), []string{revisionRange}, nil, "--reverse") } -func (sender *commitsBetweenSender) Send(commits []*pb.GitCommit) error { - return sender.stream.Send(&pb.CommitsBetweenResponse{Commits: commits}) +func (sender *commitsBetweenSender) Send(commits []*gitalypb.GitCommit) error { + return sender.stream.Send(&gitalypb.CommitsBetweenResponse{Commits: commits}) } diff --git a/internal/service/commit/between_test.go b/internal/service/commit/between_test.go index 8ebe09b4d..b5d3f18f2 100644 --- a/internal/service/commit/between_test.go +++ b/internal/service/commit/between_test.go @@ -7,7 +7,7 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -27,17 +27,17 @@ func TestSuccessfulCommitsBetween(t *testing.T) { to := []byte("ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69") // spooky-stuff fakeHash := []byte("f63f41fe459e62e1228fcef60d7189127aeba95a") fakeRef := []byte("non-existing-ref") - expectedCommits := []*pb.GitCommit{ + expectedCommits := []*gitalypb.GitCommit{ { Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -52,12 +52,12 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Id: "4a24d82dbca5c11c61556f3b35ca472b7463187e", Subject: []byte("Update README.md to include `Usage in testing and development`"), Body: []byte("Update README.md to include `Usage in testing and development`"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Luke \"Jared\" Bennett"), Email: []byte("lbennett@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1491905339}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Luke \"Jared\" Bennett"), Email: []byte("lbennett@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1491905339}, @@ -69,12 +69,12 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Id: "e63f41fe459e62e1228fcef60d7189127aeba95a", Subject: []byte("Merge branch 'gitlab-test-usage-dev-testing-docs' into 'master'"), Body: []byte("Merge branch 'gitlab-test-usage-dev-testing-docs' into 'master'\r\n\r\nUpdate README.md to include `Usage in testing and development`\r\n\r\nSee merge request !21"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Sean McGivern"), Email: []byte("sean@mcgivern.me.uk"), Date: ×tamp.Timestamp{Seconds: 1491906794}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Sean McGivern"), Email: []byte("sean@mcgivern.me.uk"), Date: ×tamp.Timestamp{Seconds: 1491906794}, @@ -89,13 +89,13 @@ func TestSuccessfulCommitsBetween(t *testing.T) { Id: "ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69", Subject: []byte("Weird commit date"), Body: []byte("Weird commit date\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Alejandro Rodríguez"), Email: []byte("alejorro70@gmail.com"), // Not the actual commit date, but the biggest we can represent Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Alejandro Rodríguez"), Email: []byte("alejorro70@gmail.com"), Date: ×tamp.Timestamp{Seconds: 9223371974719179007}, @@ -108,7 +108,7 @@ func TestSuccessfulCommitsBetween(t *testing.T) { description string from []byte to []byte - expectedCommits []*pb.GitCommit + expectedCommits []*gitalypb.GitCommit }{ { description: "From hash to hash", @@ -138,31 +138,31 @@ func TestSuccessfulCommitsBetween(t *testing.T) { description: "To hash doesn't exist", from: from, to: fakeHash, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, { description: "From hash doesn't exist", from: fakeHash, to: to, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, { description: "To ref doesn't exist", from: from, to: fakeRef, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, { description: "From ref doesn't exist", from: fakeRef, to: to, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, } for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - commits := []*pb.GitCommit{} - rpcRequest := pb.CommitsBetweenRequest{ + commits := []*gitalypb.GitCommit{} + rpcRequest := gitalypb.CommitsBetweenRequest{ Repository: testRepo, From: tc.from, To: tc.to, } @@ -200,13 +200,13 @@ func TestFailedCommitsBetweenRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} from := []byte("498214de67004b1da3d820901307bed2a68a8ef6") to := []byte("e63f41fe459e62e1228fcef60d7189127aeba95a") testCases := []struct { description string - repository *pb.Repository + repository *gitalypb.Repository from []byte to []byte code codes.Code @@ -255,7 +255,7 @@ func TestFailedCommitsBetweenRequest(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - rpcRequest := pb.CommitsBetweenRequest{ + rpcRequest := gitalypb.CommitsBetweenRequest{ Repository: tc.repository, From: tc.from, To: tc.to, } @@ -272,7 +272,7 @@ func TestFailedCommitsBetweenRequest(t *testing.T) { } } -func drainCommitsBetweenResponse(c pb.CommitService_CommitsBetweenClient) error { +func drainCommitsBetweenResponse(c gitalypb.CommitService_CommitsBetweenClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/commit_messages.go b/internal/service/commit/commit_messages.go index 63dc6fe19..167fac4bd 100644 --- a/internal/service/commit/commit_messages.go +++ b/internal/service/commit/commit_messages.go @@ -3,15 +3,14 @@ package commit import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) GetCommitMessages(request *pb.GetCommitMessagesRequest, stream pb.CommitService_GetCommitMessagesServer) error { +func (s *server) GetCommitMessages(request *gitalypb.GetCommitMessagesRequest, stream gitalypb.CommitService_GetCommitMessagesServer) error { if err := validateGetCommitMessagesRequest(request); err != nil { return status.Errorf(codes.InvalidArgument, "GetCommitMessages: %v", err) } @@ -44,7 +43,7 @@ func (s *server) GetCommitMessages(request *pb.GetCommitMessagesRequest, stream }) } -func validateGetCommitMessagesRequest(request *pb.GetCommitMessagesRequest) error { +func validateGetCommitMessagesRequest(request *gitalypb.GetCommitMessagesRequest) error { if request.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/commit/commit_messages_test.go b/internal/service/commit/commit_messages_test.go index a9ce8b4b1..a21060fd9 100644 --- a/internal/service/commit/commit_messages_test.go +++ b/internal/service/commit/commit_messages_test.go @@ -5,11 +5,10 @@ import ( "strings" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -33,7 +32,7 @@ func TestSuccessfulGetCommitMessagesRequest(t *testing.T) { commit1ID := testhelper.CreateCommit(t, testRepoPath, "local-big-commits", &testhelper.CreateCommitOpts{Message: message1}) commit2ID := testhelper.CreateCommit(t, testRepoPath, "local-big-commits", &testhelper.CreateCommitOpts{Message: message2, ParentID: commit1ID}) - request := &pb.GetCommitMessagesRequest{ + request := &gitalypb.GetCommitMessagesRequest{ Repository: testRepo, CommitIds: []string{commit1ID, commit2ID}, } @@ -41,7 +40,7 @@ func TestSuccessfulGetCommitMessagesRequest(t *testing.T) { c, err := client.GetCommitMessages(ctx, request) require.NoError(t, err) - expectedMessages := []*pb.GetCommitMessagesResponse{ + expectedMessages := []*gitalypb.GetCommitMessagesResponse{ { CommitId: commit1ID, Message: []byte(message1), @@ -65,12 +64,12 @@ func TestFailedGetCommitMessagesRequest(t *testing.T) { testCases := []struct { desc string - request *pb.GetCommitMessagesRequest + request *gitalypb.GetCommitMessagesRequest code codes.Code }{ { desc: "empty Repository", - request: &pb.GetCommitMessagesRequest{ + request: &gitalypb.GetCommitMessagesRequest{ Repository: nil, CommitIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e"}, }, @@ -98,7 +97,7 @@ func TestFailedGetCommitMessagesRequest(t *testing.T) { } } -func readAllMessagesFromClient(t *testing.T, c pb.CommitService_GetCommitMessagesClient) (messages []*pb.GetCommitMessagesResponse) { +func readAllMessagesFromClient(t *testing.T, c gitalypb.CommitService_GetCommitMessagesClient) (messages []*gitalypb.GetCommitMessagesResponse) { for { resp, err := c.Recv() if err == io.EOF { diff --git a/internal/service/commit/commit_signatures.go b/internal/service/commit/commit_signatures.go index 0be45f5ba..a24a5e436 100644 --- a/internal/service/commit/commit_signatures.go +++ b/internal/service/commit/commit_signatures.go @@ -3,15 +3,14 @@ package commit import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) GetCommitSignatures(request *pb.GetCommitSignaturesRequest, stream pb.CommitService_GetCommitSignaturesServer) error { +func (s *server) GetCommitSignatures(request *gitalypb.GetCommitSignaturesRequest, stream gitalypb.CommitService_GetCommitSignaturesServer) error { if err := validateGetCommitSignaturesRequest(request); err != nil { return status.Errorf(codes.InvalidArgument, "GetCommitSignatures: %v", err) } @@ -44,7 +43,7 @@ func (s *server) GetCommitSignatures(request *pb.GetCommitSignaturesRequest, str }) } -func validateGetCommitSignaturesRequest(request *pb.GetCommitSignaturesRequest) error { +func validateGetCommitSignaturesRequest(request *gitalypb.GetCommitSignaturesRequest) error { if request.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/commit/commit_signatures_test.go b/internal/service/commit/commit_signatures_test.go index 026bbd3b6..60a36b1af 100644 --- a/internal/service/commit/commit_signatures_test.go +++ b/internal/service/commit/commit_signatures_test.go @@ -4,10 +4,9 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -25,7 +24,7 @@ func TestSuccessfulGetCommitSignaturesRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.GetCommitSignaturesRequest{ + request := &gitalypb.GetCommitSignaturesRequest{ Repository: testRepo, CommitIds: []string{ "5937ac0a7beb003549fc5fd26fc247adbce4a52e", // has signature @@ -38,7 +37,7 @@ func TestSuccessfulGetCommitSignaturesRequest(t *testing.T) { c, err := client.GetCommitSignatures(ctx, request) require.NoError(t, err) - expectedSignautes := []*pb.GetCommitSignaturesResponse{ + expectedSignautes := []*gitalypb.GetCommitSignaturesResponse{ { CommitId: "5937ac0a7beb003549fc5fd26fc247adbce4a52e", Signature: testhelper.MustReadFile(t, "testdata/commit-5937ac0a7beb003549fc5fd26fc247adbce4a52e-signature"), @@ -67,12 +66,12 @@ func TestFailedGetCommitSignaturesRequest(t *testing.T) { testCases := []struct { desc string - request *pb.GetCommitSignaturesRequest + request *gitalypb.GetCommitSignaturesRequest code codes.Code }{ { desc: "empty Repository", - request: &pb.GetCommitSignaturesRequest{ + request: &gitalypb.GetCommitSignaturesRequest{ Repository: nil, CommitIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e"}, }, @@ -80,7 +79,7 @@ func TestFailedGetCommitSignaturesRequest(t *testing.T) { }, { desc: "empty CommitIds", - request: &pb.GetCommitSignaturesRequest{ + request: &gitalypb.GetCommitSignaturesRequest{ Repository: testRepo, CommitIds: []string{}, }, @@ -108,7 +107,7 @@ func TestFailedGetCommitSignaturesRequest(t *testing.T) { } } -func readAllSignaturesFromClient(t *testing.T, c pb.CommitService_GetCommitSignaturesClient) (signatures []*pb.GetCommitSignaturesResponse) { +func readAllSignaturesFromClient(t *testing.T, c gitalypb.CommitService_GetCommitSignaturesClient) (signatures []*gitalypb.GetCommitSignaturesResponse) { for { resp, err := c.Recv() if err == io.EOF { diff --git a/internal/service/commit/commits_by_message.go b/internal/service/commit/commits_by_message.go index 2c7e1fc63..a1a06fbdb 100644 --- a/internal/service/commit/commits_by_message.go +++ b/internal/service/commit/commits_by_message.go @@ -3,17 +3,16 @@ package commit import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) type commitsByMessageSender struct { - stream pb.CommitService_CommitsByMessageServer + stream gitalypb.CommitService_CommitsByMessageServer } -func (s *server) CommitsByMessage(in *pb.CommitsByMessageRequest, stream pb.CommitService_CommitsByMessageServer) error { +func (s *server) CommitsByMessage(in *gitalypb.CommitsByMessageRequest, stream gitalypb.CommitService_CommitsByMessageServer) error { if err := validateCommitsByMessageRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "CommitsByMessage: %v", err) } @@ -53,7 +52,7 @@ func (s *server) CommitsByMessage(in *pb.CommitsByMessageRequest, stream pb.Comm return sendCommits(stream.Context(), sender, in.GetRepository(), []string{string(revision)}, paths, gitLogExtraOptions...) } -func validateCommitsByMessageRequest(in *pb.CommitsByMessageRequest) error { +func validateCommitsByMessageRequest(in *gitalypb.CommitsByMessageRequest) error { if in.GetQuery() == "" { return fmt.Errorf("empty Query") } @@ -61,6 +60,6 @@ func validateCommitsByMessageRequest(in *pb.CommitsByMessageRequest) error { return nil } -func (sender *commitsByMessageSender) Send(commits []*pb.GitCommit) error { - return sender.stream.Send(&pb.CommitsByMessageResponse{Commits: commits}) +func (sender *commitsByMessageSender) Send(commits []*gitalypb.GitCommit) error { + return sender.stream.Send(&gitalypb.CommitsByMessageResponse{Commits: commits}) } diff --git a/internal/service/commit/commits_by_message_test.go b/internal/service/commit/commits_by_message_test.go index 5f62a6cec..ba4cd69a3 100644 --- a/internal/service/commit/commits_by_message_test.go +++ b/internal/service/commit/commits_by_message_test.go @@ -4,10 +4,9 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" "golang.org/x/net/context" @@ -24,7 +23,7 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - commits := []*pb.GitCommit{ + commits := []*gitalypb.GitCommit{ { Id: "bf6e164cac2dc32b1f391ca4290badcbe4ffc5fb", Subject: []byte("Commit #10"), @@ -47,12 +46,12 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { testCases := []struct { desc string - request *pb.CommitsByMessageRequest - expectedCommits []*pb.GitCommit + request *gitalypb.CommitsByMessageRequest + expectedCommits []*gitalypb.GitCommit }{ { desc: "revision + query", - request: &pb.CommitsByMessageRequest{ + request: &gitalypb.CommitsByMessageRequest{ Revision: []byte("few-commits"), Query: "commit #1", }, @@ -60,7 +59,7 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { }, { desc: "revision + query + limit", - request: &pb.CommitsByMessageRequest{ + request: &gitalypb.CommitsByMessageRequest{ Revision: []byte("few-commits"), Query: "commit #1", Limit: 1, @@ -69,7 +68,7 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { }, { desc: "revision + query + offset", - request: &pb.CommitsByMessageRequest{ + request: &gitalypb.CommitsByMessageRequest{ Revision: []byte("few-commits"), Query: "commit #1", Offset: 1, @@ -78,21 +77,21 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { }, { desc: "query + empty revision + path", - request: &pb.CommitsByMessageRequest{ + request: &gitalypb.CommitsByMessageRequest{ Query: "much more", Path: []byte("files/ruby"), }, - expectedCommits: []*pb.GitCommit{ + expectedCommits: []*gitalypb.GitCommit{ { Id: "913c66a37b4a45b9769037c55c2d238bd0942d2e", Subject: []byte("Files, encoding and much more"), Body: []byte("Files, encoding and much more\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488896}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488896}, @@ -104,19 +103,19 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { }, { desc: "query + empty revision + path not in the commits", - request: &pb.CommitsByMessageRequest{ + request: &gitalypb.CommitsByMessageRequest{ Query: "much more", Path: []byte("bar"), }, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, { desc: "query + bad revision", - request: &pb.CommitsByMessageRequest{ + request: &gitalypb.CommitsByMessageRequest{ Revision: []byte("maaaaasterrrrr"), Query: "much more", }, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, } @@ -133,7 +132,7 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) { t.Fatal(err) } - receivedCommits := []*pb.GitCommit{} + receivedCommits := []*gitalypb.GitCommit{} for { resp, err := c.Recv() if err == io.EOF { @@ -164,26 +163,26 @@ func TestFailedCommitsByMessageRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { desc string - request *pb.CommitsByMessageRequest + request *gitalypb.CommitsByMessageRequest code codes.Code }{ { desc: "Invalid repository", - request: &pb.CommitsByMessageRequest{Repository: invalidRepo, Query: "foo"}, + request: &gitalypb.CommitsByMessageRequest{Repository: invalidRepo, Query: "foo"}, code: codes.InvalidArgument, }, { desc: "Repository is nil", - request: &pb.CommitsByMessageRequest{Query: "foo"}, + request: &gitalypb.CommitsByMessageRequest{Query: "foo"}, code: codes.InvalidArgument, }, { desc: "Query is missing", - request: &pb.CommitsByMessageRequest{Repository: testRepo}, + request: &gitalypb.CommitsByMessageRequest{Repository: testRepo}, code: codes.InvalidArgument, }, } @@ -203,7 +202,7 @@ func TestFailedCommitsByMessageRequest(t *testing.T) { } } -func drainCommitsByMessageResponse(c pb.CommitService_CommitsByMessageClient) error { +func drainCommitsByMessageResponse(c gitalypb.CommitService_CommitsByMessageClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/commits_helper.go b/internal/service/commit/commits_helper.go index ae1f0071f..5f2c2572f 100644 --- a/internal/service/commit/commits_helper.go +++ b/internal/service/commit/commits_helper.go @@ -3,20 +3,19 @@ package commit import ( "context" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" ) type commitsSender interface { - Send([]*pb.GitCommit) error + Send([]*gitalypb.GitCommit) error } const commitsPerChunk = 20 -func sendCommits(ctx context.Context, sender commitsSender, repo *pb.Repository, revisionRange []string, paths []string, extraArgs ...string) error { +func sendCommits(ctx context.Context, sender commitsSender, repo *gitalypb.Repository, revisionRange []string, paths []string, extraArgs ...string) error { cmd, err := log.GitLogCommand(ctx, repo, revisionRange, paths, extraArgs...) if err != nil { return err @@ -27,7 +26,7 @@ func sendCommits(ctx context.Context, sender commitsSender, repo *pb.Repository, return err } - var commits []*pb.GitCommit + var commits []*gitalypb.GitCommit for logParser.Parse() { commit := logParser.Commit() diff --git a/internal/service/commit/count_commits.go b/internal/service/commit/count_commits.go index 0abf85522..9ab4858c4 100644 --- a/internal/service/commit/count_commits.go +++ b/internal/service/commit/count_commits.go @@ -7,17 +7,16 @@ import ( "strconv" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) CountCommits(ctx context.Context, in *pb.CountCommitsRequest) (*pb.CountCommitsResponse, error) { +func (s *server) CountCommits(ctx context.Context, in *gitalypb.CountCommitsRequest) (*gitalypb.CountCommitsResponse, error) { if err := validateCountCommitsRequest(in); err != nil { return nil, status.Errorf(codes.InvalidArgument, "CountCommits: %v", err) } @@ -70,10 +69,10 @@ func (s *server) CountCommits(ctx context.Context, in *pb.CountCommitsRequest) ( } } - return &pb.CountCommitsResponse{Count: int32(count)}, nil + return &gitalypb.CountCommitsResponse{Count: int32(count)}, nil } -func validateCountCommitsRequest(in *pb.CountCommitsRequest) error { +func validateCountCommitsRequest(in *gitalypb.CountCommitsRequest) error { if len(in.GetRevision()) == 0 && !in.GetAll() { return fmt.Errorf("empty Revision and false All") } diff --git a/internal/service/commit/count_commits_test.go b/internal/service/commit/count_commits_test.go index 33ae04c22..cdb86eb7a 100644 --- a/internal/service/commit/count_commits_test.go +++ b/internal/service/commit/count_commits_test.go @@ -5,10 +5,9 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" "golang.org/x/net/context" @@ -48,7 +47,7 @@ func TestSuccessfulCountCommitsRequest(t *testing.T) { } testCases := []struct { - repo *pb.Repository + repo *gitalypb.Repository revision, path []byte all bool before, after, desc string @@ -121,7 +120,7 @@ func TestSuccessfulCountCommitsRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.CountCommitsRequest{Repository: testCase.repo} + request := &gitalypb.CountCommitsRequest{Repository: testCase.repo} if testCase.all { request.All = true @@ -177,10 +176,10 @@ func TestFailedCountCommitsRequestDueToValidationError(t *testing.T) { revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") - rpcRequests := []pb.CountCommitsRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision}, // Repository doesn't exist - {Repository: nil, Revision: revision}, // Repository is nil - {Repository: testRepo, Revision: nil, All: false}, // Revision is empty and All is false + rpcRequests := []gitalypb.CountCommitsRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision}, // Repository doesn't exist + {Repository: nil, Revision: revision}, // Repository is nil + {Repository: testRepo, Revision: nil, All: false}, // Revision is empty and All is false } for _, rpcRequest := range rpcRequests { diff --git a/internal/service/commit/extractsignature.go b/internal/service/commit/extractsignature.go index 44273a4db..572331f1a 100644 --- a/internal/service/commit/extractsignature.go +++ b/internal/service/commit/extractsignature.go @@ -1,11 +1,11 @@ package commit import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) -func (s *server) ExtractCommitSignature(request *pb.ExtractCommitSignatureRequest, stream pb.CommitService_ExtractCommitSignatureServer) error { +func (s *server) ExtractCommitSignature(request *gitalypb.ExtractCommitSignatureRequest, stream gitalypb.CommitService_ExtractCommitSignatureServer) error { ctx := stream.Context() client, err := s.CommitServiceClient(ctx) diff --git a/internal/service/commit/extractsignature_test.go b/internal/service/commit/extractsignature_test.go index 81b464456..786fde75f 100644 --- a/internal/service/commit/extractsignature_test.go +++ b/internal/service/commit/extractsignature_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -33,13 +33,13 @@ func TestExtractCommitSignatureSuccess(t *testing.T) { testCases := []struct { desc string - req *pb.ExtractCommitSignatureRequest + req *gitalypb.ExtractCommitSignatureRequest signature []byte signedText []byte }{ { desc: "commit with signature", - req: &pb.ExtractCommitSignatureRequest{ + req: &gitalypb.ExtractCommitSignatureRequest{ Repository: testRepo, CommitId: "5937ac0a7beb003549fc5fd26fc247adbce4a52e", }, @@ -48,7 +48,7 @@ func TestExtractCommitSignatureSuccess(t *testing.T) { }, { desc: "commit without signature", - req: &pb.ExtractCommitSignatureRequest{ + req: &gitalypb.ExtractCommitSignatureRequest{ Repository: testRepo, CommitId: "e63f41fe459e62e1228fcef60d7189127aeba95a", }, @@ -68,14 +68,14 @@ func TestExtractCommitSignatureSuccess(t *testing.T) { } } -func getSignatureAndText(ctx context.Context, client pb.CommitServiceClient, req *pb.ExtractCommitSignatureRequest) ([]byte, []byte, error) { +func getSignatureAndText(ctx context.Context, client gitalypb.CommitServiceClient, req *gitalypb.ExtractCommitSignatureRequest) ([]byte, []byte, error) { stream, err := client.ExtractCommitSignature(ctx, req) if err != nil { return nil, nil, err } var signature, signedText []byte - var resp *pb.ExtractCommitSignatureResponse + var resp *gitalypb.ExtractCommitSignatureResponse for err == nil { resp, err = stream.Recv() if err != nil && err != io.EOF { @@ -104,12 +104,12 @@ func TestExtractCommitSignatureFail(t *testing.T) { testCases := []struct { desc string - req *pb.ExtractCommitSignatureRequest + req *gitalypb.ExtractCommitSignatureRequest code codes.Code }{ { desc: "truncated commit ID", - req: &pb.ExtractCommitSignatureRequest{ + req: &gitalypb.ExtractCommitSignatureRequest{ Repository: testRepo, CommitId: "5937ac0a7beb003549fc5fd26", }, @@ -117,7 +117,7 @@ func TestExtractCommitSignatureFail(t *testing.T) { }, { desc: "empty commit ID", - req: &pb.ExtractCommitSignatureRequest{ + req: &gitalypb.ExtractCommitSignatureRequest{ Repository: testRepo, CommitId: "", }, @@ -125,7 +125,7 @@ func TestExtractCommitSignatureFail(t *testing.T) { }, { desc: "empty repo field", - req: &pb.ExtractCommitSignatureRequest{ + req: &gitalypb.ExtractCommitSignatureRequest{ Repository: nil, CommitId: "e63f41fe459e62e1228fcef60d7189127aeba95a", }, @@ -133,7 +133,7 @@ func TestExtractCommitSignatureFail(t *testing.T) { }, { desc: "commit ID unknown", - req: &pb.ExtractCommitSignatureRequest{ + req: &gitalypb.ExtractCommitSignatureRequest{ Repository: testRepo, CommitId: "0000000000000000000000000000000000000000", }, @@ -146,7 +146,7 @@ func TestExtractCommitSignatureFail(t *testing.T) { stream, err := client.ExtractCommitSignature(ctx, tc.req) require.NoError(t, err) - var resp *pb.ExtractCommitSignatureResponse + var resp *gitalypb.ExtractCommitSignatureResponse for err == nil { resp, err = stream.Recv() if resp != nil { diff --git a/internal/service/commit/filter_shas_with_signatures.go b/internal/service/commit/filter_shas_with_signatures.go index c64453fa5..6e879169b 100644 --- a/internal/service/commit/filter_shas_with_signatures.go +++ b/internal/service/commit/filter_shas_with_signatures.go @@ -1,13 +1,13 @@ package commit import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) FilterShasWithSignatures(bidi pb.CommitService_FilterShasWithSignaturesServer) error { +func (s *server) FilterShasWithSignatures(bidi gitalypb.CommitService_FilterShasWithSignaturesServer) error { firstRequest, err := bidi.Recv() if err != nil { return err @@ -58,7 +58,7 @@ func (s *server) FilterShasWithSignatures(bidi pb.CommitService_FilterShasWithSi ) } -func verifyFirstFilterShasWithSignaturesRequest(in *pb.FilterShasWithSignaturesRequest) error { +func verifyFirstFilterShasWithSignaturesRequest(in *gitalypb.FilterShasWithSignaturesRequest) error { if in.Repository == nil { return status.Errorf(codes.InvalidArgument, "no repository given") } diff --git a/internal/service/commit/filter_shas_with_signatures_test.go b/internal/service/commit/filter_shas_with_signatures_test.go index 0b3bfbd45..d3045f1a5 100644 --- a/internal/service/commit/filter_shas_with_signatures_test.go +++ b/internal/service/commit/filter_shas_with_signatures_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -56,7 +56,7 @@ func TestFilterShasWithSignaturesSuccessful(t *testing.T) { t.Run(testCase.desc, func(t *testing.T) { stream, err := client.FilterShasWithSignatures(ctx) require.NoError(t, err) - require.NoError(t, stream.Send(&pb.FilterShasWithSignaturesRequest{Repository: testRepo, Shas: testCase.in})) + require.NoError(t, stream.Send(&gitalypb.FilterShasWithSignaturesRequest{Repository: testRepo, Shas: testCase.in})) require.NoError(t, stream.CloseSend()) recvOut, err := recvFSWS(stream) require.NoError(t, err) @@ -78,7 +78,7 @@ func TestFilterShasWithSignaturesValidationError(t *testing.T) { stream, err := client.FilterShasWithSignatures(ctx) require.NoError(t, err) - require.NoError(t, stream.Send(&pb.FilterShasWithSignaturesRequest{})) + require.NoError(t, stream.Send(&gitalypb.FilterShasWithSignaturesRequest{})) require.NoError(t, stream.CloseSend()) _, err = recvFSWS(stream) @@ -86,7 +86,7 @@ func TestFilterShasWithSignaturesValidationError(t *testing.T) { require.Contains(t, err.Error(), "no repository given") } -func recvFSWS(stream pb.CommitService_FilterShasWithSignaturesClient) ([][]byte, error) { +func recvFSWS(stream gitalypb.CommitService_FilterShasWithSignaturesClient) ([][]byte, error) { var ret [][]byte resp, err := stream.Recv() for ; err == nil; resp, err = stream.Recv() { diff --git a/internal/service/commit/find_all_commits.go b/internal/service/commit/find_all_commits.go index 4197f8992..9453f98a0 100644 --- a/internal/service/commit/find_all_commits.go +++ b/internal/service/commit/find_all_commits.go @@ -3,10 +3,9 @@ package commit import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/service/ref" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -15,10 +14,10 @@ import ( var _findBranchNamesFunc = ref.FindBranchNames type findAllCommitsSender struct { - stream pb.CommitService_FindAllCommitsServer + stream gitalypb.CommitService_FindAllCommitsServer } -func (s *server) FindAllCommits(in *pb.FindAllCommitsRequest, stream pb.CommitService_FindAllCommitsServer) error { +func (s *server) FindAllCommits(in *gitalypb.FindAllCommitsRequest, stream gitalypb.CommitService_FindAllCommitsServer) error { sender := &findAllCommitsSender{stream} var gitLogExtraOptions []string @@ -29,11 +28,11 @@ func (s *server) FindAllCommits(in *pb.FindAllCommitsRequest, stream pb.CommitSe gitLogExtraOptions = append(gitLogExtraOptions, fmt.Sprintf("--skip=%d", skip)) } switch in.GetOrder() { - case pb.FindAllCommitsRequest_NONE: + case gitalypb.FindAllCommitsRequest_NONE: // Do nothing - case pb.FindAllCommitsRequest_DATE: + case gitalypb.FindAllCommitsRequest_DATE: gitLogExtraOptions = append(gitLogExtraOptions, "--date-order") - case pb.FindAllCommitsRequest_TOPO: + case gitalypb.FindAllCommitsRequest_TOPO: gitLogExtraOptions = append(gitLogExtraOptions, "--topo-order") } @@ -54,6 +53,6 @@ func (s *server) FindAllCommits(in *pb.FindAllCommitsRequest, stream pb.CommitSe return sendCommits(stream.Context(), sender, in.GetRepository(), revisions, nil, gitLogExtraOptions...) } -func (sender *findAllCommitsSender) Send(commits []*pb.GitCommit) error { - return sender.stream.Send(&pb.FindAllCommitsResponse{Commits: commits}) +func (sender *findAllCommitsSender) Send(commits []*gitalypb.GitCommit) error { + return sender.stream.Send(&gitalypb.FindAllCommitsResponse{Commits: commits}) } diff --git a/internal/service/commit/find_all_commits_test.go b/internal/service/commit/find_all_commits_test.go index 24a255cea..1cb65ded6 100644 --- a/internal/service/commit/find_all_commits_test.go +++ b/internal/service/commit/find_all_commits_test.go @@ -4,11 +4,10 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/service/ref" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" "golang.org/x/net/context" @@ -20,7 +19,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { _findBranchNamesFunc = ref.FindBranchNames }() - _findBranchNamesFunc = func(ctx context.Context, repo *pb.Repository) ([][]byte, error) { + _findBranchNamesFunc = func(ctx context.Context, repo *gitalypb.Repository) ([][]byte, error) { return [][]byte{ []byte("few-commits"), []byte("two-commits"), @@ -38,7 +37,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { // Commits made on another branch in parallel to the normal commits below. // Will be used to test topology ordering. - alternateCommits := []*pb.GitCommit{ + alternateCommits := []*gitalypb.GitCommit{ { Id: "0031876facac3f2b2702a0e53a26e89939a42209", Subject: []byte("Merge branch 'few-commits-4' into few-commits-2"), @@ -72,7 +71,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { } // Nothing special about these commits. - normalCommits := []*pb.GitCommit{ + normalCommits := []*gitalypb.GitCommit{ { Id: "bf6e164cac2dc32b1f391ca4290badcbe4ffc5fb", Subject: []byte("Commit #10"), @@ -160,12 +159,12 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { Id: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863", Subject: []byte("Initial commit"), Body: []byte("Initial commit\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488198}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488198}, @@ -176,7 +175,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { } // A commit that exists on "two-commits" branch. - singleCommit := []*pb.GitCommit{ + singleCommit := []*gitalypb.GitCommit{ { Id: "304d257dcb821665ab5110318fc58a007bd104ed", Subject: []byte("Commit #11"), @@ -188,7 +187,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { }, } - timeOrderedCommits := []*pb.GitCommit{ + timeOrderedCommits := []*gitalypb.GitCommit{ alternateCommits[0], normalCommits[0], alternateCommits[1], normalCommits[1], alternateCommits[2], @@ -198,19 +197,19 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { testCases := []struct { desc string - request *pb.FindAllCommitsRequest - expectedCommits []*pb.GitCommit + request *gitalypb.FindAllCommitsRequest + expectedCommits []*gitalypb.GitCommit }{ { desc: "all commits of a revision", - request: &pb.FindAllCommitsRequest{ + request: &gitalypb.FindAllCommitsRequest{ Revision: []byte("few-commits"), }, expectedCommits: timeOrderedCommits, }, { desc: "maximum number of commits of a revision", - request: &pb.FindAllCommitsRequest{ + request: &gitalypb.FindAllCommitsRequest{ MaxCount: 5, Revision: []byte("few-commits"), }, @@ -218,7 +217,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { }, { desc: "skipping number of commits of a revision", - request: &pb.FindAllCommitsRequest{ + request: &gitalypb.FindAllCommitsRequest{ Skip: 5, Revision: []byte("few-commits"), }, @@ -226,7 +225,7 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { }, { desc: "maximum number of commits of a revision plus skipping", - request: &pb.FindAllCommitsRequest{ + request: &gitalypb.FindAllCommitsRequest{ Skip: 5, MaxCount: 2, Revision: []byte("few-commits"), @@ -235,29 +234,29 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) { }, { desc: "all commits of a revision ordered by date", - request: &pb.FindAllCommitsRequest{ + request: &gitalypb.FindAllCommitsRequest{ Revision: []byte("few-commits"), - Order: pb.FindAllCommitsRequest_DATE, + Order: gitalypb.FindAllCommitsRequest_DATE, }, expectedCommits: timeOrderedCommits, }, { desc: "all commits of a revision ordered by topology", - request: &pb.FindAllCommitsRequest{ + request: &gitalypb.FindAllCommitsRequest{ Revision: []byte("few-commits"), - Order: pb.FindAllCommitsRequest_TOPO, + Order: gitalypb.FindAllCommitsRequest_TOPO, }, expectedCommits: topoOrderedCommits, }, { desc: "all commits of all branches", - request: &pb.FindAllCommitsRequest{}, + request: &gitalypb.FindAllCommitsRequest{}, expectedCommits: append(singleCommit, timeOrderedCommits...), }, { desc: "non-existing revision", - request: &pb.FindAllCommitsRequest{Revision: []byte("i-do-not-exist")}, - expectedCommits: []*pb.GitCommit{}, + request: &gitalypb.FindAllCommitsRequest{Revision: []byte("i-do-not-exist")}, + expectedCommits: []*gitalypb.GitCommit{}, }, } @@ -292,21 +291,21 @@ func TestFailedFindAllCommitsRequest(t *testing.T) { client, conn := newCommitServiceClient(t, serverSocketPath) defer conn.Close() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { desc string - request *pb.FindAllCommitsRequest + request *gitalypb.FindAllCommitsRequest code codes.Code }{ { desc: "Invalid repository", - request: &pb.FindAllCommitsRequest{Repository: invalidRepo}, + request: &gitalypb.FindAllCommitsRequest{Repository: invalidRepo}, code: codes.InvalidArgument, }, { desc: "Repository is nil", - request: &pb.FindAllCommitsRequest{}, + request: &gitalypb.FindAllCommitsRequest{}, code: codes.InvalidArgument, }, } @@ -327,8 +326,8 @@ func TestFailedFindAllCommitsRequest(t *testing.T) { } } -func collectCommtsFromFindAllCommitsClient(t *testing.T, c pb.CommitService_FindAllCommitsClient) []*pb.GitCommit { - receivedCommits := []*pb.GitCommit{} +func collectCommtsFromFindAllCommitsClient(t *testing.T, c gitalypb.CommitService_FindAllCommitsClient) []*gitalypb.GitCommit { + receivedCommits := []*gitalypb.GitCommit{} for { resp, err := c.Recv() @@ -344,7 +343,7 @@ func collectCommtsFromFindAllCommitsClient(t *testing.T, c pb.CommitService_Find return receivedCommits } -func drainFindAllCommitsResponse(c pb.CommitService_FindAllCommitsClient) error { +func drainFindAllCommitsResponse(c gitalypb.CommitService_FindAllCommitsClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/find_commit.go b/internal/service/commit/find_commit.go index 2a967d2ba..f44c4b6e7 100644 --- a/internal/service/commit/find_commit.go +++ b/internal/service/commit/find_commit.go @@ -1,8 +1,7 @@ package commit import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/log" @@ -11,7 +10,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) FindCommit(ctx context.Context, in *pb.FindCommitRequest) (*pb.FindCommitResponse, error) { +func (s *server) FindCommit(ctx context.Context, in *gitalypb.FindCommitRequest) (*gitalypb.FindCommitResponse, error) { revision := in.GetRevision() if err := git.ValidateRevision(revision); err != nil { return nil, status.Errorf(codes.InvalidArgument, "FindCommit: revision: %v", err) @@ -20,5 +19,5 @@ func (s *server) FindCommit(ctx context.Context, in *pb.FindCommitRequest) (*pb. repo := in.GetRepository() commit, err := log.GetCommit(ctx, repo, string(revision)) - return &pb.FindCommitResponse{Commit: commit}, err + return &gitalypb.FindCommitResponse{Commit: commit}, err } diff --git a/internal/service/commit/find_commit_test.go b/internal/service/commit/find_commit_test.go index 511b9c69c..f55ab7ed9 100644 --- a/internal/service/commit/find_commit_test.go +++ b/internal/service/commit/find_commit_test.go @@ -7,7 +7,7 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/featureflag" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -45,21 +45,21 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { testCases := []struct { description string revision string - commit *pb.GitCommit + commit *gitalypb.GitCommit }{ { description: "With a branch name", revision: "branch-merged", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "498214de67004b1da3d820901307bed2a68a8ef6", Subject: []byte("adds bar folder and branch-test text file to check Repository merged_to_root_ref method"), Body: []byte("adds bar folder and branch-test text file to check Repository merged_to_root_ref method\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("tiagonbotelho"), Email: []byte("tiagonbotelho@hotmail.com"), Date: ×tamp.Timestamp{Seconds: 1474470806}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("tiagonbotelho"), Email: []byte("tiagonbotelho@hotmail.com"), Date: ×tamp.Timestamp{Seconds: 1474470806}, @@ -71,16 +71,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "With a tag name", revision: "v1.0.0", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9", Subject: []byte("More submodules"), Body: []byte("More submodules\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491261}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491261}, @@ -92,16 +92,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "With a hash", revision: "b83d6e391c22777fca1ed3012fce84f633d7fed0", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -116,16 +116,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "With an initial commit", revision: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863", Subject: []byte("Initial commit"), Body: []byte("Initial commit\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488198}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488198}, @@ -137,16 +137,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "with non-utf8 message encoding, recognized by Git", revision: "c809470461118b7bcab850f6e9a7ca97ac42f8ea", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "c809470461118b7bcab850f6e9a7ca97ac42f8ea", Subject: windows1251Message[:len(windows1251Message)-1], Body: windows1251Message, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1512132977}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1512132977}, @@ -158,16 +158,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "with non-utf8 garbage message encoding, not recognized by Git", revision: "0999bb770f8dc92ab5581cc0b474b3e31a96bf5c", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "0999bb770f8dc92ab5581cc0b474b3e31a96bf5c", Subject: []byte("Hello\xf0world"), Body: []byte("Hello\xf0world\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1517328273}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1517328273}, @@ -179,15 +179,15 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "with a very large message", revision: bigCommitID, - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: bigCommitID, Subject: []byte("An empty commit with REALLY BIG message"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Scrooge McDuck"), Email: []byte("scrooge@mcduck.com"), Date: ×tamp.Timestamp{Seconds: bigCommit.Author.Date.Seconds}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Scrooge McDuck"), Email: []byte("scrooge@mcduck.com"), Date: ×tamp.Timestamp{Seconds: bigCommit.Committer.Date.Seconds}, @@ -200,16 +200,16 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { { description: "with different author and committer", revision: "77e835ef0856f33c4f0982f84d10bdb0567fe440", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "77e835ef0856f33c4f0982f84d10bdb0567fe440", Subject: []byte("Add file larger than 1 mb"), Body: []byte("Add file larger than 1 mb\n\nIn order to test Max File Size push rule we need a file larger than 1 MB\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Ruben Davila"), Email: []byte("rdavila84@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1523247267}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1527855450}, @@ -230,10 +230,10 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { }, } - allCommits := []*pb.GitCommit{} + allCommits := []*gitalypb.GitCommit{} for _, testCase := range testCases { t.Run(testCase.description, func(t *testing.T) { - request := &pb.FindCommitRequest{ + request := &gitalypb.FindCommitRequest{ Repository: testRepo, Revision: []byte(testCase.revision), } @@ -255,7 +255,7 @@ func TestSuccessfulFindCommitRequest(t *testing.T) { ) for i, testCase := range testCases { - request := &pb.FindCommitRequest{ + request := &gitalypb.FindCommitRequest{ Repository: testRepo, Revision: []byte(testCase.revision), } @@ -276,12 +276,12 @@ func TestFailedFindCommitRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { description string revision []byte - repo *pb.Repository + repo *gitalypb.Repository }{ {repo: invalidRepo, revision: []byte("master"), description: "Invalid repo"}, {repo: testRepo, revision: []byte(""), description: "Empty revision"}, @@ -298,7 +298,7 @@ func TestFailedFindCommitRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.description, func(t *testing.T) { - request := &pb.FindCommitRequest{ + request := &gitalypb.FindCommitRequest{ Repository: testCase.repo, Revision: testCase.revision, } diff --git a/internal/service/commit/find_commits.go b/internal/service/commit/find_commits.go index 0e9429a65..d8a1440c9 100644 --- a/internal/service/commit/find_commits.go +++ b/internal/service/commit/find_commits.go @@ -1,15 +1,14 @@ package commit import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) FindCommits(req *pb.FindCommitsRequest, stream pb.CommitService_FindCommitsServer) error { +func (s *server) FindCommits(req *gitalypb.FindCommitsRequest, stream gitalypb.CommitService_FindCommitsServer) error { ctx := stream.Context() // Use Gitaly's default branch lookup function because that is already diff --git a/internal/service/commit/find_commits_test.go b/internal/service/commit/find_commits_test.go index a01af547a..c3bc3c7e1 100644 --- a/internal/service/commit/find_commits_test.go +++ b/internal/service/commit/find_commits_test.go @@ -10,7 +10,7 @@ import ( "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "github.com/golang/protobuf/ptypes/timestamp" @@ -32,20 +32,20 @@ func TestFindCommitsFields(t *testing.T) { testCases := []struct { id string - commit *pb.GitCommit + commit *gitalypb.GitCommit }{ { id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -59,16 +59,16 @@ func TestFindCommitsFields(t *testing.T) { }, { id: "c809470461118b7bcab850f6e9a7ca97ac42f8ea", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "c809470461118b7bcab850f6e9a7ca97ac42f8ea", Subject: windows1251Message[:len(windows1251Message)-1], Body: windows1251Message, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1512132977}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1512132977}, @@ -79,16 +79,16 @@ func TestFindCommitsFields(t *testing.T) { }, { id: "0999bb770f8dc92ab5581cc0b474b3e31a96bf5c", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "0999bb770f8dc92ab5581cc0b474b3e31a96bf5c", Subject: []byte("Hello\xf0world"), Body: []byte("Hello\xf0world\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1517328273}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1517328273}, @@ -99,16 +99,16 @@ func TestFindCommitsFields(t *testing.T) { }, { id: "77e835ef0856f33c4f0982f84d10bdb0567fe440", - commit: &pb.GitCommit{ + commit: &gitalypb.GitCommit{ Id: "77e835ef0856f33c4f0982f84d10bdb0567fe440", Subject: []byte("Add file larger than 1 mb"), Body: []byte("Add file larger than 1 mb\n\nIn order to test Max File Size push rule we need a file larger than 1 MB\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Ruben Davila"), Email: []byte("rdavila84@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1523247267}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Jacob Vosmaer"), Email: []byte("jacob@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1527855450}, @@ -121,7 +121,7 @@ func TestFindCommitsFields(t *testing.T) { for _, tc := range testCases { t.Run(tc.id, func(t *testing.T) { - request := &pb.FindCommitsRequest{ + request := &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte(tc.id), Limit: 1, @@ -158,7 +158,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { testCases := []struct { desc string - request *pb.FindCommitsRequest + request *gitalypb.FindCommitsRequest // Use 'ids' if you know the exact commits id's that should be returned ids []string // Use minCommits if you don't know the exact commit id's @@ -166,7 +166,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }{ { desc: "only revision, limit commits", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte("0031876facac3f2b2702a0e53a26e89939a42209"), Limit: 3, @@ -179,21 +179,21 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }, { desc: "revision, default commit limit", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte("0031876facac3f2b2702a0e53a26e89939a42209"), }, }, { desc: "revision, default commit limit, bypassing rugged walk", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte("0031876facac3f2b2702a0e53a26e89939a42209"), DisableWalk: true, }, }, { desc: "revision and paths", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte("0031876facac3f2b2702a0e53a26e89939a42209"), Paths: [][]byte{[]byte("LICENSE")}, @@ -203,7 +203,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }, { desc: "empty revision", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Limit: 35, }, @@ -211,7 +211,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }, { desc: "before and after", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Before: ×tamp.Timestamp{Seconds: 1483225200}, After: ×tamp.Timestamp{Seconds: 1472680800}, @@ -224,7 +224,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }, { desc: "no merges", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte("e63f41fe459e62e1228fcef60d7189127aeba95a"), SkipMerges: true, @@ -245,7 +245,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }, { desc: "following renames", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Revision: []byte("94bb47ca1297b7b3731ff2a36923640991e9236f"), Paths: [][]byte{[]byte("CHANGELOG.md")}, @@ -260,7 +260,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { }, { desc: "all refs", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, All: true, Limit: 90, @@ -279,7 +279,7 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) { var ids []string for err == nil { - var resp *pb.FindCommitsResponse + var resp *gitalypb.FindCommitsResponse resp, err = stream.Recv() for _, c := range resp.GetCommits() { ids = append(ids, c.Id) @@ -339,7 +339,7 @@ func TestSuccessfulFindCommitsRequestWithAltGitObjectDirs(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { testRepoCopy.GitAlternateObjectDirectories = testCase.altDirs - request := &pb.FindCommitsRequest{ + request := &gitalypb.FindCommitsRequest{ Repository: testRepoCopy, Revision: currentHead, Limit: 1, @@ -351,7 +351,7 @@ func TestSuccessfulFindCommitsRequestWithAltGitObjectDirs(t *testing.T) { c, err := client.FindCommits(ctx, request) require.NoError(t, err) - receivedCommits := []*pb.GitCommit{} + receivedCommits := []*gitalypb.GitCommit{} for { resp, err := c.Recv() @@ -381,12 +381,12 @@ func TestFailureFindCommitsRequest(t *testing.T) { testCases := []struct { desc string - request *pb.FindCommitsRequest + request *gitalypb.FindCommitsRequest code codes.Code }{ { desc: "empty path string", - request: &pb.FindCommitsRequest{ + request: &gitalypb.FindCommitsRequest{ Repository: testRepo, Paths: [][]byte{[]byte("")}, }, diff --git a/internal/service/commit/isancestor.go b/internal/service/commit/isancestor.go index 120508858..eeca8ebae 100644 --- a/internal/service/commit/isancestor.go +++ b/internal/service/commit/isancestor.go @@ -9,11 +9,11 @@ import ( log "github.com/sirupsen/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" ) -func (s *server) CommitIsAncestor(ctx context.Context, in *pb.CommitIsAncestorRequest) (*pb.CommitIsAncestorResponse, error) { +func (s *server) CommitIsAncestor(ctx context.Context, in *gitalypb.CommitIsAncestorRequest) (*gitalypb.CommitIsAncestorResponse, error) { if in.AncestorId == "" { return nil, status.Errorf(codes.InvalidArgument, "Bad Request (empty ancestor sha)") } @@ -22,11 +22,11 @@ func (s *server) CommitIsAncestor(ctx context.Context, in *pb.CommitIsAncestorRe } ret, err := commitIsAncestorName(ctx, in.Repository, in.AncestorId, in.ChildId) - return &pb.CommitIsAncestorResponse{Value: ret}, err + return &gitalypb.CommitIsAncestorResponse{Value: ret}, err } // Assumes that `path`, `ancestorID` and `childID` are populated :trollface: -func commitIsAncestorName(ctx context.Context, repo *pb.Repository, ancestorID, childID string) (bool, error) { +func commitIsAncestorName(ctx context.Context, repo *gitalypb.Repository, ancestorID, childID string) (bool, error) { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "ancestorSha": ancestorID, "childSha": childID, diff --git a/internal/service/commit/isancestor_test.go b/internal/service/commit/isancestor_test.go index 9a8e0530c..89948d380 100644 --- a/internal/service/commit/isancestor_test.go +++ b/internal/service/commit/isancestor_test.go @@ -5,14 +5,13 @@ import ( "os/exec" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "github.com/stretchr/testify/require" "golang.org/x/net/context" "google.golang.org/grpc/codes" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) func TestCommitIsAncestorFailure(t *testing.T) { @@ -26,12 +25,12 @@ func TestCommitIsAncestorFailure(t *testing.T) { defer cleanupFn() queries := []struct { - Request *pb.CommitIsAncestorRequest + Request *gitalypb.CommitIsAncestorRequest ErrorCode codes.Code ErrMsg string }{ { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: nil, AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", @@ -40,7 +39,7 @@ func TestCommitIsAncestorFailure(t *testing.T) { ErrMsg: "Expected to throw invalid argument got: %s", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "", ChildId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", @@ -49,7 +48,7 @@ func TestCommitIsAncestorFailure(t *testing.T) { ErrMsg: "Expected to throw invalid argument got: %s", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "", @@ -58,8 +57,8 @@ func TestCommitIsAncestorFailure(t *testing.T) { ErrMsg: "Expected to throw invalid argument got: %s", }, { - Request: &pb.CommitIsAncestorRequest{ - Repository: &pb.Repository{StorageName: "default", RelativePath: "fake-path"}, + Request: &gitalypb.CommitIsAncestorRequest{ + Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "fake-path"}, AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", }, @@ -92,12 +91,12 @@ func TestCommitIsAncestorSuccess(t *testing.T) { defer cleanupFn() queries := []struct { - Request *pb.CommitIsAncestorRequest + Request *gitalypb.CommitIsAncestorRequest Response bool ErrMsg string }{ { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", ChildId: "372ab6950519549b14d220271ee2322caa44d4eb", @@ -106,7 +105,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { ErrMsg: "Expected commit to be ancestor", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e", @@ -115,7 +114,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { ErrMsg: "Expected commit not to be ancestor", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "1234123412341234123412341234123412341234", ChildId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", @@ -124,7 +123,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { ErrMsg: "Expected invalid commit to not be ancestor", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", ChildId: "gitaly-stuff", @@ -133,7 +132,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { ErrMsg: "Expected `b83d6e391c22777fca1ed3012fce84f633d7fed0` to be ancestor of `gitaly-stuff`", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "gitaly-stuff", ChildId: "master", @@ -142,7 +141,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { ErrMsg: "Expected branch `gitaly-stuff` not to be ancestor of `master`", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "refs/tags/v1.0.0", ChildId: "refs/tags/v1.1.0", @@ -151,7 +150,7 @@ func TestCommitIsAncestorSuccess(t *testing.T) { ErrMsg: "Expected tag `v1.0.0` to be ancestor of `v1.1.0`", }, { - Request: &pb.CommitIsAncestorRequest{ + Request: &gitalypb.CommitIsAncestorRequest{ Repository: testRepo, AncestorId: "refs/tags/v1.1.0", ChildId: "refs/tags/v1.0.0", @@ -219,7 +218,7 @@ func TestSuccessfulIsAncestorRequestWithAltGitObjectDirs(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { testRepoCopy.GitAlternateObjectDirectories = testCase.altDirs - request := &pb.CommitIsAncestorRequest{ + request := &gitalypb.CommitIsAncestorRequest{ Repository: testRepoCopy, AncestorId: string(previousHead), ChildId: string(currentHead), diff --git a/internal/service/commit/languages.go b/internal/service/commit/languages.go index 5d8227a6a..3ebde7dbe 100644 --- a/internal/service/commit/languages.go +++ b/internal/service/commit/languages.go @@ -8,17 +8,16 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/linguist" "gitlab.com/gitlab-org/gitaly/internal/service/ref" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" ) -func (*server) CommitLanguages(ctx context.Context, req *pb.CommitLanguagesRequest) (*pb.CommitLanguagesResponse, error) { +func (*server) CommitLanguages(ctx context.Context, req *gitalypb.CommitLanguagesRequest) (*gitalypb.CommitLanguagesResponse, error) { repo := req.Repository revision := string(req.Revision) @@ -44,7 +43,7 @@ func (*server) CommitLanguages(ctx context.Context, req *pb.CommitLanguagesReque return nil, err } - resp := &pb.CommitLanguagesResponse{} + resp := &gitalypb.CommitLanguagesResponse{} if len(stats) == 0 { return resp, nil } @@ -59,7 +58,7 @@ func (*server) CommitLanguages(ctx context.Context, req *pb.CommitLanguagesReque } for lang, count := range stats { - l := &pb.CommitLanguagesResponse_Language{ + l := &gitalypb.CommitLanguagesResponse_Language{ Name: lang, Share: float32(100*count) / float32(total), Color: linguist.Color(lang), @@ -72,13 +71,13 @@ func (*server) CommitLanguages(ctx context.Context, req *pb.CommitLanguagesReque return resp, nil } -type languageSorter []*pb.CommitLanguagesResponse_Language +type languageSorter []*gitalypb.CommitLanguagesResponse_Language func (ls languageSorter) Len() int { return len(ls) } func (ls languageSorter) Swap(i, j int) { ls[i], ls[j] = ls[j], ls[i] } func (ls languageSorter) Less(i, j int) bool { return ls[i].Share > ls[j].Share } -func lookupRevision(ctx context.Context, repo *pb.Repository, revision string) (string, error) { +func lookupRevision(ctx context.Context, repo *gitalypb.Repository, revision string) (string, error) { revParse, err := git.Command(ctx, repo, "rev-parse", revision) if err != nil { return "", err diff --git a/internal/service/commit/languages_test.go b/internal/service/commit/languages_test.go index 0deeb7ca0..5b3497f35 100644 --- a/internal/service/commit/languages_test.go +++ b/internal/service/commit/languages_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "github.com/stretchr/testify/require" @@ -20,7 +20,7 @@ func TestLanguages(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.CommitLanguagesRequest{ + request := &gitalypb.CommitLanguagesRequest{ Repository: testRepo, Revision: []byte("cb19058ecc02d01f8e4290b7e79cafd16a8839b6"), } @@ -32,7 +32,7 @@ func TestLanguages(t *testing.T) { require.NotZero(t, len(resp.Languages), "number of languages in response") - expectedLanguages := []pb.CommitLanguagesResponse_Language{ + expectedLanguages := []gitalypb.CommitLanguagesResponse_Language{ {Name: "Ruby", Share: 66, Color: "#701516"}, {Name: "JavaScript", Share: 22, Color: "#f1e05a"}, {Name: "HTML", Share: 7, Color: "#e34c26"}, @@ -50,7 +50,7 @@ func TestLanguages(t *testing.T) { } } -func languageEqual(expected, actual *pb.CommitLanguagesResponse_Language) bool { +func languageEqual(expected, actual *gitalypb.CommitLanguagesResponse_Language) bool { if expected.Name != actual.Name { return false } @@ -73,7 +73,7 @@ func TestLanguagesEmptyRevision(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.CommitLanguagesRequest{ + request := &gitalypb.CommitLanguagesRequest{ Repository: testRepo, } diff --git a/internal/service/commit/last_commit_for_path.go b/internal/service/commit/last_commit_for_path.go index ce049bf86..1b528fdbf 100644 --- a/internal/service/commit/last_commit_for_path.go +++ b/internal/service/commit/last_commit_for_path.go @@ -3,16 +3,15 @@ package commit import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) LastCommitForPath(ctx context.Context, in *pb.LastCommitForPathRequest) (*pb.LastCommitForPathResponse, error) { +func (s *server) LastCommitForPath(ctx context.Context, in *gitalypb.LastCommitForPathRequest) (*gitalypb.LastCommitForPathResponse, error) { if err := validateLastCommitForPathRequest(in); err != nil { return nil, status.Errorf(codes.InvalidArgument, "LastCommitForPath: %v", err) } @@ -27,10 +26,10 @@ func (s *server) LastCommitForPath(ctx context.Context, in *pb.LastCommitForPath return nil, err } - return &pb.LastCommitForPathResponse{Commit: commit}, nil + return &gitalypb.LastCommitForPathResponse{Commit: commit}, nil } -func validateLastCommitForPathRequest(in *pb.LastCommitForPathRequest) error { +func validateLastCommitForPathRequest(in *gitalypb.LastCommitForPathRequest) error { if len(in.Revision) == 0 { return fmt.Errorf("empty Revision") } diff --git a/internal/service/commit/last_commit_for_path_test.go b/internal/service/commit/last_commit_for_path_test.go index 58e234d73..4dff1b648 100644 --- a/internal/service/commit/last_commit_for_path_test.go +++ b/internal/service/commit/last_commit_for_path_test.go @@ -3,10 +3,9 @@ package commit import ( "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" "golang.org/x/net/context" @@ -23,16 +22,16 @@ func TestSuccessfulLastCommitForPathRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - commit := &pb.GitCommit{ + commit := &gitalypb.GitCommit{ Id: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d", Subject: []byte("Change some files"), Body: []byte("Change some files\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491451}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491451}, @@ -45,7 +44,7 @@ func TestSuccessfulLastCommitForPathRequest(t *testing.T) { desc string revision string path []byte - commit *pb.GitCommit + commit *gitalypb.GitCommit }{ { desc: "path present", @@ -73,7 +72,7 @@ func TestSuccessfulLastCommitForPathRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.LastCommitForPathRequest{ + request := &gitalypb.LastCommitForPathRequest{ Repository: testRepo, Revision: []byte(testCase.revision), Path: []byte(testCase.path), @@ -101,26 +100,26 @@ func TestFailedLastCommitForPathRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { desc string - request *pb.LastCommitForPathRequest + request *gitalypb.LastCommitForPathRequest code codes.Code }{ { desc: "Invalid repository", - request: &pb.LastCommitForPathRequest{Repository: invalidRepo}, + request: &gitalypb.LastCommitForPathRequest{Repository: invalidRepo}, code: codes.InvalidArgument, }, { desc: "Repository is nil", - request: &pb.LastCommitForPathRequest{Revision: []byte("some-branch")}, + request: &gitalypb.LastCommitForPathRequest{Revision: []byte("some-branch")}, code: codes.InvalidArgument, }, { desc: "Revision is missing", - request: &pb.LastCommitForPathRequest{Repository: testRepo, Path: []byte("foo/bar")}, + request: &gitalypb.LastCommitForPathRequest{Repository: testRepo, Path: []byte("foo/bar")}, code: codes.InvalidArgument, }, } diff --git a/internal/service/commit/list_commits_by_oid.go b/internal/service/commit/list_commits_by_oid.go index 2035debb4..05a7a1deb 100644 --- a/internal/service/commit/list_commits_by_oid.go +++ b/internal/service/commit/list_commits_by_oid.go @@ -1,14 +1,14 @@ package commit import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" ) const batchSizeListCommitsByOid = 20 -func (s *server) ListCommitsByOid(in *pb.ListCommitsByOidRequest, stream pb.CommitService_ListCommitsByOidServer) error { +func (s *server) ListCommitsByOid(in *gitalypb.ListCommitsByOidRequest, stream gitalypb.CommitService_ListCommitsByOidServer) error { ctx := stream.Context() c, err := catfile.New(ctx, in.Repository) @@ -16,11 +16,11 @@ func (s *server) ListCommitsByOid(in *pb.ListCommitsByOidRequest, stream pb.Comm return err } - send := func(commits []*pb.GitCommit) error { - return stream.Send(&pb.ListCommitsByOidResponse{Commits: commits}) + send := func(commits []*gitalypb.GitCommit) error { + return stream.Send(&gitalypb.ListCommitsByOidResponse{Commits: commits}) } - var commits []*pb.GitCommit + var commits []*gitalypb.GitCommit for _, oid := range in.Oid { commit, err := gitlog.GetCommitCatfile(c, oid) if err != nil { diff --git a/internal/service/commit/list_commits_by_oid_test.go b/internal/service/commit/list_commits_by_oid_test.go index 31f57be41..9b778e1a8 100644 --- a/internal/service/commit/list_commits_by_oid_test.go +++ b/internal/service/commit/list_commits_by_oid_test.go @@ -4,7 +4,7 @@ import ( "io" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "github.com/stretchr/testify/require" @@ -21,7 +21,7 @@ func TestSuccessfulListCommitsByOidRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - commits := []*pb.GitCommit{ + commits := []*gitalypb.GitCommit{ { Id: "bf6e164cac2dc32b1f391ca4290badcbe4ffc5fb", Subject: []byte("Commit #10"), @@ -44,50 +44,50 @@ func TestSuccessfulListCommitsByOidRequest(t *testing.T) { testCases := []struct { desc string - request *pb.ListCommitsByOidRequest - expectedCommits []*pb.GitCommit + request *gitalypb.ListCommitsByOidRequest + expectedCommits []*gitalypb.GitCommit }{ { desc: "find one commit", - request: &pb.ListCommitsByOidRequest{ + request: &gitalypb.ListCommitsByOidRequest{ Oid: []string{commits[0].Id}, }, expectedCommits: commits[0:1], }, { desc: "find multiple commits", - request: &pb.ListCommitsByOidRequest{ + request: &gitalypb.ListCommitsByOidRequest{ Oid: []string{commits[0].Id, commits[1].Id}, }, expectedCommits: commits, }, { desc: "no query", - request: &pb.ListCommitsByOidRequest{ + request: &gitalypb.ListCommitsByOidRequest{ Oid: []string{}, }, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, { desc: "empty query", - request: &pb.ListCommitsByOidRequest{ + request: &gitalypb.ListCommitsByOidRequest{ Oid: []string{""}, }, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, { desc: "partial oids", - request: &pb.ListCommitsByOidRequest{ + request: &gitalypb.ListCommitsByOidRequest{ Oid: []string{commits[0].Id[0:10], commits[1].Id[0:8]}, }, expectedCommits: commits, }, { desc: "unknown oids", - request: &pb.ListCommitsByOidRequest{ + request: &gitalypb.ListCommitsByOidRequest{ Oid: []string{"deadbeef", "987654321"}, }, - expectedCommits: []*pb.GitCommit{}, + expectedCommits: []*gitalypb.GitCommit{}, }, } @@ -114,8 +114,8 @@ func TestSuccessfulListCommitsByOidRequest(t *testing.T) { } } -func consumeGetByOidResponse(t *testing.T, c pb.CommitService_ListCommitsByOidClient) []*pb.GitCommit { - receivedCommits := []*pb.GitCommit{} +func consumeGetByOidResponse(t *testing.T, c gitalypb.CommitService_ListCommitsByOidClient) []*gitalypb.GitCommit { + receivedCommits := []*gitalypb.GitCommit{} for { resp, err := c.Recv() if err == io.EOF { @@ -186,7 +186,7 @@ func TestSuccessfulListCommitsByOidLargeRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - req := &pb.ListCommitsByOidRequest{ + req := &gitalypb.ListCommitsByOidRequest{ Oid: masterCommitids, Repository: testRepo, } diff --git a/internal/service/commit/list_files.go b/internal/service/commit/list_files.go index c764e71dd..e1d5f1d49 100644 --- a/internal/service/commit/list_files.go +++ b/internal/service/commit/list_files.go @@ -8,13 +8,13 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/helper/lines" ) -func (s *server) ListFiles(in *pb.ListFilesRequest, stream pb.CommitService_ListFilesServer) error { +func (s *server) ListFiles(in *gitalypb.ListFilesRequest, stream gitalypb.CommitService_ListFilesServer) error { grpc_logrus.Extract(stream.Context()).WithFields(log.Fields{ "Revision": in.GetRevision(), }).Debug("ListFiles") @@ -37,7 +37,7 @@ func (s *server) ListFiles(in *pb.ListFilesRequest, stream pb.CommitService_List } } if !git.IsValidRef(stream.Context(), repo, string(revision)) { - return stream.Send(&pb.ListFilesResponse{}) + return stream.Send(&gitalypb.ListFilesResponse{}) } cmd, err := git.Command(stream.Context(), repo, "ls-tree", "-z", "-r", "--full-tree", "--full-name", "--", string(revision)) @@ -51,7 +51,7 @@ func (s *server) ListFiles(in *pb.ListFilesRequest, stream pb.CommitService_List return lines.Send(cmd, listFilesWriter(stream), []byte{'\x00'}) } -func listFilesWriter(stream pb.CommitService_ListFilesServer) lines.Sender { +func listFilesWriter(stream gitalypb.CommitService_ListFilesServer) lines.Sender { return func(objs [][]byte) error { paths := make([][]byte, 0) for _, obj := range objs { @@ -69,6 +69,6 @@ func listFilesWriter(stream pb.CommitService_ListFilesServer) lines.Sender { paths = append(paths, data[1]) } } - return stream.Send(&pb.ListFilesResponse{Paths: paths}) + return stream.Send(&gitalypb.ListFilesResponse{Paths: paths}) } } diff --git a/internal/service/commit/list_files_test.go b/internal/service/commit/list_files_test.go index acd93e609..2c0b55ab8 100644 --- a/internal/service/commit/list_files_test.go +++ b/internal/service/commit/list_files_test.go @@ -10,7 +10,7 @@ import ( "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/service/ref" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -43,7 +43,7 @@ var ( ) func TestListFilesSuccess(t *testing.T) { - defaultBranchName = func(ctx context.Context, _ *pb.Repository) ([]byte, error) { + defaultBranchName = func(ctx context.Context, _ *gitalypb.Repository) ([]byte, error) { return []byte("test-do-not-touch"), nil } defer func() { @@ -101,7 +101,7 @@ func TestListFilesSuccess(t *testing.T) { for _, test := range tests { t.Run(fmt.Sprintf("test case: %q", test.revision), func(t *testing.T) { var files [][]byte - rpcRequest := pb.ListFilesRequest{ + rpcRequest := gitalypb.ListFilesRequest{ Repository: testRepo, Revision: []byte(test.revision), } @@ -144,22 +144,22 @@ func TestListFilesFailure(t *testing.T) { defer conn.Close() tests := []struct { - repo *pb.Repository + repo *gitalypb.Repository code codes.Code desc string }{ // Nil Repo {repo: nil, code: codes.InvalidArgument, desc: "nil repo"}, // Empty Repo Object - {repo: &pb.Repository{}, code: codes.InvalidArgument, desc: "empty repo object"}, + {repo: &gitalypb.Repository{}, code: codes.InvalidArgument, desc: "empty repo object"}, // Non-existing Repo - {repo: &pb.Repository{StorageName: "foo", RelativePath: "bar"}, code: codes.InvalidArgument, desc: "non-existing repo"}, + {repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar"}, code: codes.InvalidArgument, desc: "non-existing repo"}, } for _, test := range tests { t.Run(test.desc, func(t *testing.T) { - rpcRequest := pb.ListFilesRequest{ + rpcRequest := gitalypb.ListFilesRequest{ Repository: test.repo, Revision: []byte("master"), } @@ -176,7 +176,7 @@ func TestListFilesFailure(t *testing.T) { } } -func drainListFilesResponse(c pb.CommitService_ListFilesClient) error { +func drainListFilesResponse(c gitalypb.CommitService_ListFilesClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/list_last_commits_for_tree.go b/internal/service/commit/list_last_commits_for_tree.go index e7fa14ee2..c145bd0df 100644 --- a/internal/service/commit/list_last_commits_for_tree.go +++ b/internal/service/commit/list_last_commits_for_tree.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/log" @@ -19,7 +19,7 @@ var ( maxNumStatBatchSize = 10 ) -func (s *server) ListLastCommitsForTree(in *pb.ListLastCommitsForTreeRequest, stream pb.CommitService_ListLastCommitsForTreeServer) error { +func (s *server) ListLastCommitsForTree(in *gitalypb.ListLastCommitsForTreeRequest, stream gitalypb.CommitService_ListLastCommitsForTreeServer) error { if err := validateListLastCommitsForTreeRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "ListLastCommitsForTree: %v", err) } @@ -33,7 +33,7 @@ func (s *server) ListLastCommitsForTree(in *pb.ListLastCommitsForTreeRequest, st return status.Errorf(codes.Internal, "ListLastCommitsForTree: gitCommand: %v", err) } - batch := make([]*pb.ListLastCommitsForTreeResponse_CommitForTree, 0, maxNumStatBatchSize) + batch := make([]*gitalypb.ListLastCommitsForTreeResponse_CommitForTree, 0, maxNumStatBatchSize) entries, err := getLSTreeEntries(parser) if err != nil { return err @@ -56,7 +56,7 @@ func (s *server) ListLastCommitsForTree(in *pb.ListLastCommitsForTreeRequest, st return err } - commitForTree := &pb.ListLastCommitsForTreeResponse_CommitForTree{ + commitForTree := &gitalypb.ListLastCommitsForTreeResponse_CommitForTree{ Path: entry.Path, Commit: commit, } @@ -99,7 +99,7 @@ func getLSTreeEntries(parser *lstree.Parser) (lstree.Entries, error) { return entries, nil } -func newLSTreeParser(in *pb.ListLastCommitsForTreeRequest, stream pb.CommitService_ListLastCommitsForTreeServer) (*command.Command, *lstree.Parser, error) { +func newLSTreeParser(in *gitalypb.ListLastCommitsForTreeRequest, stream gitalypb.CommitService_ListLastCommitsForTreeServer) (*command.Command, *lstree.Parser, error) { path := string(in.GetPath()) if path == "" || path == "/" { path = "." @@ -114,19 +114,19 @@ func newLSTreeParser(in *pb.ListLastCommitsForTreeRequest, stream pb.CommitServi return cmd, lstree.NewParser(cmd), nil } -func sendCommitsForTree(batch []*pb.ListLastCommitsForTreeResponse_CommitForTree, stream pb.CommitService_ListLastCommitsForTreeServer) error { +func sendCommitsForTree(batch []*gitalypb.ListLastCommitsForTreeResponse_CommitForTree, stream gitalypb.CommitService_ListLastCommitsForTreeServer) error { if len(batch) == 0 { return nil } - if err := stream.Send(&pb.ListLastCommitsForTreeResponse{Commits: batch}); err != nil { + if err := stream.Send(&gitalypb.ListLastCommitsForTreeResponse{Commits: batch}); err != nil { return err } return nil } -func validateListLastCommitsForTreeRequest(in *pb.ListLastCommitsForTreeRequest) error { +func validateListLastCommitsForTreeRequest(in *gitalypb.ListLastCommitsForTreeRequest) error { if in.Revision == "" { return fmt.Errorf("empty Revision") } diff --git a/internal/service/commit/list_last_commits_for_tree_test.go b/internal/service/commit/list_last_commits_for_tree_test.go index 1b0b10fc7..49d2cc5f3 100644 --- a/internal/service/commit/list_last_commits_for_tree_test.go +++ b/internal/service/commit/list_last_commits_for_tree_test.go @@ -4,10 +4,9 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -168,7 +167,7 @@ func TestSuccessfulListLastCommitsForTreeRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.ListLastCommitsForTreeRequest{ + request := &gitalypb.ListLastCommitsForTreeRequest{ Repository: testRepo, Revision: testCase.revision, Path: testCase.path, @@ -218,16 +217,16 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - invalidRepo := &pb.Repository{StorageName: "broken", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "broken", RelativePath: "path"} testCases := []struct { desc string - request *pb.ListLastCommitsForTreeRequest + request *gitalypb.ListLastCommitsForTreeRequest code codes.Code }{ { desc: "Revision is missing", - request: &pb.ListLastCommitsForTreeRequest{ + request: &gitalypb.ListLastCommitsForTreeRequest{ Repository: testRepo, Path: []byte("/"), Revision: "", @@ -238,7 +237,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { }, { desc: "Invalid repository", - request: &pb.ListLastCommitsForTreeRequest{ + request: &gitalypb.ListLastCommitsForTreeRequest{ Repository: invalidRepo, Path: []byte("/"), Revision: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d", @@ -249,7 +248,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { }, { desc: "Repository is nil", - request: &pb.ListLastCommitsForTreeRequest{ + request: &gitalypb.ListLastCommitsForTreeRequest{ Path: []byte("/"), Revision: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d", Offset: 0, @@ -259,7 +258,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { }, { desc: "Revision is missing", - request: &pb.ListLastCommitsForTreeRequest{ + request: &gitalypb.ListLastCommitsForTreeRequest{ Repository: testRepo, Path: []byte("/"), Offset: 0, @@ -269,7 +268,7 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) { }, { desc: "Ambiguous revision", - request: &pb.ListLastCommitsForTreeRequest{ + request: &gitalypb.ListLastCommitsForTreeRequest{ Repository: testRepo, Revision: "a", Offset: 0, diff --git a/internal/service/commit/raw_blame.go b/internal/service/commit/raw_blame.go index 59b8a083f..aec6849a0 100644 --- a/internal/service/commit/raw_blame.go +++ b/internal/service/commit/raw_blame.go @@ -4,17 +4,16 @@ import ( "fmt" "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) RawBlame(in *pb.RawBlameRequest, stream pb.CommitService_RawBlameServer) error { +func (s *server) RawBlame(in *gitalypb.RawBlameRequest, stream gitalypb.CommitService_RawBlameServer) error { if err := validateRawBlameRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "RawBlame: %v", err) } @@ -32,7 +31,7 @@ func (s *server) RawBlame(in *pb.RawBlameRequest, stream pb.CommitService_RawBla } sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.RawBlameResponse{Data: p}) + return stream.Send(&gitalypb.RawBlameResponse{Data: p}) }) _, err = io.Copy(sw, cmd) @@ -47,7 +46,7 @@ func (s *server) RawBlame(in *pb.RawBlameRequest, stream pb.CommitService_RawBla return nil } -func validateRawBlameRequest(in *pb.RawBlameRequest) error { +func validateRawBlameRequest(in *gitalypb.RawBlameRequest) error { if len(in.GetRevision()) == 0 { return fmt.Errorf("empty Revision") } diff --git a/internal/service/commit/raw_blame_test.go b/internal/service/commit/raw_blame_test.go index aa3d3c39d..4406fac1a 100644 --- a/internal/service/commit/raw_blame_test.go +++ b/internal/service/commit/raw_blame_test.go @@ -5,11 +5,10 @@ import ( "io/ioutil" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -48,7 +47,7 @@ func TestSuccessfulRawBlameRequest(t *testing.T) { for _, testCase := range testCases { t.Run(fmt.Sprintf("test case: revision=%q path=%q", testCase.revision, testCase.path), func(t *testing.T) { - request := &pb.RawBlameRequest{ + request := &gitalypb.RawBlameRequest{ Repository: testRepo, Revision: testCase.revision, Path: testCase.path, @@ -86,11 +85,11 @@ func TestFailedRawBlameRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { description string - repo *pb.Repository + repo *gitalypb.Repository revision, path []byte code codes.Code }{ @@ -120,7 +119,7 @@ func TestFailedRawBlameRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.description, func(t *testing.T) { - request := pb.RawBlameRequest{ + request := gitalypb.RawBlameRequest{ Repository: testCase.repo, Revision: testCase.revision, Path: testCase.path, @@ -138,7 +137,7 @@ func TestFailedRawBlameRequest(t *testing.T) { } } -func drainRawBlameResponse(c pb.CommitService_RawBlameClient) error { +func drainRawBlameResponse(c gitalypb.CommitService_RawBlameClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/server.go b/internal/service/commit/server.go index eb2f3046d..7f2024531 100644 --- a/internal/service/commit/server.go +++ b/internal/service/commit/server.go @@ -1,10 +1,9 @@ package commit import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/service/ref" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) type server struct { @@ -16,6 +15,6 @@ var ( ) // NewServer creates a new instance of a grpc CommitServiceServer -func NewServer(rs *rubyserver.Server) pb.CommitServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.CommitServiceServer { return &server{rs} } diff --git a/internal/service/commit/stats.go b/internal/service/commit/stats.go index 9b647f15b..e8dc33fae 100644 --- a/internal/service/commit/stats.go +++ b/internal/service/commit/stats.go @@ -3,12 +3,12 @@ package commit import ( "golang.org/x/net/context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) -func (s *server) CommitStats(ctx context.Context, in *pb.CommitStatsRequest) (*pb.CommitStatsResponse, error) { +func (s *server) CommitStats(ctx context.Context, in *gitalypb.CommitStatsRequest) (*gitalypb.CommitStatsResponse, error) { client, err := s.CommitServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/commit/stats_test.go b/internal/service/commit/stats_test.go index bf0d7e34a..61f6bcfde 100644 --- a/internal/service/commit/stats_test.go +++ b/internal/service/commit/stats_test.go @@ -8,7 +8,7 @@ import ( "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -45,7 +45,7 @@ func TestCommitStatsSuccess(t *testing.T) { } for _, tc := range tests { - resp, err := client.CommitStats(ctx, &pb.CommitStatsRequest{Repository: testRepo, Revision: tc.revision}) + resp, err := client.CommitStats(ctx, &gitalypb.CommitStatsRequest{Repository: testRepo, Revision: tc.revision}) assert.NoError(t, err) assert.Equal(t, tc.oid, resp.GetOid()) assert.Equal(t, tc.additions, resp.GetAdditions()) @@ -68,19 +68,19 @@ func TestCommitStatsFailure(t *testing.T) { tests := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository revision []byte err codes.Code }{ { desc: "repo not found", - repo: &pb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar.git"}, revision: []byte("test-do-not-touch"), err: codes.NotFound, }, { desc: "storage not found", - repo: &pb.Repository{StorageName: "foo", RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar.git"}, revision: []byte("test-do-not-touch"), err: codes.InvalidArgument, }, @@ -94,7 +94,7 @@ func TestCommitStatsFailure(t *testing.T) { for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - _, err := client.CommitStats(ctx, &pb.CommitStatsRequest{Repository: tc.repo, Revision: tc.revision}) + _, err := client.CommitStats(ctx, &gitalypb.CommitStatsRequest{Repository: tc.repo, Revision: tc.revision}) testhelper.RequireGrpcError(t, err, tc.err) }) } diff --git a/internal/service/commit/testhelper_test.go b/internal/service/commit/testhelper_test.go index fe939f3f9..c26bf5fef 100644 --- a/internal/service/commit/testhelper_test.go +++ b/internal/service/commit/testhelper_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/linguist" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -14,8 +15,6 @@ import ( log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/reflection" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) var () @@ -52,14 +51,14 @@ func startTestServices(t *testing.T) (*grpc.Server, string) { t.Fatal("failed to start server") } - pb.RegisterCommitServiceServer(server, NewServer(rubyServer)) + gitalypb.RegisterCommitServiceServer(server, NewServer(rubyServer)) reflection.Register(server) go server.Serve(listener) return server, serverSocketPath } -func newCommitServiceClient(t *testing.T, serviceSocketPath string) (pb.CommitServiceClient, *grpc.ClientConn) { +func newCommitServiceClient(t *testing.T, serviceSocketPath string) (gitalypb.CommitServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -71,11 +70,11 @@ func newCommitServiceClient(t *testing.T, serviceSocketPath string) (pb.CommitSe t.Fatal(err) } - return pb.NewCommitServiceClient(conn), conn + return gitalypb.NewCommitServiceClient(conn), conn } -func dummyCommitAuthor(ts int64) *pb.CommitAuthor { - return &pb.CommitAuthor{ +func dummyCommitAuthor(ts int64) *gitalypb.CommitAuthor { + return &gitalypb.CommitAuthor{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad+gitlab-test@gitlab.com"), Date: ×tamp.Timestamp{Seconds: ts}, diff --git a/internal/service/commit/tree_entries.go b/internal/service/commit/tree_entries.go index e974bf31e..e6ac63377 100644 --- a/internal/service/commit/tree_entries.go +++ b/internal/service/commit/tree_entries.go @@ -6,7 +6,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -14,7 +14,7 @@ import ( var maxTreeEntries = 1000 -func validateGetTreeEntriesRequest(in *pb.GetTreeEntriesRequest) error { +func validateGetTreeEntriesRequest(in *gitalypb.GetTreeEntriesRequest) error { if len(in.GetRevision()) == 0 { return fmt.Errorf("empty Revision") } @@ -26,11 +26,11 @@ func validateGetTreeEntriesRequest(in *pb.GetTreeEntriesRequest) error { return nil } -func populateFlatPath(c *catfile.Batch, entries []*pb.TreeEntry) error { +func populateFlatPath(c *catfile.Batch, entries []*gitalypb.TreeEntry) error { for _, entry := range entries { entry.FlatPath = entry.Path - if entry.Type != pb.TreeEntry_TREE { + if entry.Type != gitalypb.TreeEntry_TREE { continue } @@ -40,7 +40,7 @@ func populateFlatPath(c *catfile.Batch, entries []*pb.TreeEntry) error { if err != nil { return err } - if len(subentries) != 1 || subentries[0].Type != pb.TreeEntry_TREE { + if len(subentries) != 1 || subentries[0].Type != gitalypb.TreeEntry_TREE { break } @@ -51,7 +51,7 @@ func populateFlatPath(c *catfile.Batch, entries []*pb.TreeEntry) error { return nil } -func sendTreeEntries(stream pb.CommitService_GetTreeEntriesServer, c *catfile.Batch, revision, path string, recursive bool) error { +func sendTreeEntries(stream gitalypb.CommitService_GetTreeEntriesServer, c *catfile.Batch, revision, path string, recursive bool) error { entries, err := treeEntries(c, revision, path, "", recursive) if err != nil { return err @@ -64,7 +64,7 @@ func sendTreeEntries(stream pb.CommitService_GetTreeEntriesServer, c *catfile.Ba } for len(entries) > maxTreeEntries { - chunk := &pb.GetTreeEntriesResponse{ + chunk := &gitalypb.GetTreeEntriesResponse{ Entries: entries[:maxTreeEntries], } if err := stream.Send(chunk); err != nil { @@ -74,13 +74,13 @@ func sendTreeEntries(stream pb.CommitService_GetTreeEntriesServer, c *catfile.Ba } if len(entries) > 0 { - return stream.Send(&pb.GetTreeEntriesResponse{Entries: entries}) + return stream.Send(&gitalypb.GetTreeEntriesResponse{Entries: entries}) } return nil } -func (s *server) GetTreeEntries(in *pb.GetTreeEntriesRequest, stream pb.CommitService_GetTreeEntriesServer) error { +func (s *server) GetTreeEntries(in *gitalypb.GetTreeEntriesRequest, stream gitalypb.CommitService_GetTreeEntriesServer) error { grpc_logrus.Extract(stream.Context()).WithFields(log.Fields{ "Revision": in.Revision, "Path": in.Path, diff --git a/internal/service/commit/tree_entries_helper.go b/internal/service/commit/tree_entries_helper.go index b18467cae..1edb74fa2 100644 --- a/internal/service/commit/tree_entries_helper.go +++ b/internal/service/commit/tree_entries_helper.go @@ -8,18 +8,18 @@ import ( "path/filepath" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" ) const oidSize = 20 -func extractEntryInfoFromTreeData(treeData *bytes.Buffer, commitOid, rootOid, rootPath string, treeInfo *catfile.ObjectInfo) ([]*pb.TreeEntry, error) { +func extractEntryInfoFromTreeData(treeData *bytes.Buffer, commitOid, rootOid, rootPath string, treeInfo *catfile.ObjectInfo) ([]*gitalypb.TreeEntry, error) { if len(treeInfo.Oid) == 0 { return nil, fmt.Errorf("empty tree oid") } - var entries []*pb.TreeEntry + var entries []*gitalypb.TreeEntry oidBuf := &bytes.Buffer{} for treeData.Len() > 0 { modeBytes, err := treeData.ReadBytes(' ') @@ -50,7 +50,7 @@ func extractEntryInfoFromTreeData(treeData *bytes.Buffer, commitOid, rootOid, ro return entries, nil } -func treeEntries(c *catfile.Batch, revision, path string, rootOid string, recursive bool) ([]*pb.TreeEntry, error) { +func treeEntries(c *catfile.Batch, revision, path string, rootOid string, recursive bool) ([]*gitalypb.TreeEntry, error) { if path == "." { path = "" } @@ -106,11 +106,11 @@ func treeEntries(c *catfile.Batch, revision, path string, rootOid string, recurs return entries, nil } - var orderedEntries []*pb.TreeEntry + var orderedEntries []*gitalypb.TreeEntry for _, entry := range entries { orderedEntries = append(orderedEntries, entry) - if entry.Type == pb.TreeEntry_TREE { + if entry.Type == gitalypb.TreeEntry_TREE { subentries, err := treeEntries(c, revision, string(entry.Path), rootOid, true) if err != nil { return nil, err @@ -124,7 +124,7 @@ func treeEntries(c *catfile.Batch, revision, path string, rootOid string, recurs } // TreeEntryForRevisionAndPath returns a TreeEntry struct for the object present at the revision/path pair. -func TreeEntryForRevisionAndPath(c *catfile.Batch, revision, path string) (*pb.TreeEntry, error) { +func TreeEntryForRevisionAndPath(c *catfile.Batch, revision, path string) (*gitalypb.TreeEntry, error) { entries, err := treeEntries(c, revision, pathPkg.Dir(path), "", false) if err != nil { return nil, err diff --git a/internal/service/commit/tree_entries_test.go b/internal/service/commit/tree_entries_test.go index 209603cd7..f8d310019 100644 --- a/internal/service/commit/tree_entries_test.go +++ b/internal/service/commit/tree_entries_test.go @@ -9,7 +9,7 @@ import ( "golang.org/x/net/context" "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -33,13 +33,13 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rootEntries := []*pb.TreeEntry{ + rootEntries := []*gitalypb.TreeEntry{ { Oid: "fd90a3d2d21d6b4f9bec2c33fb7f49780c55f0d2", RootOid: rootOid, Path: []byte(".DS_Store"), FlatPath: []byte(".DS_Store"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -48,7 +48,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte(".gitignore"), FlatPath: []byte(".gitignore"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -57,7 +57,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte(".gitmodules"), FlatPath: []byte(".gitmodules"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -66,7 +66,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("CHANGELOG"), FlatPath: []byte("CHANGELOG"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -75,7 +75,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("CONTRIBUTING.md"), FlatPath: []byte("CONTRIBUTING.md"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -84,7 +84,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("LICENSE"), FlatPath: []byte("LICENSE"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -93,7 +93,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("MAINTENANCE.md"), FlatPath: []byte("MAINTENANCE.md"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -102,7 +102,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("PROCESS.md"), FlatPath: []byte("PROCESS.md"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -111,7 +111,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("README.md"), FlatPath: []byte("README.md"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -120,7 +120,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("VERSION"), FlatPath: []byte("VERSION"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -129,7 +129,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("encoding"), FlatPath: []byte("encoding"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -138,7 +138,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files"), FlatPath: []byte("files"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -147,7 +147,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("level-0"), FlatPath: []byte("level-0"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -156,18 +156,18 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("six"), FlatPath: []byte("six"), - Type: pb.TreeEntry_COMMIT, + Type: gitalypb.TreeEntry_COMMIT, Mode: 0160000, CommitOid: commitID, }, } - filesDirEntries := []*pb.TreeEntry{ + filesDirEntries := []*gitalypb.TreeEntry{ { Oid: "60d7a906c2fd9e4509aeb1187b98d0ea7ce827c9", RootOid: rootOid, Path: []byte("files/.DS_Store"), FlatPath: []byte("files/.DS_Store"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -176,7 +176,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files/flat"), FlatPath: []byte("files/flat/path/correct"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -185,7 +185,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files/html"), FlatPath: []byte("files/html"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -194,7 +194,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files/images"), FlatPath: []byte("files/images"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -203,7 +203,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files/js"), FlatPath: []byte("files/js"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -212,7 +212,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files/markdown"), FlatPath: []byte("files/markdown"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -221,18 +221,18 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { RootOid: rootOid, Path: []byte("files/ruby"), FlatPath: []byte("files/ruby"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, } - recursiveEntries := []*pb.TreeEntry{ + recursiveEntries := []*gitalypb.TreeEntry{ { Oid: "d564d0bc3dd917926892c55e3706cc116d5b165e", RootOid: rootOid, Path: []byte("level-0/level-1-1"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -240,7 +240,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { Oid: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", RootOid: rootOid, Path: []byte("level-0/level-1-1/.gitkeep"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -248,7 +248,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { Oid: "02366a40d0cde8191e43a8c5b821176c0668522c", RootOid: rootOid, Path: []byte("level-0/level-1-2"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -256,7 +256,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { Oid: "d564d0bc3dd917926892c55e3706cc116d5b165e", RootOid: rootOid, Path: []byte("level-0/level-1-2/level-2"), - Type: pb.TreeEntry_TREE, + Type: gitalypb.TreeEntry_TREE, Mode: 040000, CommitOid: commitID, }, @@ -264,7 +264,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { Oid: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", RootOid: rootOid, Path: []byte("level-0/level-1-2/level-2/.gitkeep"), - Type: pb.TreeEntry_BLOB, + Type: gitalypb.TreeEntry_BLOB, Mode: 0100644, CommitOid: commitID, }, @@ -275,7 +275,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { revision []byte path []byte recursive bool - entries []*pb.TreeEntry + entries []*gitalypb.TreeEntry }{ { description: "with root path", @@ -312,7 +312,7 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.description, func(t *testing.T) { - request := &pb.GetTreeEntriesRequest{ + request := &gitalypb.GetTreeEntriesRequest{ Repository: testRepo, Revision: testCase.revision, Path: testCase.path, @@ -332,8 +332,8 @@ func TestSuccessfulGetTreeEntries(t *testing.T) { } } -func getTreeEntriesFromTreeEntryClient(t *testing.T, client pb.CommitService_GetTreeEntriesClient) []*pb.TreeEntry { - var entries []*pb.TreeEntry +func getTreeEntriesFromTreeEntryClient(t *testing.T, client gitalypb.CommitService_GetTreeEntriesClient) []*gitalypb.TreeEntry { + var entries []*gitalypb.TreeEntry for { resp, err := client.Recv() if err == io.EOF { @@ -360,11 +360,11 @@ func TestFailedGetTreeEntriesRequestDueToValidationError(t *testing.T) { revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") path := []byte("a/b/c") - rpcRequests := []pb.GetTreeEntriesRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision, Path: path}, // Repository doesn't exist - {Repository: nil, Revision: revision, Path: path}, // Repository is nil - {Repository: testRepo, Revision: nil, Path: path}, // Revision is empty - {Repository: testRepo, Revision: revision}, // Path is empty + rpcRequests := []gitalypb.GetTreeEntriesRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision, Path: path}, // Repository doesn't exist + {Repository: nil, Revision: revision, Path: path}, // Repository is nil + {Repository: testRepo, Revision: nil, Path: path}, // Revision is empty + {Repository: testRepo, Revision: revision}, // Path is empty } for _, rpcRequest := range rpcRequests { @@ -382,7 +382,7 @@ func TestFailedGetTreeEntriesRequestDueToValidationError(t *testing.T) { } } -func drainTreeEntriesResponse(c pb.CommitService_GetTreeEntriesClient) error { +func drainTreeEntriesResponse(c gitalypb.CommitService_GetTreeEntriesClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/tree_entry.go b/internal/service/commit/tree_entry.go index 559c76390..cacfe7c26 100644 --- a/internal/service/commit/tree_entry.go +++ b/internal/service/commit/tree_entry.go @@ -5,29 +5,28 @@ import ( "io" "strings" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func sendTreeEntry(stream pb.Commit_TreeEntryServer, c *catfile.Batch, revision, path string, limit int64) error { +func sendTreeEntry(stream gitalypb.Commit_TreeEntryServer, c *catfile.Batch, revision, path string, limit int64) error { treeEntry, err := TreeEntryForRevisionAndPath(c, revision, path) if err != nil { return err } if treeEntry == nil || len(treeEntry.Oid) == 0 { - return helper.DecorateError(codes.Unavailable, stream.Send(&pb.TreeEntryResponse{})) + return helper.DecorateError(codes.Unavailable, stream.Send(&gitalypb.TreeEntryResponse{})) } - if treeEntry.Type == pb.TreeEntry_COMMIT { - response := &pb.TreeEntryResponse{ - Type: pb.TreeEntryResponse_COMMIT, + if treeEntry.Type == gitalypb.TreeEntry_COMMIT { + response := &gitalypb.TreeEntryResponse{ + Type: gitalypb.TreeEntryResponse_COMMIT, Mode: treeEntry.Mode, Oid: treeEntry.Oid, } @@ -38,14 +37,14 @@ func sendTreeEntry(stream pb.Commit_TreeEntryServer, c *catfile.Batch, revision, return nil } - if treeEntry.Type == pb.TreeEntry_TREE { + if treeEntry.Type == gitalypb.TreeEntry_TREE { treeInfo, err := c.Info(treeEntry.Oid) if err != nil { return err } - response := &pb.TreeEntryResponse{ - Type: pb.TreeEntryResponse_TREE, + response := &gitalypb.TreeEntryResponse{ + Type: gitalypb.TreeEntryResponse_TREE, Oid: treeEntry.Oid, Size: treeInfo.Size, Mode: treeEntry.Mode, @@ -71,8 +70,8 @@ func sendTreeEntry(stream pb.Commit_TreeEntryServer, c *catfile.Batch, revision, dataLength = limit } - response := &pb.TreeEntryResponse{ - Type: pb.TreeEntryResponse_BLOB, + response := &gitalypb.TreeEntryResponse{ + Type: gitalypb.TreeEntryResponse_BLOB, Oid: objectInfo.Oid, Size: objectInfo.Size, Mode: treeEntry.Mode, @@ -94,7 +93,7 @@ func sendTreeEntry(stream pb.Commit_TreeEntryServer, c *catfile.Batch, revision, } // Use a new response so we don't send other fields (Size, ...) over and over - response = &pb.TreeEntryResponse{} + response = &gitalypb.TreeEntryResponse{} return nil }) @@ -103,7 +102,7 @@ func sendTreeEntry(stream pb.Commit_TreeEntryServer, c *catfile.Batch, revision, return err } -func (s *server) TreeEntry(in *pb.TreeEntryRequest, stream pb.CommitService_TreeEntryServer) error { +func (s *server) TreeEntry(in *gitalypb.TreeEntryRequest, stream gitalypb.CommitService_TreeEntryServer) error { if err := validateRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "TreeEntry: %v", err) } @@ -123,7 +122,7 @@ func (s *server) TreeEntry(in *pb.TreeEntryRequest, stream pb.CommitService_Tree return sendTreeEntry(stream, c, string(in.GetRevision()), requestPath, in.GetLimit()) } -func validateRequest(in *pb.TreeEntryRequest) error { +func validateRequest(in *gitalypb.TreeEntryRequest) error { if len(in.GetRevision()) == 0 { return fmt.Errorf("empty Revision") } diff --git a/internal/service/commit/tree_entry_test.go b/internal/service/commit/tree_entry_test.go index 516d231c3..9d221dd82 100644 --- a/internal/service/commit/tree_entry_test.go +++ b/internal/service/commit/tree_entry_test.go @@ -6,17 +6,16 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" ) type treeEntry struct { oid string - objectType pb.TreeEntryResponse_ObjectType + objectType gitalypb.TreeEntryResponse_ObjectType data []byte mode int32 size int64 @@ -42,7 +41,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { revision: []byte("913c66a37b4a45b9769037c55c2d238bd0942d2e"), path: []byte("MAINTENANCE.md"), expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_BLOB, + objectType: gitalypb.TreeEntryResponse_BLOB, oid: "95d9f0a5e7bb054e9dd3975589b8dfc689e20e88", size: 1367, mode: 0100644, @@ -54,7 +53,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { path: []byte("MAINTENANCE.md"), limit: 40 * 1024, expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_BLOB, + objectType: gitalypb.TreeEntryResponse_BLOB, oid: "95d9f0a5e7bb054e9dd3975589b8dfc689e20e88", size: 1367, mode: 0100644, @@ -65,7 +64,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { revision: []byte("38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e"), path: []byte("with space/README.md"), expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_BLOB, + objectType: gitalypb.TreeEntryResponse_BLOB, oid: "8c3014aceae45386c3c026a7ea4a1f68660d51d6", size: 36, mode: 0100644, @@ -77,7 +76,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { path: []byte("gitaly/file-with-multiple-chunks"), limit: 30 * 1024, expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_BLOB, + objectType: gitalypb.TreeEntryResponse_BLOB, oid: "1c69c4d2a65ad05c24ac3b6780b5748b97ffd3aa", size: 42220, mode: 0100644, @@ -98,7 +97,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { revision: []byte("e63f41fe459e62e1228fcef60d7189127aeba95a"), path: []byte("gitlab-grack"), expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_COMMIT, + objectType: gitalypb.TreeEntryResponse_COMMIT, oid: "645f6c4c82fd3f5e06f67134450a570b795e55a6", mode: 0160000, }, @@ -107,7 +106,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { revision: []byte("c347ca2e140aa667b968e51ed0ffe055501fe4f4"), path: []byte("files/js"), expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_TREE, + objectType: gitalypb.TreeEntryResponse_TREE, oid: "31405c5ddef582c5a9b7a85230413ff90e2fe720", size: 83, mode: 040000, @@ -117,7 +116,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { revision: []byte("c347ca2e140aa667b968e51ed0ffe055501fe4f4"), path: []byte("files/js/"), expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_TREE, + objectType: gitalypb.TreeEntryResponse_TREE, oid: "31405c5ddef582c5a9b7a85230413ff90e2fe720", size: 83, mode: 040000, @@ -127,7 +126,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { revision: []byte("b83d6e391c22777fca1ed3012fce84f633d7fed0"), path: []byte("foo/bar/.gitkeep"), expectedTreeEntry: treeEntry{ - objectType: pb.TreeEntryResponse_BLOB, + objectType: gitalypb.TreeEntryResponse_BLOB, oid: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", size: 0, mode: 0100644, @@ -143,7 +142,7 @@ func TestSuccessfulTreeEntry(t *testing.T) { for _, testCase := range testCases { t.Run(fmt.Sprintf("test case: revision=%q path=%q", testCase.revision, testCase.path), func(t *testing.T) { - request := &pb.TreeEntryRequest{ + request := &gitalypb.TreeEntryRequest{ Repository: testRepo, Revision: testCase.revision, Path: testCase.path, @@ -175,11 +174,11 @@ func TestFailedTreeEntryRequestDueToValidationError(t *testing.T) { revision := []byte("d42783470dc29fde2cf459eb3199ee1d7e3f3a72") path := []byte("a/b/c") - rpcRequests := []pb.TreeEntryRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision, Path: path}, // Repository doesn't exist - {Repository: nil, Revision: revision, Path: path}, // Repository is nil - {Repository: testRepo, Revision: nil, Path: path}, // Revision is empty - {Repository: testRepo, Revision: revision}, // Path is empty + rpcRequests := []gitalypb.TreeEntryRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, Revision: revision, Path: path}, // Repository doesn't exist + {Repository: nil, Revision: revision, Path: path}, // Repository is nil + {Repository: testRepo, Revision: nil, Path: path}, // Revision is empty + {Repository: testRepo, Revision: revision}, // Path is empty } for _, rpcRequest := range rpcRequests { @@ -198,7 +197,7 @@ func TestFailedTreeEntryRequestDueToValidationError(t *testing.T) { } } -func getTreeEntryFromTreeEntryClient(t *testing.T, client pb.Commit_TreeEntryClient) *treeEntry { +func getTreeEntryFromTreeEntryClient(t *testing.T, client gitalypb.Commit_TreeEntryClient) *treeEntry { fetchedTreeEntry := &treeEntry{} firstResponseReceived := false @@ -223,7 +222,7 @@ func getTreeEntryFromTreeEntryClient(t *testing.T, client pb.Commit_TreeEntryCli return fetchedTreeEntry } -func assertExactReceivedTreeEntry(t *testing.T, client pb.Commit_TreeEntryClient, expectedTreeEntry *treeEntry) { +func assertExactReceivedTreeEntry(t *testing.T, client gitalypb.Commit_TreeEntryClient, expectedTreeEntry *treeEntry) { fetchedTreeEntry := getTreeEntryFromTreeEntryClient(t, client) if fetchedTreeEntry.oid != expectedTreeEntry.oid { @@ -247,7 +246,7 @@ func assertExactReceivedTreeEntry(t *testing.T, client pb.Commit_TreeEntryClient } } -func drainTreeEntryResponse(c pb.Commit_TreeEntryClient) error { +func drainTreeEntryResponse(c gitalypb.Commit_TreeEntryClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/commit/util.go b/internal/service/commit/util.go index 0512136e4..93811d0f3 100644 --- a/internal/service/commit/util.go +++ b/internal/service/commit/util.go @@ -5,11 +5,11 @@ import ( "path" "strconv" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) -func newTreeEntry(commitOid, rootOid, rootPath string, filename, oidBytes, modeBytes []byte) (*pb.TreeEntry, error) { - var objectType pb.TreeEntry_EntryType +func newTreeEntry(commitOid, rootOid, rootPath string, filename, oidBytes, modeBytes []byte) (*gitalypb.TreeEntry, error) { + var objectType gitalypb.TreeEntry_EntryType mode, err := strconv.ParseInt(string(modeBytes), 8, 32) if err != nil { @@ -21,14 +21,14 @@ func newTreeEntry(commitOid, rootOid, rootPath string, filename, oidBytes, modeB // Based on https://github.com/git/git/blob/v2.13.1/builtin/ls-tree.c#L67-L87 switch mode & 0xf000 { case 0160000: - objectType = pb.TreeEntry_COMMIT + objectType = gitalypb.TreeEntry_COMMIT case 040000: - objectType = pb.TreeEntry_TREE + objectType = gitalypb.TreeEntry_TREE default: - objectType = pb.TreeEntry_BLOB + objectType = gitalypb.TreeEntry_BLOB } - return &pb.TreeEntry{ + return &gitalypb.TreeEntry{ CommitOid: commitOid, RootOid: rootOid, Oid: oid, diff --git a/internal/service/conflicts/list_conflict_files.go b/internal/service/conflicts/list_conflict_files.go index c9b79a7d5..0664feeb8 100644 --- a/internal/service/conflicts/list_conflict_files.go +++ b/internal/service/conflicts/list_conflict_files.go @@ -3,13 +3,13 @@ package conflicts import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) ListConflictFiles(in *pb.ListConflictFilesRequest, stream pb.ConflictsService_ListConflictFilesServer) error { +func (s *server) ListConflictFiles(in *gitalypb.ListConflictFilesRequest, stream gitalypb.ConflictsService_ListConflictFilesServer) error { ctx := stream.Context() if err := validateListConflictFilesRequest(in); err != nil { @@ -42,7 +42,7 @@ func (s *server) ListConflictFiles(in *pb.ListConflictFilesRequest, stream pb.Co }) } -func validateListConflictFilesRequest(in *pb.ListConflictFilesRequest) error { +func validateListConflictFilesRequest(in *gitalypb.ListConflictFilesRequest) error { if in.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/conflicts/list_conflict_files_test.go b/internal/service/conflicts/list_conflict_files_test.go index f342abe61..d4fef5096 100644 --- a/internal/service/conflicts/list_conflict_files_test.go +++ b/internal/service/conflicts/list_conflict_files_test.go @@ -8,12 +8,12 @@ import ( "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) type conflictFile struct { - header *pb.ConflictFileHeader + header *gitalypb.ConflictFileHeader content []byte } @@ -52,7 +52,7 @@ end ctx, cancel := testhelper.Context() defer cancel() - request := &pb.ListConflictFilesRequest{ + request := &gitalypb.ListConflictFilesRequest{ Repository: testRepo, OurCommitOid: ourCommitOid, TheirCommitOid: theirCommitOid, @@ -65,7 +65,7 @@ end expectedFiles := []*conflictFile{ { - header: &pb.ConflictFileHeader{ + header: &gitalypb.ConflictFileHeader{ Repository: testRepo, CommitOid: ourCommitOid, OurMode: int32(0100644), @@ -75,7 +75,7 @@ end content: []byte(conflictContent1), }, { - header: &pb.ConflictFileHeader{ + header: &gitalypb.ConflictFileHeader{ Repository: testRepo, CommitOid: ourCommitOid, OurMode: int32(0100644), @@ -140,7 +140,7 @@ func TestListConflictFilesFailedPrecondition(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - request := &pb.ListConflictFilesRequest{ + request := &gitalypb.ListConflictFilesRequest{ Repository: testRepo, OurCommitOid: tc.ourCommitOid, TheirCommitOid: tc.theirCommitOid, @@ -171,12 +171,12 @@ func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { testCases := []struct { desc string - request *pb.ListConflictFilesRequest + request *gitalypb.ListConflictFilesRequest code codes.Code }{ { desc: "empty repo", - request: &pb.ListConflictFilesRequest{ + request: &gitalypb.ListConflictFilesRequest{ Repository: nil, OurCommitOid: ourCommitOid, TheirCommitOid: theirCommitOid, @@ -185,7 +185,7 @@ func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { }, { desc: "empty OurCommitId field", - request: &pb.ListConflictFilesRequest{ + request: &gitalypb.ListConflictFilesRequest{ Repository: testRepo, OurCommitOid: "", TheirCommitOid: theirCommitOid, @@ -194,7 +194,7 @@ func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { }, { desc: "empty TheirCommitId field", - request: &pb.ListConflictFilesRequest{ + request: &gitalypb.ListConflictFilesRequest{ Repository: testRepo, OurCommitOid: ourCommitOid, TheirCommitOid: "", @@ -214,7 +214,7 @@ func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) { } } -func getConflictFiles(t *testing.T, c pb.ConflictsService_ListConflictFilesClient) []*conflictFile { +func getConflictFiles(t *testing.T, c gitalypb.ConflictsService_ListConflictFilesClient) []*conflictFile { files := []*conflictFile{} var currentFile *conflictFile @@ -247,7 +247,7 @@ func getConflictFiles(t *testing.T, c pb.ConflictsService_ListConflictFilesClien return files } -func drainListConflictFilesResponse(c pb.ConflictsService_ListConflictFilesClient) error { +func drainListConflictFilesResponse(c gitalypb.ConflictsService_ListConflictFilesClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/conflicts/resolve_conflicts.go b/internal/service/conflicts/resolve_conflicts.go index d54aedf90..72416953a 100644 --- a/internal/service/conflicts/resolve_conflicts.go +++ b/internal/service/conflicts/resolve_conflicts.go @@ -3,13 +3,13 @@ package conflicts import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) ResolveConflicts(stream pb.ConflictsService_ResolveConflictsServer) error { +func (s *server) ResolveConflicts(stream gitalypb.ConflictsService_ResolveConflictsServer) error { firstRequest, err := stream.Recv() if err != nil { return err @@ -64,7 +64,7 @@ func (s *server) ResolveConflicts(stream pb.ConflictsService_ResolveConflictsSer return stream.SendAndClose(response) } -func validateResolveConflictsHeader(header *pb.ResolveConflictsRequestHeader) error { +func validateResolveConflictsHeader(header *gitalypb.ResolveConflictsRequestHeader) error { if header.GetOurCommitOid() == "" { return fmt.Errorf("empty OurCommitOid") } diff --git a/internal/service/conflicts/resolve_conflicts_test.go b/internal/service/conflicts/resolve_conflicts_test.go index b871a48eb..02c593c68 100644 --- a/internal/service/conflicts/resolve_conflicts_test.go +++ b/internal/service/conflicts/resolve_conflicts_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" serverPkg "gitlab.com/gitlab-org/gitaly/internal/server" "gitlab.com/gitlab-org/gitaly/internal/service/conflicts" @@ -17,7 +17,7 @@ import ( ) var ( - user = &pb.User{ + user = &gitalypb.User{ Name: []byte("John Doe"), Email: []byte("johndoe@gitlab.com"), GlId: "user-1", @@ -63,9 +63,9 @@ func TestSuccessfulResolveConflictsRequest(t *testing.T) { require.NoError(t, err) sourceBranch := "conflict-resolvable" - headerRequest := &pb.ResolveConflictsRequest{ - ResolveConflictsRequestPayload: &pb.ResolveConflictsRequest_Header{ - Header: &pb.ResolveConflictsRequestHeader{ + headerRequest := &gitalypb.ResolveConflictsRequest{ + ResolveConflictsRequestPayload: &gitalypb.ResolveConflictsRequest_Header{ + Header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, TargetRepository: testRepo, CommitMessage: []byte(conflictResolutionCommitMessage), @@ -77,13 +77,13 @@ func TestSuccessfulResolveConflictsRequest(t *testing.T) { }, }, } - filesRequest1 := &pb.ResolveConflictsRequest{ - ResolveConflictsRequestPayload: &pb.ResolveConflictsRequest_FilesJson{ + filesRequest1 := &gitalypb.ResolveConflictsRequest{ + ResolveConflictsRequestPayload: &gitalypb.ResolveConflictsRequest_FilesJson{ FilesJson: filesJSON[:50], }, } - filesRequest2 := &pb.ResolveConflictsRequest{ - ResolveConflictsRequestPayload: &pb.ResolveConflictsRequest_FilesJson{ + filesRequest2 := &gitalypb.ResolveConflictsRequest{ + ResolveConflictsRequestPayload: &gitalypb.ResolveConflictsRequest_FilesJson{ FilesJson: filesJSON[50:], }, } @@ -140,9 +140,9 @@ func TestFailedResolveConflictsRequestDueToResolutionError(t *testing.T) { filesJSON, err := json.Marshal(files) require.NoError(t, err) - headerRequest := &pb.ResolveConflictsRequest{ - ResolveConflictsRequestPayload: &pb.ResolveConflictsRequest_Header{ - Header: &pb.ResolveConflictsRequestHeader{ + headerRequest := &gitalypb.ResolveConflictsRequest{ + ResolveConflictsRequestPayload: &gitalypb.ResolveConflictsRequest_Header{ + Header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, TargetRepository: testRepo, CommitMessage: []byte(conflictResolutionCommitMessage), @@ -154,8 +154,8 @@ func TestFailedResolveConflictsRequestDueToResolutionError(t *testing.T) { }, }, } - filesRequest := &pb.ResolveConflictsRequest{ - ResolveConflictsRequestPayload: &pb.ResolveConflictsRequest_FilesJson{ + filesRequest := &gitalypb.ResolveConflictsRequest{ + ResolveConflictsRequestPayload: &gitalypb.ResolveConflictsRequest_FilesJson{ FilesJson: filesJSON, }, } @@ -189,12 +189,12 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { testCases := []struct { desc string - header *pb.ResolveConflictsRequestHeader + header *gitalypb.ResolveConflictsRequestHeader code codes.Code }{ { desc: "empty repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: nil, OurCommitOid: ourCommitOid, TargetRepository: testRepo, @@ -207,7 +207,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { }, { desc: "empty target repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, OurCommitOid: ourCommitOid, TargetRepository: nil, @@ -220,7 +220,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { }, { desc: "empty OurCommitId repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, OurCommitOid: "", TargetRepository: testRepo, @@ -233,7 +233,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { }, { desc: "empty TheirCommitId repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, OurCommitOid: ourCommitOid, TargetRepository: testRepo, @@ -246,7 +246,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { }, { desc: "empty CommitMessage repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, OurCommitOid: ourCommitOid, TargetRepository: testRepo, @@ -259,7 +259,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { }, { desc: "empty SourceBranch repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, OurCommitOid: ourCommitOid, TargetRepository: testRepo, @@ -272,7 +272,7 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { }, { desc: "empty TargetBranch repo", - header: &pb.ResolveConflictsRequestHeader{ + header: &gitalypb.ResolveConflictsRequestHeader{ Repository: testRepo, OurCommitOid: ourCommitOid, TargetRepository: testRepo, @@ -294,8 +294,8 @@ func TestFailedResolveConflictsRequestDueToValidation(t *testing.T) { stream, err := client.ResolveConflicts(ctx) require.NoError(t, err) - headerRequest := &pb.ResolveConflictsRequest{ - ResolveConflictsRequestPayload: &pb.ResolveConflictsRequest_Header{ + headerRequest := &gitalypb.ResolveConflictsRequest{ + ResolveConflictsRequestPayload: &gitalypb.ResolveConflictsRequest_Header{ Header: testCase.header, }, } diff --git a/internal/service/conflicts/server.go b/internal/service/conflicts/server.go index bba67d6d9..aa000398c 100644 --- a/internal/service/conflicts/server.go +++ b/internal/service/conflicts/server.go @@ -1,7 +1,7 @@ package conflicts import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) @@ -10,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a grpc ConflictsServer -func NewServer(rs *rubyserver.Server) pb.ConflictsServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.ConflictsServiceServer { return &server{rs} } diff --git a/internal/service/conflicts/testhelper_test.go b/internal/service/conflicts/testhelper_test.go index 92651f3d6..947473da5 100644 --- a/internal/service/conflicts/testhelper_test.go +++ b/internal/service/conflicts/testhelper_test.go @@ -11,8 +11,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/reflection" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -47,7 +46,7 @@ func runConflictsServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterConflictsServiceServer(server, NewServer(RubyServer)) + gitalypb.RegisterConflictsServiceServer(server, NewServer(RubyServer)) reflection.Register(server) go server.Serve(listener) @@ -55,7 +54,7 @@ func runConflictsServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func NewConflictsClient(t *testing.T, serverSocketPath string) (pb.ConflictsServiceClient, *grpc.ClientConn) { +func NewConflictsClient(t *testing.T, serverSocketPath string) (gitalypb.ConflictsServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -68,5 +67,5 @@ func NewConflictsClient(t *testing.T, serverSocketPath string) (pb.ConflictsServ t.Fatal(err) } - return pb.NewConflictsServiceClient(conn), conn + return gitalypb.NewConflictsServiceClient(conn), conn } diff --git a/internal/service/diff/commit.go b/internal/service/diff/commit.go index cbf4aeeb2..5037d47db 100644 --- a/internal/service/diff/commit.go +++ b/internal/service/diff/commit.go @@ -6,7 +6,7 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/diff" "gitlab.com/gitlab-org/gitaly/internal/git" "google.golang.org/grpc/codes" @@ -18,7 +18,7 @@ type requestWithLeftRightCommitIds interface { GetRightCommitId() string } -func (s *server) CommitDiff(in *pb.CommitDiffRequest, stream pb.DiffService_CommitDiffServer) error { +func (s *server) CommitDiff(in *gitalypb.CommitDiffRequest, stream gitalypb.DiffService_CommitDiffServer) error { grpc_logrus.Extract(stream.Context()).WithFields(log.Fields{ "LeftCommitId": in.LeftCommitId, "RightCommitId": in.RightCommitId, @@ -68,7 +68,7 @@ func (s *server) CommitDiff(in *pb.CommitDiffRequest, stream pb.DiffService_Comm limits.SafeMaxBytes = int(in.SafeMaxBytes) return eachDiff(stream.Context(), "CommitDiff", in.Repository, cmdArgs, limits, func(diff *diff.Diff) error { - response := &pb.CommitDiffResponse{ + response := &gitalypb.CommitDiffResponse{ FromPath: diff.FromPath, ToPath: diff.ToPath, FromId: diff.FromID, @@ -106,7 +106,7 @@ func (s *server) CommitDiff(in *pb.CommitDiffRequest, stream pb.DiffService_Comm } // Use a new response so we don't send other fields (FromPath, ...) over and over - response = &pb.CommitDiffResponse{} + response = &gitalypb.CommitDiffResponse{} } } @@ -114,7 +114,7 @@ func (s *server) CommitDiff(in *pb.CommitDiffRequest, stream pb.DiffService_Comm }) } -func (s *server) CommitDelta(in *pb.CommitDeltaRequest, stream pb.DiffService_CommitDeltaServer) error { +func (s *server) CommitDelta(in *gitalypb.CommitDeltaRequest, stream gitalypb.DiffService_CommitDeltaServer) error { grpc_logrus.Extract(stream.Context()).WithFields(log.Fields{ "LeftCommitId": in.LeftCommitId, "RightCommitId": in.RightCommitId, @@ -145,7 +145,7 @@ func (s *server) CommitDelta(in *pb.CommitDeltaRequest, stream pb.DiffService_Co } } - var batch []*pb.CommitDelta + var batch []*gitalypb.CommitDelta var batchSize int flushFunc := func() error { @@ -153,7 +153,7 @@ func (s *server) CommitDelta(in *pb.CommitDeltaRequest, stream pb.DiffService_Co return nil } - if err := stream.Send(&pb.CommitDeltaResponse{Deltas: batch}); err != nil { + if err := stream.Send(&gitalypb.CommitDeltaResponse{Deltas: batch}); err != nil { return status.Errorf(codes.Unavailable, "CommitDelta: send: %v", err) } @@ -161,7 +161,7 @@ func (s *server) CommitDelta(in *pb.CommitDeltaRequest, stream pb.DiffService_Co } err := eachDiff(stream.Context(), "CommitDelta", in.Repository, cmdArgs, diff.Limits{}, func(diff *diff.Diff) error { - delta := &pb.CommitDelta{ + delta := &gitalypb.CommitDelta{ FromPath: diff.FromPath, ToPath: diff.ToPath, FromId: diff.FromID, @@ -203,7 +203,7 @@ func validateRequest(in requestWithLeftRightCommitIds) error { return nil } -func eachDiff(ctx context.Context, rpc string, repo *pb.Repository, cmdArgs []string, limits diff.Limits, callback func(*diff.Diff) error) error { +func eachDiff(ctx context.Context, rpc string, repo *gitalypb.Repository, cmdArgs []string, limits diff.Limits, callback func(*diff.Diff) error) error { cmd, err := git.Command(ctx, repo, cmdArgs...) if err != nil { if _, ok := status.FromError(err); ok { diff --git a/internal/service/diff/commit_test.go b/internal/service/diff/commit_test.go index 13ac79ffe..6124ad6c8 100644 --- a/internal/service/diff/commit_test.go +++ b/internal/service/diff/commit_test.go @@ -6,7 +6,7 @@ import ( "io" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/diff" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -27,7 +27,7 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) { rightCommit := "ab2c9622c02288a2bbaaf35d96088cfdff31d9d9" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.CommitDiffRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit, IgnoreWhitespaceChange: false} + rpcRequest := &gitalypb.CommitDiffRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit, IgnoreWhitespaceChange: false} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -191,7 +191,7 @@ func TestSuccessfulCommitDiffRequestWithPaths(t *testing.T) { rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.CommitDiffRequest{ + rpcRequest := &gitalypb.CommitDiffRequest{ Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit, @@ -269,7 +269,7 @@ func TestSuccessfulCommitDiffRequestWithTypeChangeDiff(t *testing.T) { rightCommit := "184a47d38677e2e439964859b877ae9bc424ab11" leftCommit := "80d56eb72ba5d77fd8af857eced17a7d0640cb82" - rpcRequest := &pb.CommitDiffRequest{ + rpcRequest := &gitalypb.CommitDiffRequest{ Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit, @@ -402,7 +402,7 @@ func TestSuccessfulCommitDiffRequestWithIgnoreWhitespaceChange(t *testing.T) { for _, entry := range pathsAndDiffs { t.Run(entry.desc, func(t *testing.T) { - rpcRequest := &pb.CommitDiffRequest{ + rpcRequest := &gitalypb.CommitDiffRequest{ Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit, @@ -442,12 +442,12 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { requestsAndResults := []struct { desc string - request pb.CommitDiffRequest + request gitalypb.CommitDiffRequest result []diffAttributes }{ { desc: "no enforcement", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: false, }, result: []diffAttributes{ @@ -460,7 +460,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "max file count enforcement", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, MaxFiles: 3, MaxLines: 1000, @@ -476,7 +476,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "max line count enforcement", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, MaxFiles: 5, MaxLines: 90, @@ -491,7 +491,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "max byte count enforcement", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, MaxFiles: 5, MaxLines: 1000, @@ -508,7 +508,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "no collapse", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, CollapseDiffs: false, MaxFiles: 3, @@ -528,7 +528,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "set as too large when exceeding single patch limit", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, CollapseDiffs: false, MaxFiles: 5, @@ -549,7 +549,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "collapse after safe max file count is exceeded", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, CollapseDiffs: true, MaxFiles: 3, @@ -569,7 +569,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "collapse after safe max line count is exceeded", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, CollapseDiffs: true, MaxFiles: 5, @@ -590,7 +590,7 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) { }, { desc: "collapse after safe max byte count is exceeded", - request: pb.CommitDiffRequest{ + request: gitalypb.CommitDiffRequest{ EnforceLimits: true, CollapseDiffs: true, MaxFiles: 4, @@ -658,11 +658,11 @@ func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) { rightCommit := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72" leftCommit := rightCommit + "~" // Parent of rightCommit - rpcRequests := []pb.CommitDiffRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository doesn't exist - {Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository is nil - {Repository: testRepo, RightCommitId: "", LeftCommitId: leftCommit}, // RightCommitId is empty - {Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: ""}, // LeftCommitId is empty + rpcRequests := []gitalypb.CommitDiffRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository doesn't exist + {Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository is nil + {Repository: testRepo, RightCommitId: "", LeftCommitId: leftCommit}, // RightCommitId is empty + {Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: ""}, // LeftCommitId is empty } for _, rpcRequest := range rpcRequests { @@ -693,7 +693,7 @@ func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) { nonExistentCommitID := "deadfacedeadfacedeadfacedeadfacedeadface" leftCommit := nonExistentCommitID + "~" // Parent of rightCommit - rpcRequest := &pb.CommitDiffRequest{Repository: testRepo, RightCommitId: nonExistentCommitID, LeftCommitId: leftCommit} + rpcRequest := &gitalypb.CommitDiffRequest{Repository: testRepo, RightCommitId: nonExistentCommitID, LeftCommitId: leftCommit} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -718,7 +718,7 @@ func TestSuccessfulCommitDeltaRequest(t *testing.T) { rightCommit := "742518b2be68fc750bb4c357c0df821a88113286" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.CommitDeltaRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} + rpcRequest := &gitalypb.CommitDeltaRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -841,7 +841,7 @@ func TestSuccessfulCommitDeltaRequestWithPaths(t *testing.T) { rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.CommitDeltaRequest{ + rpcRequest := &gitalypb.CommitDeltaRequest{ Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit, @@ -911,11 +911,11 @@ func TestFailedCommitDeltaRequestDueToValidationError(t *testing.T) { rightCommit := "d42783470dc29fde2cf459eb3199ee1d7e3f3a72" leftCommit := rightCommit + "~" // Parent of rightCommit - rpcRequests := []pb.CommitDeltaRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository doesn't exist - {Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository is nil - {Repository: testRepo, RightCommitId: "", LeftCommitId: leftCommit}, // RightCommitId is empty - {Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: ""}, // LeftCommitId is empty + rpcRequests := []gitalypb.CommitDeltaRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository doesn't exist + {Repository: nil, RightCommitId: rightCommit, LeftCommitId: leftCommit}, // Repository is nil + {Repository: testRepo, RightCommitId: "", LeftCommitId: leftCommit}, // RightCommitId is empty + {Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: ""}, // LeftCommitId is empty } for _, rpcRequest := range rpcRequests { @@ -946,7 +946,7 @@ func TestFailedCommitDeltaRequestWithNonExistentCommit(t *testing.T) { nonExistentCommitID := "deadfacedeadfacedeadfacedeadfacedeadface" leftCommit := nonExistentCommitID + "~" // Parent of rightCommit - rpcRequest := &pb.CommitDeltaRequest{Repository: testRepo, RightCommitId: nonExistentCommitID, LeftCommitId: leftCommit} + rpcRequest := &gitalypb.CommitDeltaRequest{Repository: testRepo, RightCommitId: nonExistentCommitID, LeftCommitId: leftCommit} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -959,7 +959,7 @@ func TestFailedCommitDeltaRequestWithNonExistentCommit(t *testing.T) { testhelper.RequireGrpcError(t, err, codes.Unavailable) } -func drainCommitDiffResponse(c pb.Diff_CommitDiffClient) error { +func drainCommitDiffResponse(c gitalypb.Diff_CommitDiffClient) error { for { _, err := c.Recv() if err != nil { @@ -968,7 +968,7 @@ func drainCommitDiffResponse(c pb.Diff_CommitDiffClient) error { } } -func drainCommitDeltaResponse(c pb.Diff_CommitDeltaClient) error { +func drainCommitDeltaResponse(c gitalypb.Diff_CommitDeltaClient) error { for { _, err := c.Recv() if err != nil { @@ -977,7 +977,7 @@ func drainCommitDeltaResponse(c pb.Diff_CommitDeltaClient) error { } } -func getDiffsFromCommitDiffClient(t *testing.T, client pb.DiffService_CommitDiffClient) []*diff.Diff { +func getDiffsFromCommitDiffClient(t *testing.T, client gitalypb.DiffService_CommitDiffClient) []*diff.Diff { var diffs []*diff.Diff var currentDiff *diff.Diff @@ -1016,7 +1016,7 @@ func getDiffsFromCommitDiffClient(t *testing.T, client pb.DiffService_CommitDiff return diffs } -func assertExactReceivedDiffs(t *testing.T, client pb.DiffService_CommitDiffClient, expectedDiffs []diff.Diff) { +func assertExactReceivedDiffs(t *testing.T, client gitalypb.DiffService_CommitDiffClient, expectedDiffs []diff.Diff) { fetchedDiffs := getDiffsFromCommitDiffClient(t, client) var i int @@ -1068,7 +1068,7 @@ func assertExactReceivedDiffs(t *testing.T, client pb.DiffService_CommitDiffClie } } -func assertExactReceivedDeltas(t *testing.T, client pb.Diff_CommitDeltaClient, expectedDeltas []diff.Diff) { +func assertExactReceivedDeltas(t *testing.T, client gitalypb.Diff_CommitDeltaClient, expectedDeltas []diff.Diff) { i := 0 for { fetchedDeltas, err := client.Recv() diff --git a/internal/service/diff/numstat.go b/internal/service/diff/numstat.go index 71edb068e..f6a1aecce 100644 --- a/internal/service/diff/numstat.go +++ b/internal/service/diff/numstat.go @@ -3,7 +3,7 @@ package diff import ( "io" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/diff" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -15,12 +15,12 @@ var ( maxNumStatBatchSize = 1000 ) -func (s *server) DiffStats(in *pb.DiffStatsRequest, stream pb.DiffService_DiffStatsServer) error { +func (s *server) DiffStats(in *gitalypb.DiffStatsRequest, stream gitalypb.DiffService_DiffStatsServer) error { if err := validateDiffStatsRequestParams(in); err != nil { return err } - var batch []*pb.DiffStats + var batch []*gitalypb.DiffStats cmdArgs := []string{"diff", "--numstat", "-z", in.LeftCommitId, in.RightCommitId} cmd, err := git.Command(stream.Context(), in.Repository, cmdArgs...) @@ -43,7 +43,7 @@ func (s *server) DiffStats(in *pb.DiffStatsRequest, stream pb.DiffService_DiffSt return err } - numStat := &pb.DiffStats{ + numStat := &gitalypb.DiffStats{ Additions: stat.Additions, Deletions: stat.Deletions, Path: stat.Path, @@ -67,19 +67,19 @@ func (s *server) DiffStats(in *pb.DiffStatsRequest, stream pb.DiffService_DiffSt return sendStats(batch, stream) } -func sendStats(batch []*pb.DiffStats, stream pb.DiffService_DiffStatsServer) error { +func sendStats(batch []*gitalypb.DiffStats, stream gitalypb.DiffService_DiffStatsServer) error { if len(batch) == 0 { return nil } - if err := stream.Send(&pb.DiffStatsResponse{Stats: batch}); err != nil { + if err := stream.Send(&gitalypb.DiffStatsResponse{Stats: batch}); err != nil { return status.Errorf(codes.Unavailable, "DiffStats: send: %v", err) } return nil } -func validateDiffStatsRequestParams(in *pb.DiffStatsRequest) error { +func validateDiffStatsRequestParams(in *gitalypb.DiffStatsRequest) error { repo := in.GetRepository() if _, err := helper.GetRepoPath(repo); err != nil { return err diff --git a/internal/service/diff/numstat_test.go b/internal/service/diff/numstat_test.go index 1b8d4c5f9..cb38d17e8 100644 --- a/internal/service/diff/numstat_test.go +++ b/internal/service/diff/numstat_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/diff" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" @@ -24,7 +24,7 @@ func TestSuccessfulDiffStatsRequest(t *testing.T) { rightCommit := "e4003da16c1c2c3fc4567700121b17bf8e591c6c" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.DiffStatsRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} + rpcRequest := &gitalypb.DiffStatsRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} ctx, cancel := testhelper.Context() defer cancel() @@ -142,21 +142,21 @@ func TestFailedDiffStatsRequest(t *testing.T) { tests := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository leftCommitID string rightCommitID string err codes.Code }{ { desc: "repo not found", - repo: &pb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar.git"}, leftCommitID: "e4003da16c1c2c3fc4567700121b17bf8e591c6c", rightCommitID: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", err: codes.NotFound, }, { desc: "storage not found", - repo: &pb.Repository{StorageName: "foo", RelativePath: "bar.git"}, + repo: &gitalypb.Repository{StorageName: "foo", RelativePath: "bar.git"}, leftCommitID: "e4003da16c1c2c3fc4567700121b17bf8e591c6c", rightCommitID: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", err: codes.InvalidArgument, @@ -206,7 +206,7 @@ func TestFailedDiffStatsRequest(t *testing.T) { } for _, tc := range tests { - rpcRequest := &pb.DiffStatsRequest{Repository: tc.repo, RightCommitId: tc.rightCommitID, LeftCommitId: tc.leftCommitID} + rpcRequest := &gitalypb.DiffStatsRequest{Repository: tc.repo, RightCommitId: tc.rightCommitID, LeftCommitId: tc.leftCommitID} stream, err := client.DiffStats(ctx, rpcRequest) require.NoError(t, err) diff --git a/internal/service/diff/patch.go b/internal/service/diff/patch.go index 690c67c2d..51718088a 100644 --- a/internal/service/diff/patch.go +++ b/internal/service/diff/patch.go @@ -1,12 +1,11 @@ package diff import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) -func (s *server) CommitPatch(in *pb.CommitPatchRequest, stream pb.DiffService_CommitPatchServer) error { +func (s *server) CommitPatch(in *gitalypb.CommitPatchRequest, stream gitalypb.DiffService_CommitPatchServer) error { ctx := stream.Context() client, err := s.DiffServiceClient(ctx) diff --git a/internal/service/diff/patch_test.go b/internal/service/diff/patch_test.go index 3e49f31e0..b849edfe9 100644 --- a/internal/service/diff/patch_test.go +++ b/internal/service/diff/patch_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -42,7 +42,7 @@ func TestSuccessfulCommitPatchRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.CommitPatchRequest{ + request := &gitalypb.CommitPatchRequest{ Repository: testRepo, Revision: testCase.revision, } diff --git a/internal/service/diff/raw.go b/internal/service/diff/raw.go index 3fade9527..46688aec7 100644 --- a/internal/service/diff/raw.go +++ b/internal/service/diff/raw.go @@ -3,17 +3,16 @@ package diff import ( "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) RawDiff(in *pb.RawDiffRequest, stream pb.DiffService_RawDiffServer) error { +func (s *server) RawDiff(in *gitalypb.RawDiffRequest, stream gitalypb.DiffService_RawDiffServer) error { if err := validateRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "RawDiff: %v", err) } @@ -21,13 +20,13 @@ func (s *server) RawDiff(in *pb.RawDiffRequest, stream pb.DiffService_RawDiffSer cmdArgs := []string{"diff", "--full-index", in.LeftCommitId, in.RightCommitId} sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.RawDiffResponse{Data: p}) + return stream.Send(&gitalypb.RawDiffResponse{Data: p}) }) return sendRawOutput(stream.Context(), "RawDiff", in.Repository, sw, cmdArgs) } -func (s *server) RawPatch(in *pb.RawPatchRequest, stream pb.DiffService_RawPatchServer) error { +func (s *server) RawPatch(in *gitalypb.RawPatchRequest, stream gitalypb.DiffService_RawPatchServer) error { if err := validateRequest(in); err != nil { return status.Errorf(codes.InvalidArgument, "RawPatch: %v", err) } @@ -35,13 +34,13 @@ func (s *server) RawPatch(in *pb.RawPatchRequest, stream pb.DiffService_RawPatch cmdArgs := []string{"format-patch", "--stdout", in.LeftCommitId + ".." + in.RightCommitId} sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.RawPatchResponse{Data: p}) + return stream.Send(&gitalypb.RawPatchResponse{Data: p}) }) return sendRawOutput(stream.Context(), "RawPatch", in.Repository, sw, cmdArgs) } -func sendRawOutput(ctx context.Context, rpc string, repo *pb.Repository, sender io.Writer, cmdArgs []string) error { +func sendRawOutput(ctx context.Context, rpc string, repo *gitalypb.Repository, sender io.Writer, cmdArgs []string) error { cmd, err := git.Command(ctx, repo, cmdArgs...) if err != nil { if _, ok := status.FromError(err); ok { diff --git a/internal/service/diff/raw_test.go b/internal/service/diff/raw_test.go index 52cdc655e..a689fe1ad 100644 --- a/internal/service/diff/raw_test.go +++ b/internal/service/diff/raw_test.go @@ -4,11 +4,10 @@ import ( "fmt" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -28,7 +27,7 @@ func TestSuccessfulRawDiffRequest(t *testing.T) { rightCommit := "e395f646b1499e8e0279445fc99a0596a65fab7e" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.RawDiffRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} + rpcRequest := &gitalypb.RawDiffRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} c, err := client.RawDiff(ctx, rpcRequest) require.NoError(t, err) @@ -69,12 +68,12 @@ func TestFailedRawDiffRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.RawDiffRequest + request *gitalypb.RawDiffRequest code codes.Code }{ { desc: "empty left commit", - request: &pb.RawDiffRequest{ + request: &gitalypb.RawDiffRequest{ Repository: testRepo, LeftCommitId: "", RightCommitId: "e395f646b1499e8e0279445fc99a0596a65fab7e", @@ -83,7 +82,7 @@ func TestFailedRawDiffRequestDueToValidations(t *testing.T) { }, { desc: "empty right commit", - request: &pb.RawDiffRequest{ + request: &gitalypb.RawDiffRequest{ Repository: testRepo, RightCommitId: "", LeftCommitId: "e395f646b1499e8e0279445fc99a0596a65fab7e", @@ -92,7 +91,7 @@ func TestFailedRawDiffRequestDueToValidations(t *testing.T) { }, { desc: "empty repo", - request: &pb.RawDiffRequest{ + request: &gitalypb.RawDiffRequest{ Repository: nil, RightCommitId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", LeftCommitId: "e395f646b1499e8e0279445fc99a0596a65fab7e", @@ -127,7 +126,7 @@ func TestSuccessfulRawPatchRequest(t *testing.T) { rightCommit := "e395f646b1499e8e0279445fc99a0596a65fab7e" leftCommit := "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab" - rpcRequest := &pb.RawPatchRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} + rpcRequest := &gitalypb.RawPatchRequest{Repository: testRepo, RightCommitId: rightCommit, LeftCommitId: leftCommit} c, err := client.RawPatch(ctx, rpcRequest) require.NoError(t, err) @@ -161,12 +160,12 @@ func TestFailedRawPatchRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.RawPatchRequest + request *gitalypb.RawPatchRequest code codes.Code }{ { desc: "empty left commit", - request: &pb.RawPatchRequest{ + request: &gitalypb.RawPatchRequest{ Repository: testRepo, LeftCommitId: "", RightCommitId: "e395f646b1499e8e0279445fc99a0596a65fab7e", @@ -175,7 +174,7 @@ func TestFailedRawPatchRequestDueToValidations(t *testing.T) { }, { desc: "empty right commit", - request: &pb.RawPatchRequest{ + request: &gitalypb.RawPatchRequest{ Repository: testRepo, RightCommitId: "", LeftCommitId: "e395f646b1499e8e0279445fc99a0596a65fab7e", @@ -184,7 +183,7 @@ func TestFailedRawPatchRequestDueToValidations(t *testing.T) { }, { desc: "empty repo", - request: &pb.RawPatchRequest{ + request: &gitalypb.RawPatchRequest{ Repository: nil, RightCommitId: "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab", LeftCommitId: "e395f646b1499e8e0279445fc99a0596a65fab7e", @@ -204,7 +203,7 @@ func TestFailedRawPatchRequestDueToValidations(t *testing.T) { } } -func drainRawDiffResponse(c pb.DiffService_RawDiffClient) error { +func drainRawDiffResponse(c gitalypb.DiffService_RawDiffClient) error { var err error for err == nil { _, err = c.Recv() @@ -212,7 +211,7 @@ func drainRawDiffResponse(c pb.DiffService_RawDiffClient) error { return err } -func drainRawPatchResponse(c pb.DiffService_RawPatchClient) error { +func drainRawPatchResponse(c gitalypb.DiffService_RawPatchClient) error { var err error for err == nil { _, err = c.Recv() diff --git a/internal/service/diff/server.go b/internal/service/diff/server.go index 644298e44..8474b63f6 100644 --- a/internal/service/diff/server.go +++ b/internal/service/diff/server.go @@ -1,7 +1,7 @@ package diff import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) @@ -13,7 +13,7 @@ type server struct { } // NewServer creates a new instance of a gRPC DiffServer -func NewServer(rs *rubyserver.Server) pb.DiffServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.DiffServiceServer { return &server{ MsgSizeThreshold: msgSizeThreshold, Server: rs, diff --git a/internal/service/diff/testhelper_test.go b/internal/service/diff/testhelper_test.go index a4d0dc672..9031c33a3 100644 --- a/internal/service/diff/testhelper_test.go +++ b/internal/service/diff/testhelper_test.go @@ -11,8 +11,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/reflection" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -47,7 +46,7 @@ func runDiffServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterDiffServiceServer(server, NewServer(rubyServer)) + gitalypb.RegisterDiffServiceServer(server, NewServer(rubyServer)) reflection.Register(server) go server.Serve(listener) @@ -55,7 +54,7 @@ func runDiffServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func newDiffClient(t *testing.T, serverSocketPath string) (pb.DiffServiceClient, *grpc.ClientConn) { +func newDiffClient(t *testing.T, serverSocketPath string) (gitalypb.DiffServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -68,5 +67,5 @@ func newDiffClient(t *testing.T, serverSocketPath string) (pb.DiffServiceClient, t.Fatal(err) } - return pb.NewDiffServiceClient(conn), conn + return gitalypb.NewDiffServiceClient(conn), conn } diff --git a/internal/service/namespace/namespace.go b/internal/service/namespace/namespace.go index ae0f98a79..ef8abffe0 100644 --- a/internal/service/namespace/namespace.go +++ b/internal/service/namespace/namespace.go @@ -4,7 +4,7 @@ import ( "os" "path" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -13,7 +13,7 @@ import ( var noNameError = status.Errorf(codes.InvalidArgument, "Name: cannot be empty") -func (s *server) NamespaceExists(ctx context.Context, in *pb.NamespaceExistsRequest) (*pb.NamespaceExistsResponse, error) { +func (s *server) NamespaceExists(ctx context.Context, in *gitalypb.NamespaceExistsRequest) (*gitalypb.NamespaceExistsResponse, error) { storagePath, err := helper.GetStorageByName(in.GetStorageName()) if err != nil { return nil, err @@ -26,15 +26,15 @@ func (s *server) NamespaceExists(ctx context.Context, in *pb.NamespaceExistsRequ } if fi, err := os.Stat(namespacePath(storagePath, in.GetName())); os.IsNotExist(err) { - return &pb.NamespaceExistsResponse{Exists: false}, nil + return &gitalypb.NamespaceExistsResponse{Exists: false}, nil } else if err != nil { return nil, status.Errorf(codes.Internal, "could not stat the directory: %v", err) } else { - return &pb.NamespaceExistsResponse{Exists: fi.IsDir()}, nil + return &gitalypb.NamespaceExistsResponse{Exists: fi.IsDir()}, nil } } -func (s *server) AddNamespace(ctx context.Context, in *pb.AddNamespaceRequest) (*pb.AddNamespaceResponse, error) { +func (s *server) AddNamespace(ctx context.Context, in *gitalypb.AddNamespaceRequest) (*gitalypb.AddNamespaceResponse, error) { storagePath, err := helper.GetStorageByName(in.GetStorageName()) if err != nil { return nil, err @@ -49,10 +49,10 @@ func (s *server) AddNamespace(ctx context.Context, in *pb.AddNamespaceRequest) ( return nil, status.Errorf(codes.Internal, "create directory: %v", err) } - return &pb.AddNamespaceResponse{}, nil + return &gitalypb.AddNamespaceResponse{}, nil } -func (s *server) RenameNamespace(ctx context.Context, in *pb.RenameNamespaceRequest) (*pb.RenameNamespaceResponse, error) { +func (s *server) RenameNamespace(ctx context.Context, in *gitalypb.RenameNamespaceRequest) (*gitalypb.RenameNamespaceResponse, error) { storagePath, err := helper.GetStorageByName(in.GetStorageName()) if err != nil { return nil, err @@ -64,7 +64,7 @@ func (s *server) RenameNamespace(ctx context.Context, in *pb.RenameNamespaceRequ // No need to check if the from path exists, if it doesn't, we'd later get an // os.LinkError - toExistsCheck := &pb.NamespaceExistsRequest{StorageName: in.StorageName, Name: in.GetTo()} + toExistsCheck := &gitalypb.NamespaceExistsRequest{StorageName: in.StorageName, Name: in.GetTo()} if exists, err := s.NamespaceExists(ctx, toExistsCheck); err != nil { return nil, err } else if exists.Exists { @@ -78,10 +78,10 @@ func (s *server) RenameNamespace(ctx context.Context, in *pb.RenameNamespaceRequ return nil, status.Errorf(codes.Internal, "rename: %v", err) } - return &pb.RenameNamespaceResponse{}, nil + return &gitalypb.RenameNamespaceResponse{}, nil } -func (s *server) RemoveNamespace(ctx context.Context, in *pb.RemoveNamespaceRequest) (*pb.RemoveNamespaceResponse, error) { +func (s *server) RemoveNamespace(ctx context.Context, in *gitalypb.RemoveNamespaceRequest) (*gitalypb.RemoveNamespaceResponse, error) { storagePath, err := helper.GetStorageByName(in.GetStorageName()) if err != nil { return nil, err @@ -97,7 +97,7 @@ func (s *server) RemoveNamespace(ctx context.Context, in *pb.RemoveNamespaceRequ if err = os.RemoveAll(namespacePath(storagePath, in.GetName())); err != nil { return nil, status.Errorf(codes.Internal, "removal: %v", err) } - return &pb.RemoveNamespaceResponse{}, nil + return &gitalypb.RemoveNamespaceResponse{}, nil } func namespacePath(storage, ns string) string { diff --git a/internal/service/namespace/namespace_test.go b/internal/service/namespace/namespace_test.go index dd71db26c..f5ac3471f 100644 --- a/internal/service/namespace/namespace_test.go +++ b/internal/service/namespace/namespace_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -43,19 +43,19 @@ func TestNamespaceExists(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - _, err := client.AddNamespace(ctx, &pb.AddNamespaceRequest{StorageName: "default", Name: "existing"}) + _, err := client.AddNamespace(ctx, &gitalypb.AddNamespaceRequest{StorageName: "default", Name: "existing"}) require.NoError(t, err, "Namespace creation failed") - defer client.RemoveNamespace(ctx, &pb.RemoveNamespaceRequest{StorageName: "default", Name: "existing"}) + defer client.RemoveNamespace(ctx, &gitalypb.RemoveNamespaceRequest{StorageName: "default", Name: "existing"}) queries := []struct { desc string - request *pb.NamespaceExistsRequest + request *gitalypb.NamespaceExistsRequest errorCode codes.Code exists bool }{ { desc: "empty name", - request: &pb.NamespaceExistsRequest{ + request: &gitalypb.NamespaceExistsRequest{ StorageName: "default", Name: "", }, @@ -63,7 +63,7 @@ func TestNamespaceExists(t *testing.T) { }, { desc: "Namespace doesn't exists", - request: &pb.NamespaceExistsRequest{ + request: &gitalypb.NamespaceExistsRequest{ StorageName: "default", Name: "not-existing", }, @@ -72,7 +72,7 @@ func TestNamespaceExists(t *testing.T) { }, { desc: "Wrong storage path", - request: &pb.NamespaceExistsRequest{ + request: &gitalypb.NamespaceExistsRequest{ StorageName: "other", Name: "existing", }, @@ -81,7 +81,7 @@ func TestNamespaceExists(t *testing.T) { }, { desc: "Namespace exists", - request: &pb.NamespaceExistsRequest{ + request: &gitalypb.NamespaceExistsRequest{ StorageName: "default", Name: "existing", }, @@ -114,12 +114,12 @@ func TestAddNamespace(t *testing.T) { queries := []struct { desc string - request *pb.AddNamespaceRequest + request *gitalypb.AddNamespaceRequest errorCode codes.Code }{ { desc: "No name", - request: &pb.AddNamespaceRequest{ + request: &gitalypb.AddNamespaceRequest{ StorageName: "default", Name: "", }, @@ -127,7 +127,7 @@ func TestAddNamespace(t *testing.T) { }, { desc: "Namespace is successfully created", - request: &pb.AddNamespaceRequest{ + request: &gitalypb.AddNamespaceRequest{ StorageName: "default", Name: "create-me", }, @@ -135,7 +135,7 @@ func TestAddNamespace(t *testing.T) { }, { desc: "Idempotent on creation", - request: &pb.AddNamespaceRequest{ + request: &gitalypb.AddNamespaceRequest{ StorageName: "default", Name: "create-me", }, @@ -143,7 +143,7 @@ func TestAddNamespace(t *testing.T) { }, { desc: "no storage", - request: &pb.AddNamespaceRequest{ + request: &gitalypb.AddNamespaceRequest{ StorageName: "", Name: "mepmep", }, @@ -162,7 +162,7 @@ func TestAddNamespace(t *testing.T) { // Clean up if tc.errorCode == codes.OK { - client.RemoveNamespace(ctx, &pb.RemoveNamespaceRequest{ + client.RemoveNamespace(ctx, &gitalypb.RemoveNamespaceRequest{ StorageName: tc.request.StorageName, Name: tc.request.Name, }) @@ -183,12 +183,12 @@ func TestRemoveNamespace(t *testing.T) { queries := []struct { desc string - request *pb.RemoveNamespaceRequest + request *gitalypb.RemoveNamespaceRequest errorCode codes.Code }{ { desc: "Namespace is successfully removed", - request: &pb.RemoveNamespaceRequest{ + request: &gitalypb.RemoveNamespaceRequest{ StorageName: "default", Name: "created", }, @@ -196,7 +196,7 @@ func TestRemoveNamespace(t *testing.T) { }, { desc: "Idempotent on deletion", - request: &pb.RemoveNamespaceRequest{ + request: &gitalypb.RemoveNamespaceRequest{ StorageName: "default", Name: "not-there", }, @@ -204,7 +204,7 @@ func TestRemoveNamespace(t *testing.T) { }, { desc: "no storage", - request: &pb.RemoveNamespaceRequest{ + request: &gitalypb.RemoveNamespaceRequest{ StorageName: "", Name: "mepmep", }, @@ -214,7 +214,7 @@ func TestRemoveNamespace(t *testing.T) { for _, tc := range queries { t.Run(tc.desc, func(t *testing.T) { - _, err := client.AddNamespace(ctx, &pb.AddNamespaceRequest{StorageName: "default", Name: "created"}) + _, err := client.AddNamespace(ctx, &gitalypb.AddNamespaceRequest{StorageName: "default", Name: "created"}) require.NoError(t, err, "setup failed") _, err = client.RemoveNamespace(ctx, tc.request) @@ -235,12 +235,12 @@ func TestRenameNamespace(t *testing.T) { queries := []struct { desc string - request *pb.RenameNamespaceRequest + request *gitalypb.RenameNamespaceRequest errorCode codes.Code }{ { desc: "Renaming an existing namespace", - request: &pb.RenameNamespaceRequest{ + request: &gitalypb.RenameNamespaceRequest{ From: "existing", To: "new-path", StorageName: "default", @@ -249,7 +249,7 @@ func TestRenameNamespace(t *testing.T) { }, { desc: "No from given", - request: &pb.RenameNamespaceRequest{ + request: &gitalypb.RenameNamespaceRequest{ From: "", To: "new-path", StorageName: "default", @@ -258,7 +258,7 @@ func TestRenameNamespace(t *testing.T) { }, { desc: "non-existing namespace", - request: &pb.RenameNamespaceRequest{ + request: &gitalypb.RenameNamespaceRequest{ From: "non-existing", To: "new-path", StorageName: "default", @@ -267,7 +267,7 @@ func TestRenameNamespace(t *testing.T) { }, { desc: "existing destination namespace", - request: &pb.RenameNamespaceRequest{ + request: &gitalypb.RenameNamespaceRequest{ From: "existing", To: "existing", StorageName: "default", @@ -276,7 +276,7 @@ func TestRenameNamespace(t *testing.T) { }, } - _, err := client.AddNamespace(ctx, &pb.AddNamespaceRequest{ + _, err := client.AddNamespace(ctx, &gitalypb.AddNamespaceRequest{ StorageName: "default", Name: "existing", }) @@ -289,7 +289,7 @@ func TestRenameNamespace(t *testing.T) { require.Equal(t, tc.errorCode, helper.GrpcCode(err)) if tc.errorCode == codes.OK { - client.RemoveNamespace(ctx, &pb.RemoveNamespaceRequest{ + client.RemoveNamespace(ctx, &gitalypb.RemoveNamespaceRequest{ StorageName: "default", Name: "new-path", }) diff --git a/internal/service/namespace/server.go b/internal/service/namespace/server.go index 5735feb37..395a050b3 100644 --- a/internal/service/namespace/server.go +++ b/internal/service/namespace/server.go @@ -1,12 +1,10 @@ package namespace -import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" -) +import "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" type server struct{} // NewServer creates a new instance of a gRPC namespace server -func NewServer() pb.NamespaceServiceServer { +func NewServer() gitalypb.NamespaceServiceServer { return &server{} } diff --git a/internal/service/namespace/testhelper_test.go b/internal/service/namespace/testhelper_test.go index 2d814a321..5655839f0 100644 --- a/internal/service/namespace/testhelper_test.go +++ b/internal/service/namespace/testhelper_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc" @@ -21,7 +21,7 @@ func runNamespaceServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterNamespaceServiceServer(server, NewServer()) + gitalypb.RegisterNamespaceServiceServer(server, NewServer()) reflection.Register(server) go server.Serve(listener) @@ -29,7 +29,7 @@ func runNamespaceServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func newNamespaceClient(t *testing.T, serverSocketPath string) (pb.NamespaceServiceClient, *grpc.ClientConn) { +func newNamespaceClient(t *testing.T, serverSocketPath string) (gitalypb.NamespaceServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -41,5 +41,5 @@ func newNamespaceClient(t *testing.T, serverSocketPath string) (pb.NamespaceServ t.Fatal(err) } - return pb.NewNamespaceServiceClient(conn), conn + return gitalypb.NewNamespaceServiceClient(conn), conn } diff --git a/internal/service/operations/branches.go b/internal/service/operations/branches.go index c6750872c..e355f906a 100644 --- a/internal/service/operations/branches.go +++ b/internal/service/operations/branches.go @@ -1,16 +1,15 @@ package operations import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" ) -func (s *server) UserCreateBranch(ctx context.Context, req *pb.UserCreateBranchRequest) (*pb.UserCreateBranchResponse, error) { +func (s *server) UserCreateBranch(ctx context.Context, req *gitalypb.UserCreateBranchRequest) (*gitalypb.UserCreateBranchResponse, error) { client, err := s.OperationServiceClient(ctx) if err != nil { return nil, err @@ -24,7 +23,7 @@ func (s *server) UserCreateBranch(ctx context.Context, req *pb.UserCreateBranchR return client.UserCreateBranch(clientCtx, req) } -func (s *server) UserUpdateBranch(ctx context.Context, req *pb.UserUpdateBranchRequest) (*pb.UserUpdateBranchResponse, error) { +func (s *server) UserUpdateBranch(ctx context.Context, req *gitalypb.UserUpdateBranchRequest) (*gitalypb.UserUpdateBranchResponse, error) { client, err := s.OperationServiceClient(ctx) if err != nil { return nil, err @@ -38,7 +37,7 @@ func (s *server) UserUpdateBranch(ctx context.Context, req *pb.UserUpdateBranchR return client.UserUpdateBranch(clientCtx, req) } -func (s *server) UserDeleteBranch(ctx context.Context, req *pb.UserDeleteBranchRequest) (*pb.UserDeleteBranchResponse, error) { +func (s *server) UserDeleteBranch(ctx context.Context, req *gitalypb.UserDeleteBranchRequest) (*gitalypb.UserDeleteBranchResponse, error) { if len(req.BranchName) == 0 { return nil, status.Errorf(codes.InvalidArgument, "Bad Request (empty branch name)") } diff --git a/internal/service/operations/branches_test.go b/internal/service/operations/branches_test.go index fa04b5f72..3ae83d200 100644 --- a/internal/service/operations/branches_test.go +++ b/internal/service/operations/branches_test.go @@ -10,11 +10,10 @@ import ( "google.golang.org/grpc/codes" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) func TestSuccessfulUserCreateBranchRequest(t *testing.T) { @@ -38,13 +37,13 @@ func TestSuccessfulUserCreateBranchRequest(t *testing.T) { desc string branchName string startPoint string - expectedBranch *pb.Branch + expectedBranch *gitalypb.Branch }{ { desc: "valid branch", branchName: "new-branch", startPoint: startPoint, - expectedBranch: &pb.Branch{ + expectedBranch: &gitalypb.Branch{ Name: []byte("new-branch"), TargetCommit: startPointCommit, }, @@ -54,7 +53,7 @@ func TestSuccessfulUserCreateBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { branchName := testCase.branchName - request := &pb.UserCreateBranchRequest{ + request := &gitalypb.UserCreateBranchRequest{ Repository: testRepo, BranchName: []byte(branchName), StartPoint: []byte(testCase.startPoint), @@ -90,7 +89,7 @@ func TestSuccessfulGitHooksForUserCreateBranchRequest(t *testing.T) { defer conn.Close() branchName := "new-branch" - request := &pb.UserCreateBranchRequest{ + request := &gitalypb.UserCreateBranchRequest{ Repository: testRepo, BranchName: []byte(branchName), StartPoint: []byte("c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"), @@ -129,7 +128,7 @@ func TestFailedUserCreateBranchDueToHooks(t *testing.T) { client, conn := newOperationClient(t, serverSocketPath) defer conn.Close() - request := &pb.UserCreateBranchRequest{ + request := &gitalypb.UserCreateBranchRequest{ Repository: testRepo, BranchName: []byte("new-branch"), StartPoint: []byte("c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"), @@ -171,7 +170,7 @@ func TestFailedUserCreateBranchRequest(t *testing.T) { desc string branchName string startPoint string - user *pb.User + user *gitalypb.User code codes.Code }{ { @@ -207,7 +206,7 @@ func TestFailedUserCreateBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.UserCreateBranchRequest{ + request := &gitalypb.UserCreateBranchRequest{ Repository: testRepo, BranchName: []byte(testCase.branchName), StartPoint: []byte(testCase.startPoint), @@ -240,7 +239,7 @@ func TestSuccessfulUserDeleteBranchRequest(t *testing.T) { defer exec.Command("git", "-C", testRepoPath, "branch", "-d", branchNameInput).Run() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Alejandro Rodríguez"), Email: []byte("alejandro@gitlab.com"), GlId: "user-123", @@ -248,7 +247,7 @@ func TestSuccessfulUserDeleteBranchRequest(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", branchNameInput) - request := &pb.UserDeleteBranchRequest{ + request := &gitalypb.UserDeleteBranchRequest{ Repository: testRepo, BranchName: []byte(branchNameInput), User: user, @@ -274,14 +273,14 @@ func TestSuccessfulGitHooksForUserDeleteBranchRequest(t *testing.T) { branchNameInput := "to-be-deleted-soon-branch" defer exec.Command("git", "-C", testRepoPath, "branch", "-d", branchNameInput).Run() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Alejandro Rodríguez"), Email: []byte("alejandro@gitlab.com"), GlId: "user-123", GlUsername: "johndoe", } - request := &pb.UserDeleteBranchRequest{ + request := &gitalypb.UserDeleteBranchRequest{ Repository: testRepo, BranchName: []byte(branchNameInput), User: user, @@ -318,7 +317,7 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Alejandro Rodríguez"), Email: []byte("alejandro@gitlab.com"), GlId: "user-123", @@ -326,12 +325,12 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) { testCases := []struct { desc string - request *pb.UserDeleteBranchRequest + request *gitalypb.UserDeleteBranchRequest code codes.Code }{ { desc: "empty user", - request: &pb.UserDeleteBranchRequest{ + request: &gitalypb.UserDeleteBranchRequest{ Repository: testRepo, BranchName: []byte("does-matter-the-name-if-user-is-empty"), }, @@ -339,7 +338,7 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) { }, { desc: "empty branch name", - request: &pb.UserDeleteBranchRequest{ + request: &gitalypb.UserDeleteBranchRequest{ Repository: testRepo, User: user, }, @@ -347,7 +346,7 @@ func TestFailedUserDeleteBranchDueToValidation(t *testing.T) { }, { desc: "non-existent branch name", - request: &pb.UserDeleteBranchRequest{ + request: &gitalypb.UserDeleteBranchRequest{ Repository: testRepo, User: user, BranchName: []byte("i-do-not-exist"), @@ -381,13 +380,13 @@ func TestFailedUserDeleteBranchDueToHooks(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", branchNameInput) defer exec.Command("git", "-C", testRepoPath, "branch", "-d", branchNameInput).Run() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Alejandro Rodríguez"), Email: []byte("alejandro@gitlab.com"), GlId: "user-123", } - request := &pb.UserDeleteBranchRequest{ + request := &gitalypb.UserDeleteBranchRequest{ Repository: testRepo, BranchName: []byte(branchNameInput), User: user, diff --git a/internal/service/operations/cherry_pick.go b/internal/service/operations/cherry_pick.go index 9459da612..eaea55558 100644 --- a/internal/service/operations/cherry_pick.go +++ b/internal/service/operations/cherry_pick.go @@ -1,15 +1,14 @@ package operations import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UserCherryPick(ctx context.Context, req *pb.UserCherryPickRequest) (*pb.UserCherryPickResponse, error) { +func (s *server) UserCherryPick(ctx context.Context, req *gitalypb.UserCherryPickRequest) (*gitalypb.UserCherryPickResponse, error) { if err := validateCherryPickOrRevertRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "UserCherryPick: %v", err) } diff --git a/internal/service/operations/cherry_pick_test.go b/internal/service/operations/cherry_pick_test.go index 49ab13cc4..1ad0b48d0 100644 --- a/internal/service/operations/cherry_pick_test.go +++ b/internal/service/operations/cherry_pick_test.go @@ -7,13 +7,12 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" serverPkg "gitlab.com/gitlab-org/gitaly/internal/server" "gitlab.com/gitlab-org/gitaly/internal/service/operations" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -39,7 +38,7 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) { masterHeadCommit, err := log.GetCommit(ctxOuter, testRepo, "master") require.NoError(t, err) - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -53,23 +52,23 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) { testCases := []struct { desc string - request *pb.UserCherryPickRequest - branchUpdate *pb.OperationBranchUpdate + request *gitalypb.UserCherryPickRequest + branchUpdate *gitalypb.OperationBranchUpdate }{ { desc: "branch exists", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, BranchName: []byte(destinationBranch), Message: []byte("Cherry-picking " + cherryPickedCommit.Id), }, - branchUpdate: &pb.OperationBranchUpdate{}, + branchUpdate: &gitalypb.OperationBranchUpdate{}, }, { desc: "nonexistent branch + start_repository == repository", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -77,11 +76,11 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) { Message: []byte("Cherry-picking " + cherryPickedCommit.Id), StartBranchName: []byte("master"), }, - branchUpdate: &pb.OperationBranchUpdate{BranchCreated: true}, + branchUpdate: &gitalypb.OperationBranchUpdate{BranchCreated: true}, }, { desc: "nonexistent branch + start_repository != repository", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -90,11 +89,11 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) { StartRepository: testRepoCopy, StartBranchName: []byte("master"), }, - branchUpdate: &pb.OperationBranchUpdate{BranchCreated: true}, + branchUpdate: &gitalypb.OperationBranchUpdate{BranchCreated: true}, }, { desc: "nonexistent branch + empty start_repository", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -102,7 +101,7 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) { Message: []byte("Cherry-picking " + cherryPickedCommit.Id), StartBranchName: []byte("master"), }, - branchUpdate: &pb.OperationBranchUpdate{BranchCreated: true}, + branchUpdate: &gitalypb.OperationBranchUpdate{BranchCreated: true}, }, } @@ -143,7 +142,7 @@ func TestSuccessfulGitHooksForUserCherryPickRequest(t *testing.T) { destinationBranch := "cherry-picking-dst" testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -152,7 +151,7 @@ func TestSuccessfulGitHooksForUserCherryPickRequest(t *testing.T) { cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab") require.NoError(t, err) - request := &pb.UserCherryPickRequest{ + request := &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -198,7 +197,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) { destinationBranch := "cherry-picking-dst" - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -206,12 +205,12 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.UserCherryPickRequest + request *gitalypb.UserCherryPickRequest code codes.Code }{ { desc: "empty user", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: nil, Commit: cherryPickedCommit, @@ -222,7 +221,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) { }, { desc: "empty commit", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: nil, @@ -233,7 +232,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) { }, { desc: "empty branch name", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -244,7 +243,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) { }, { desc: "empty message", - request: &pb.UserCherryPickRequest{ + request: &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -282,7 +281,7 @@ func TestFailedUserCherryPickRequestDueToPreReceiveError(t *testing.T) { destinationBranch := "cherry-picking-dst" testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -291,7 +290,7 @@ func TestFailedUserCherryPickRequestDueToPreReceiveError(t *testing.T) { cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab") require.NoError(t, err) - request := &pb.UserCherryPickRequest{ + request := &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -333,7 +332,7 @@ func TestFailedUserCherryPickRequestDueToCreateTreeError(t *testing.T) { destinationBranch := "cherry-picking-dst" testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -343,7 +342,7 @@ func TestFailedUserCherryPickRequestDueToCreateTreeError(t *testing.T) { cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "4a24d82dbca5c11c61556f3b35ca472b7463187e") require.NoError(t, err) - request := &pb.UserCherryPickRequest{ + request := &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, @@ -377,7 +376,7 @@ func TestFailedUserCherryPickRequestDueToCommitError(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", sourceBranch, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -386,7 +385,7 @@ func TestFailedUserCherryPickRequestDueToCommitError(t *testing.T) { cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, sourceBranch) require.NoError(t, err) - request := &pb.UserCherryPickRequest{ + request := &gitalypb.UserCherryPickRequest{ Repository: testRepo, User: user, Commit: cherryPickedCommit, diff --git a/internal/service/operations/commit_files.go b/internal/service/operations/commit_files.go index 310f60a43..e9496d1af 100644 --- a/internal/service/operations/commit_files.go +++ b/internal/service/operations/commit_files.go @@ -3,13 +3,13 @@ package operations import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UserCommitFiles(stream pb.OperationService_UserCommitFilesServer) error { +func (s *server) UserCommitFiles(stream gitalypb.OperationService_UserCommitFilesServer) error { firstRequest, err := stream.Recv() if err != nil { return err @@ -64,7 +64,7 @@ func (s *server) UserCommitFiles(stream pb.OperationService_UserCommitFilesServe return stream.SendAndClose(response) } -func validateUserCommitFilesHeader(header *pb.UserCommitFilesRequestHeader) error { +func validateUserCommitFilesHeader(header *gitalypb.UserCommitFilesRequestHeader) error { if header.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/operations/commit_files_test.go b/internal/service/operations/commit_files_test.go index c5816e7c0..d43ea457b 100644 --- a/internal/service/operations/commit_files_test.go +++ b/internal/service/operations/commit_files_test.go @@ -10,7 +10,7 @@ import ( "google.golang.org/grpc/codes" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/service/operations" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -18,7 +18,7 @@ import ( ) var ( - user = &pb.User{ + user = &gitalypb.User{ Name: []byte("John Doe"), Email: []byte("johndoe@gitlab.com"), GlId: "user-1", @@ -48,7 +48,7 @@ func TestSuccessfulUserCommitFilesRequest(t *testing.T) { authorEmail := []byte("janedoe@gitlab.com") testCases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository repoPath string branchName string repoCreated bool @@ -193,12 +193,12 @@ func TestFailedUserCommitFilesRequestDueToIndexError(t *testing.T) { ctx := metadata.NewOutgoingContext(ctxOuter, md) testCases := []struct { desc string - requests []*pb.UserCommitFilesRequest + requests []*gitalypb.UserCommitFilesRequest indexError string }{ { desc: "file already exists", - requests: []*pb.UserCommitFilesRequest{ + requests: []*gitalypb.UserCommitFilesRequest{ headerRequest(testRepo, user, "feature", commitFilesMessage, nil, nil), createFileHeaderRequest("README.md"), actionContentRequest("This file already exists"), @@ -207,7 +207,7 @@ func TestFailedUserCommitFilesRequestDueToIndexError(t *testing.T) { }, { desc: "file doesn't exists", - requests: []*pb.UserCommitFilesRequest{ + requests: []*gitalypb.UserCommitFilesRequest{ headerRequest(testRepo, user, "feature", commitFilesMessage, nil, nil), chmodFileHeaderRequest("documents/story.txt", true), }, @@ -215,12 +215,12 @@ func TestFailedUserCommitFilesRequestDueToIndexError(t *testing.T) { }, { desc: "dir already exists", - requests: []*pb.UserCommitFilesRequest{ + requests: []*gitalypb.UserCommitFilesRequest{ headerRequest(testRepo, user, "utf-dir", commitFilesMessage, nil, nil), - actionRequest(&pb.UserCommitFilesAction{ - UserCommitFilesActionPayload: &pb.UserCommitFilesAction_Header{ - Header: &pb.UserCommitFilesActionHeader{ - Action: pb.UserCommitFilesActionHeader_CREATE_DIR, + actionRequest(&gitalypb.UserCommitFilesAction{ + UserCommitFilesActionPayload: &gitalypb.UserCommitFilesAction_Header{ + Header: &gitalypb.UserCommitFilesActionHeader{ + Action: gitalypb.UserCommitFilesActionHeader_CREATE_DIR, Base64Content: false, FilePath: []byte("héllo"), }, @@ -266,7 +266,7 @@ func TestFailedUserCommitFilesRequest(t *testing.T) { branchName := "feature" testCases := []struct { desc string - req *pb.UserCommitFilesRequest + req *gitalypb.UserCommitFilesRequest }{ { desc: "empty Repository", @@ -300,10 +300,10 @@ func TestFailedUserCommitFilesRequest(t *testing.T) { } } -func headerRequest(repo *pb.Repository, user *pb.User, branchName string, commitMessage, authorName, authorEmail []byte) *pb.UserCommitFilesRequest { - return &pb.UserCommitFilesRequest{ - UserCommitFilesRequestPayload: &pb.UserCommitFilesRequest_Header{ - Header: &pb.UserCommitFilesRequestHeader{ +func headerRequest(repo *gitalypb.Repository, user *gitalypb.User, branchName string, commitMessage, authorName, authorEmail []byte) *gitalypb.UserCommitFilesRequest { + return &gitalypb.UserCommitFilesRequest{ + UserCommitFilesRequestPayload: &gitalypb.UserCommitFilesRequest_Header{ + Header: &gitalypb.UserCommitFilesRequestHeader{ Repository: repo, User: user, BranchName: []byte(branchName), @@ -317,11 +317,11 @@ func headerRequest(repo *pb.Repository, user *pb.User, branchName string, commit } } -func createFileHeaderRequest(filePath string) *pb.UserCommitFilesRequest { - return actionRequest(&pb.UserCommitFilesAction{ - UserCommitFilesActionPayload: &pb.UserCommitFilesAction_Header{ - Header: &pb.UserCommitFilesActionHeader{ - Action: pb.UserCommitFilesActionHeader_CREATE, +func createFileHeaderRequest(filePath string) *gitalypb.UserCommitFilesRequest { + return actionRequest(&gitalypb.UserCommitFilesAction{ + UserCommitFilesActionPayload: &gitalypb.UserCommitFilesAction_Header{ + Header: &gitalypb.UserCommitFilesActionHeader{ + Action: gitalypb.UserCommitFilesActionHeader_CREATE, Base64Content: false, FilePath: []byte(filePath), }, @@ -329,11 +329,11 @@ func createFileHeaderRequest(filePath string) *pb.UserCommitFilesRequest { }) } -func chmodFileHeaderRequest(filePath string, executeFilemode bool) *pb.UserCommitFilesRequest { - return actionRequest(&pb.UserCommitFilesAction{ - UserCommitFilesActionPayload: &pb.UserCommitFilesAction_Header{ - Header: &pb.UserCommitFilesActionHeader{ - Action: pb.UserCommitFilesActionHeader_CHMOD, +func chmodFileHeaderRequest(filePath string, executeFilemode bool) *gitalypb.UserCommitFilesRequest { + return actionRequest(&gitalypb.UserCommitFilesAction{ + UserCommitFilesActionPayload: &gitalypb.UserCommitFilesAction_Header{ + Header: &gitalypb.UserCommitFilesActionHeader{ + Action: gitalypb.UserCommitFilesActionHeader_CHMOD, FilePath: []byte(filePath), ExecuteFilemode: executeFilemode, }, @@ -341,17 +341,17 @@ func chmodFileHeaderRequest(filePath string, executeFilemode bool) *pb.UserCommi }) } -func actionContentRequest(content string) *pb.UserCommitFilesRequest { - return actionRequest(&pb.UserCommitFilesAction{ - UserCommitFilesActionPayload: &pb.UserCommitFilesAction_Content{ +func actionContentRequest(content string) *gitalypb.UserCommitFilesRequest { + return actionRequest(&gitalypb.UserCommitFilesAction{ + UserCommitFilesActionPayload: &gitalypb.UserCommitFilesAction_Content{ Content: []byte(content), }, }) } -func actionRequest(action *pb.UserCommitFilesAction) *pb.UserCommitFilesRequest { - return &pb.UserCommitFilesRequest{ - UserCommitFilesRequestPayload: &pb.UserCommitFilesRequest_Action{ +func actionRequest(action *gitalypb.UserCommitFilesAction) *gitalypb.UserCommitFilesRequest { + return &gitalypb.UserCommitFilesRequest{ + UserCommitFilesRequestPayload: &gitalypb.UserCommitFilesRequest_Action{ Action: action, }, } diff --git a/internal/service/operations/merge.go b/internal/service/operations/merge.go index eb5dd5d51..2e9470f5a 100644 --- a/internal/service/operations/merge.go +++ b/internal/service/operations/merge.go @@ -3,15 +3,14 @@ package operations import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UserMergeBranch(bidi pb.OperationService_UserMergeBranchServer) error { +func (s *server) UserMergeBranch(bidi gitalypb.OperationService_UserMergeBranchServer) error { firstRequest, err := bidi.Recv() if err != nil { return err @@ -58,7 +57,7 @@ func (s *server) UserMergeBranch(bidi pb.OperationService_UserMergeBranchServer) ) } -func validateFFRequest(in *pb.UserFFBranchRequest) error { +func validateFFRequest(in *gitalypb.UserFFBranchRequest) error { if len(in.Branch) == 0 { return fmt.Errorf("empty branch name") } @@ -74,7 +73,7 @@ func validateFFRequest(in *pb.UserFFBranchRequest) error { return nil } -func (s *server) UserFFBranch(ctx context.Context, in *pb.UserFFBranchRequest) (*pb.UserFFBranchResponse, error) { +func (s *server) UserFFBranch(ctx context.Context, in *gitalypb.UserFFBranchRequest) (*gitalypb.UserFFBranchResponse, error) { if err := validateFFRequest(in); err != nil { return nil, status.Errorf(codes.InvalidArgument, "UserFFBranch: %v", err) } diff --git a/internal/service/operations/merge_test.go b/internal/service/operations/merge_test.go index 0224a5b1f..41cea3221 100644 --- a/internal/service/operations/merge_test.go +++ b/internal/service/operations/merge_test.go @@ -13,15 +13,15 @@ import ( "google.golang.org/grpc/codes" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) var ( - mergeUser = &pb.User{ + mergeUser = &gitalypb.User{ Name: []byte("Jane Doe"), Email: []byte("janedoe@example.com"), GlId: "user-1", @@ -60,7 +60,7 @@ func TestSuccessfulMerge(t *testing.T) { } mergeCommitMessage := "Merged by Gitaly" - firstRequest := &pb.UserMergeBranchRequest{ + firstRequest := &gitalypb.UserMergeBranchRequest{ Repository: testRepo, User: mergeUser, CommitId: commitToMerge, @@ -76,7 +76,7 @@ func TestSuccessfulMerge(t *testing.T) { _, err = gitlog.GetCommit(ctx, testRepo, firstResponse.CommitId) require.NoError(t, err, "look up git commit before merge is applied") - require.NoError(t, mergeBidi.Send(&pb.UserMergeBranchRequest{Apply: true}), "apply merge") + require.NoError(t, mergeBidi.Send(&gitalypb.UserMergeBranchRequest{Apply: true}), "apply merge") secondResponse, err := mergeBidi.Recv() require.NoError(t, err, "receive second response") @@ -90,7 +90,7 @@ func TestSuccessfulMerge(t *testing.T) { commit, err := gitlog.GetCommit(ctx, testRepo, mergeBranchName) require.NoError(t, err, "look up git commit after call has finished") - require.Equal(t, pb.OperationBranchUpdate{CommitId: commit.Id}, *(secondResponse.BranchUpdate)) + require.Equal(t, gitalypb.OperationBranchUpdate{CommitId: commit.Id}, *(secondResponse.BranchUpdate)) require.Contains(t, commit.ParentIds, mergeBranchHeadBefore, "merge parents must include previous HEAD of branch") require.Contains(t, commit.ParentIds, commitToMerge, "merge parents must include commit to merge") @@ -124,7 +124,7 @@ func TestAbortedMerge(t *testing.T) { prepareMergeBranch(t, testRepoPath) - firstRequest := &pb.UserMergeBranchRequest{ + firstRequest := &gitalypb.UserMergeBranchRequest{ Repository: testRepo, User: mergeUser, CommitId: commitToMerge, @@ -133,12 +133,12 @@ func TestAbortedMerge(t *testing.T) { } testCases := []struct { - req *pb.UserMergeBranchRequest + req *gitalypb.UserMergeBranchRequest closeSend bool desc string }{ - {req: &pb.UserMergeBranchRequest{}, desc: "empty request, don't close"}, - {req: &pb.UserMergeBranchRequest{}, closeSend: true, desc: "empty request and close"}, + {req: &gitalypb.UserMergeBranchRequest{}, desc: "empty request, don't close"}, + {req: &gitalypb.UserMergeBranchRequest{}, closeSend: true, desc: "empty request and close"}, {closeSend: true, desc: "no request just close"}, } @@ -196,7 +196,7 @@ func TestFailedMergeConcurrentUpdate(t *testing.T) { prepareMergeBranch(t, testRepoPath) mergeCommitMessage := "Merged by Gitaly" - firstRequest := &pb.UserMergeBranchRequest{ + firstRequest := &gitalypb.UserMergeBranchRequest{ Repository: testRepo, User: mergeUser, CommitId: commitToMerge, @@ -212,12 +212,12 @@ func TestFailedMergeConcurrentUpdate(t *testing.T) { concurrentCommitID := testhelper.CreateCommit(t, testRepoPath, mergeBranchName, nil) require.NotEqual(t, firstResponse.CommitId, concurrentCommitID) - require.NoError(t, mergeBidi.Send(&pb.UserMergeBranchRequest{Apply: true}), "apply merge") + require.NoError(t, mergeBidi.Send(&gitalypb.UserMergeBranchRequest{Apply: true}), "apply merge") require.NoError(t, mergeBidi.CloseSend(), "close send") secondResponse, err := mergeBidi.Recv() require.NoError(t, err, "receive second response") - require.Equal(t, *secondResponse, pb.UserMergeBranchResponse{}, "response should be empty") + require.Equal(t, *secondResponse, gitalypb.UserMergeBranchResponse{}, "response should be empty") commit, err := gitlog.GetCommit(ctx, testRepo, mergeBranchName) require.NoError(t, err, "get commit after RPC finished") @@ -252,7 +252,7 @@ func TestFailedMergeDueToHooks(t *testing.T) { require.NoError(t, err) mergeCommitMessage := "Merged by Gitaly" - firstRequest := &pb.UserMergeBranchRequest{ + firstRequest := &gitalypb.UserMergeBranchRequest{ Repository: testRepo, User: mergeUser, CommitId: commitToMerge, @@ -265,7 +265,7 @@ func TestFailedMergeDueToHooks(t *testing.T) { _, err = mergeBidi.Recv() require.NoError(t, err, "receive first response") - require.NoError(t, mergeBidi.Send(&pb.UserMergeBranchRequest{Apply: true}), "apply merge") + require.NoError(t, mergeBidi.Send(&gitalypb.UserMergeBranchRequest{Apply: true}), "apply merge") require.NoError(t, mergeBidi.CloseSend(), "close send") secondResponse, err := mergeBidi.Recv() @@ -300,14 +300,14 @@ func TestSuccessfulUserFFBranchRequest(t *testing.T) { commitID := "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" branchName := "test-ff-target-branch" - request := &pb.UserFFBranchRequest{ + request := &gitalypb.UserFFBranchRequest{ Repository: testRepo, CommitId: commitID, Branch: []byte(branchName), User: mergeUser, } - expectedResponse := &pb.UserFFBranchResponse{ - BranchUpdate: &pb.OperationBranchUpdate{ + expectedResponse := &gitalypb.UserFFBranchResponse{ + BranchUpdate: &gitalypb.OperationBranchUpdate{ RepoCreated: false, BranchCreated: false, CommitId: commitID, @@ -342,10 +342,10 @@ func TestFailedUserFFBranchRequest(t *testing.T) { testCases := []struct { desc string - user *pb.User + user *gitalypb.User branch []byte commitID string - repo *pb.Repository + repo *gitalypb.Repository code codes.Code }{ { @@ -407,7 +407,7 @@ func TestFailedUserFFBranchRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.UserFFBranchRequest{ + request := &gitalypb.UserFFBranchRequest{ Repository: testCase.repo, User: testCase.user, Branch: testCase.branch, @@ -431,7 +431,7 @@ func TestFailedUserFFBranchDueToHooks(t *testing.T) { commitID := "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" branchName := "test-ff-target-branch" - request := &pb.UserFFBranchRequest{ + request := &gitalypb.UserFFBranchRequest{ Repository: testRepo, CommitId: commitID, Branch: []byte(branchName), @@ -492,9 +492,9 @@ func deleteBranch(testRepoPath, branchName string) { // This error is used as a sentinel value var errRecvTimeout = fmt.Errorf("timeout waiting for response") -func recvTimeout(bidi pb.OperationService_UserMergeBranchClient, timeout time.Duration) (*pb.UserMergeBranchResponse, error) { +func recvTimeout(bidi gitalypb.OperationService_UserMergeBranchClient, timeout time.Duration) (*gitalypb.UserMergeBranchResponse, error) { type responseError struct { - response *pb.UserMergeBranchResponse + response *gitalypb.UserMergeBranchResponse err error } responseCh := make(chan responseError, 1) diff --git a/internal/service/operations/rebase.go b/internal/service/operations/rebase.go index 58b04666a..dcb560f92 100644 --- a/internal/service/operations/rebase.go +++ b/internal/service/operations/rebase.go @@ -3,16 +3,15 @@ package operations import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UserRebase(ctx context.Context, req *pb.UserRebaseRequest) (*pb.UserRebaseResponse, error) { +func (s *server) UserRebase(ctx context.Context, req *gitalypb.UserRebaseRequest) (*gitalypb.UserRebaseResponse, error) { if err := validateUserRebaseRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "UserRebase: %v", err) } @@ -30,7 +29,7 @@ func (s *server) UserRebase(ctx context.Context, req *pb.UserRebaseRequest) (*pb return client.UserRebase(clientCtx, req) } -func validateUserRebaseRequest(req *pb.UserRebaseRequest) error { +func validateUserRebaseRequest(req *gitalypb.UserRebaseRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/operations/rebase_test.go b/internal/service/operations/rebase_test.go index 9de5af113..f299af4bf 100644 --- a/internal/service/operations/rebase_test.go +++ b/internal/service/operations/rebase_test.go @@ -7,11 +7,10 @@ import ( "strings" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/service/operations" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" @@ -37,13 +36,13 @@ func TestSuccessfulUserRebaseRequest(t *testing.T) { branchSha := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "rev-parse", branchName)) branchSha = strings.TrimSpace(branchSha) - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", } - request := &pb.UserRebaseRequest{ + request := &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", @@ -86,13 +85,13 @@ func TestFailedUserRebaseRequestDueToPreReceiveError(t *testing.T) { branchSha := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "rev-parse", branchName)) branchSha = strings.TrimSpace(branchSha) - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", } - request := &pb.UserRebaseRequest{ + request := &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", @@ -140,13 +139,13 @@ func TestFailedUserRebaseRequestDueToGitError(t *testing.T) { branchSha := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "rev-parse", branchName)) branchSha = strings.TrimSpace(branchSha) - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", } - request := &pb.UserRebaseRequest{ + request := &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", @@ -180,7 +179,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { testRepoCopy, _, cleanup := testhelper.NewTestRepo(t) defer cleanup() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -188,12 +187,12 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.UserRebaseRequest + request *gitalypb.UserRebaseRequest code codes.Code }{ { desc: "empty repository", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: nil, User: user, RebaseId: "1", @@ -206,7 +205,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { }, { desc: "empty user", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: testRepo, User: nil, RebaseId: "1", @@ -219,7 +218,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { }, { desc: "empty rebase id", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "", @@ -232,7 +231,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { }, { desc: "empty branch", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", @@ -245,7 +244,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { }, { desc: "empty branch sha", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", @@ -258,7 +257,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { }, { desc: "empty remote repository", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", @@ -271,7 +270,7 @@ func TestFailedUserRebaseRequestDueToValidations(t *testing.T) { }, { desc: "empty remote branch", - request: &pb.UserRebaseRequest{ + request: &gitalypb.UserRebaseRequest{ Repository: testRepo, User: user, RebaseId: "1", diff --git a/internal/service/operations/revert.go b/internal/service/operations/revert.go index c7dff23d2..2c501c449 100644 --- a/internal/service/operations/revert.go +++ b/internal/service/operations/revert.go @@ -1,15 +1,14 @@ package operations import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UserRevert(ctx context.Context, req *pb.UserRevertRequest) (*pb.UserRevertResponse, error) { +func (s *server) UserRevert(ctx context.Context, req *gitalypb.UserRevertRequest) (*gitalypb.UserRevertResponse, error) { if err := validateCherryPickOrRevertRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "UserRevert: %v", err) } diff --git a/internal/service/operations/revert_test.go b/internal/service/operations/revert_test.go index fbe0f1e3c..fea3784ae 100644 --- a/internal/service/operations/revert_test.go +++ b/internal/service/operations/revert_test.go @@ -6,12 +6,11 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/service/operations" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" @@ -36,7 +35,7 @@ func TestSuccessfulUserRevertRequest(t *testing.T) { masterHeadCommit, err := log.GetCommit(ctxOuter, testRepo, "master") require.NoError(t, err) - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -50,23 +49,23 @@ func TestSuccessfulUserRevertRequest(t *testing.T) { testCases := []struct { desc string - request *pb.UserRevertRequest - branchUpdate *pb.OperationBranchUpdate + request *gitalypb.UserRevertRequest + branchUpdate *gitalypb.OperationBranchUpdate }{ { desc: "branch exists", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, BranchName: []byte(destinationBranch), Message: []byte("Reverting " + revertedCommit.Id), }, - branchUpdate: &pb.OperationBranchUpdate{}, + branchUpdate: &gitalypb.OperationBranchUpdate{}, }, { desc: "nonexistent branch + start_repository == repository", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -74,11 +73,11 @@ func TestSuccessfulUserRevertRequest(t *testing.T) { Message: []byte("Reverting " + revertedCommit.Id), StartBranchName: []byte("master"), }, - branchUpdate: &pb.OperationBranchUpdate{BranchCreated: true}, + branchUpdate: &gitalypb.OperationBranchUpdate{BranchCreated: true}, }, { desc: "nonexistent branch + start_repository != repository", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -87,11 +86,11 @@ func TestSuccessfulUserRevertRequest(t *testing.T) { StartRepository: testRepoCopy, StartBranchName: []byte("master"), }, - branchUpdate: &pb.OperationBranchUpdate{BranchCreated: true}, + branchUpdate: &gitalypb.OperationBranchUpdate{BranchCreated: true}, }, { desc: "nonexistent branch + empty start_repository", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -99,7 +98,7 @@ func TestSuccessfulUserRevertRequest(t *testing.T) { Message: []byte("Reverting " + revertedCommit.Id), StartBranchName: []byte("master"), }, - branchUpdate: &pb.OperationBranchUpdate{BranchCreated: true}, + branchUpdate: &gitalypb.OperationBranchUpdate{BranchCreated: true}, }, } @@ -140,7 +139,7 @@ func TestSuccessfulGitHooksForUserRevertRequest(t *testing.T) { destinationBranch := "revert-dst" testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -149,7 +148,7 @@ func TestSuccessfulGitHooksForUserRevertRequest(t *testing.T) { revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e") require.NoError(t, err) - request := &pb.UserRevertRequest{ + request := &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -195,7 +194,7 @@ func TestFailedUserRevertRequestDueToValidations(t *testing.T) { destinationBranch := "revert-dst" - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -203,12 +202,12 @@ func TestFailedUserRevertRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.UserRevertRequest + request *gitalypb.UserRevertRequest code codes.Code }{ { desc: "empty user", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: nil, Commit: revertedCommit, @@ -219,7 +218,7 @@ func TestFailedUserRevertRequestDueToValidations(t *testing.T) { }, { desc: "empty commit", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: nil, @@ -230,7 +229,7 @@ func TestFailedUserRevertRequestDueToValidations(t *testing.T) { }, { desc: "empty branch name", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -241,7 +240,7 @@ func TestFailedUserRevertRequestDueToValidations(t *testing.T) { }, { desc: "empty message", - request: &pb.UserRevertRequest{ + request: &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -279,7 +278,7 @@ func TestFailedUserRevertRequestDueToPreReceiveError(t *testing.T) { destinationBranch := "revert-dst" testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -288,7 +287,7 @@ func TestFailedUserRevertRequestDueToPreReceiveError(t *testing.T) { revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e") require.NoError(t, err) - request := &pb.UserRevertRequest{ + request := &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -330,7 +329,7 @@ func TestFailedUserRevertRequestDueToCreateTreeError(t *testing.T) { destinationBranch := "revert-dst" testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -340,7 +339,7 @@ func TestFailedUserRevertRequestDueToCreateTreeError(t *testing.T) { revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "372ab6950519549b14d220271ee2322caa44d4eb") require.NoError(t, err) - request := &pb.UserRevertRequest{ + request := &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, @@ -374,7 +373,7 @@ func TestFailedUserRevertRequestDueToCommitError(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master") testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", sourceBranch, "a5391128b0ef5d21df5dd23d98557f4ef12fae20") - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -383,7 +382,7 @@ func TestFailedUserRevertRequestDueToCommitError(t *testing.T) { revertedCommit, err := log.GetCommit(ctxOuter, testRepo, sourceBranch) require.NoError(t, err) - request := &pb.UserRevertRequest{ + request := &gitalypb.UserRevertRequest{ Repository: testRepo, User: user, Commit: revertedCommit, diff --git a/internal/service/operations/server.go b/internal/service/operations/server.go index cac7373df..7a26c69f6 100644 --- a/internal/service/operations/server.go +++ b/internal/service/operations/server.go @@ -1,9 +1,8 @@ package operations import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) type server struct { @@ -11,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a grpc OperationServiceServer -func NewServer(rs *rubyserver.Server) pb.OperationServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.OperationServiceServer { return &server{rs} } diff --git a/internal/service/operations/squash.go b/internal/service/operations/squash.go index 83e1ff88e..8e007f693 100644 --- a/internal/service/operations/squash.go +++ b/internal/service/operations/squash.go @@ -3,14 +3,14 @@ package operations import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UserSquash(ctx context.Context, req *pb.UserSquashRequest) (*pb.UserSquashResponse, error) { +func (s *server) UserSquash(ctx context.Context, req *gitalypb.UserSquashRequest) (*gitalypb.UserSquashResponse, error) { if err := validateUserSquashRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "UserSquash: %v", err) } @@ -28,7 +28,7 @@ func (s *server) UserSquash(ctx context.Context, req *pb.UserSquashRequest) (*pb return client.UserSquash(clientCtx, req) } -func validateUserSquashRequest(req *pb.UserSquashRequest) error { +func validateUserSquashRequest(req *gitalypb.UserSquashRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/operations/squash_test.go b/internal/service/operations/squash_test.go index 94b599f5f..29d13183c 100644 --- a/internal/service/operations/squash_test.go +++ b/internal/service/operations/squash_test.go @@ -4,14 +4,14 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) var ( - author = &pb.User{ + author = &gitalypb.User{ Name: []byte("John Doe"), Email: []byte("johndoe@gitlab.com"), } @@ -34,7 +34,7 @@ func TestSuccessfulUserSquashRequest(t *testing.T) { testRepo, _, cleanup := testhelper.NewTestRepo(t) defer cleanup() - request := &pb.UserSquashRequest{ + request := &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", @@ -73,7 +73,7 @@ func TestFailedUserSquashRequestDueToGitError(t *testing.T) { conflictingStartSha := "bbd36ad238d14e1c03ece0f3358f545092dc9ca3" branchName := "gitaly-stuff" - request := &pb.UserSquashRequest{ + request := &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", @@ -101,12 +101,12 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.UserSquashRequest + request *gitalypb.UserSquashRequest code codes.Code }{ { desc: "empty Repository", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: nil, User: user, SquashId: "1", @@ -120,7 +120,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty User", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: nil, SquashId: "1", @@ -134,7 +134,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty SquashId", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "", @@ -148,7 +148,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty Branch", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", @@ -162,7 +162,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty StartSha", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", @@ -176,7 +176,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty EndSha", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", @@ -190,7 +190,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty Author", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", @@ -204,7 +204,7 @@ func TestFailedUserSquashRequestDueToValidations(t *testing.T) { }, { desc: "empty CommitMessage", - request: &pb.UserSquashRequest{ + request: &gitalypb.UserSquashRequest{ Repository: testRepo, User: user, SquashId: "1", diff --git a/internal/service/operations/tags.go b/internal/service/operations/tags.go index 762896283..7377ccf33 100644 --- a/internal/service/operations/tags.go +++ b/internal/service/operations/tags.go @@ -1,14 +1,13 @@ package operations import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" ) -func (s *server) UserDeleteTag(ctx context.Context, req *pb.UserDeleteTagRequest) (*pb.UserDeleteTagResponse, error) { +func (s *server) UserDeleteTag(ctx context.Context, req *gitalypb.UserDeleteTagRequest) (*gitalypb.UserDeleteTagResponse, error) { client, err := s.OperationServiceClient(ctx) if err != nil { return nil, err @@ -22,7 +21,7 @@ func (s *server) UserDeleteTag(ctx context.Context, req *pb.UserDeleteTagRequest return client.UserDeleteTag(clientCtx, req) } -func (s *server) UserCreateTag(ctx context.Context, req *pb.UserCreateTagRequest) (*pb.UserCreateTagResponse, error) { +func (s *server) UserCreateTag(ctx context.Context, req *gitalypb.UserCreateTagRequest) (*gitalypb.UserCreateTagResponse, error) { client, err := s.OperationServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/operations/tags_test.go b/internal/service/operations/tags_test.go index 0b033826c..f47ebc207 100644 --- a/internal/service/operations/tags_test.go +++ b/internal/service/operations/tags_test.go @@ -8,11 +8,10 @@ import ( "strings" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -34,7 +33,7 @@ func TestSuccessfulUserDeleteTagRequest(t *testing.T) { defer exec.Command("git", "-C", testRepoPath, "tag", "-d", tagNameInput).Run() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -42,7 +41,7 @@ func TestSuccessfulUserDeleteTagRequest(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "tag", tagNameInput) - request := &pb.UserDeleteTagRequest{ + request := &gitalypb.UserDeleteTagRequest{ Repository: testRepo, TagName: []byte(tagNameInput), User: user, @@ -68,14 +67,14 @@ func TestSuccessfulGitHooksForUserDeleteTagRequest(t *testing.T) { tagNameInput := "to-be-deleted-soon-tag" defer exec.Command("git", "-C", testRepoPath, "tag", "-d", tagNameInput).Run() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", GlUsername: "johndoe", } - request := &pb.UserDeleteTagRequest{ + request := &gitalypb.UserDeleteTagRequest{ Repository: testRepo, TagName: []byte(tagNameInput), User: user, @@ -119,7 +118,7 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) { targetRevisionCommit, err := log.GetCommit(ctx, testRepo, targetRevision) require.NoError(t, err) - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -131,13 +130,13 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) { tagName string message string targetRevision string - expectedTag *pb.Tag + expectedTag *gitalypb.Tag }{ { desc: "lightweight tag", tagName: inputTagName, targetRevision: targetRevision, - expectedTag: &pb.Tag{ + expectedTag: &gitalypb.Tag{ Name: []byte(inputTagName), TargetCommit: targetRevisionCommit, }, @@ -147,7 +146,7 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) { tagName: inputTagName, targetRevision: targetRevision, message: "This is an annotated tag", - expectedTag: &pb.Tag{ + expectedTag: &gitalypb.Tag{ Name: []byte(inputTagName), TargetCommit: targetRevisionCommit, Message: []byte("This is an annotated tag"), @@ -158,7 +157,7 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.UserCreateTagRequest{ + request := &gitalypb.UserCreateTagRequest{ Repository: testRepo, TagName: []byte(inputTagName), TargetRevision: []byte(testCase.targetRevision), @@ -196,13 +195,13 @@ func TestSuccessfulGitHooksForUserCreateTagRequest(t *testing.T) { defer cleanupFn() tagName := "new-tag" - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", GlUsername: "johndoe", } - request := &pb.UserCreateTagRequest{ + request := &gitalypb.UserCreateTagRequest{ Repository: testRepo, TagName: []byte(tagName), TargetRevision: []byte("c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"), @@ -241,7 +240,7 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -249,12 +248,12 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) { testCases := []struct { desc string - request *pb.UserDeleteTagRequest + request *gitalypb.UserDeleteTagRequest code codes.Code }{ { desc: "empty user", - request: &pb.UserDeleteTagRequest{ + request: &gitalypb.UserDeleteTagRequest{ Repository: testRepo, TagName: []byte("does-matter-the-name-if-user-is-empty"), }, @@ -262,7 +261,7 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) { }, { desc: "empty tag name", - request: &pb.UserDeleteTagRequest{ + request: &gitalypb.UserDeleteTagRequest{ Repository: testRepo, User: user, }, @@ -270,7 +269,7 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) { }, { desc: "non-existent tag name", - request: &pb.UserDeleteTagRequest{ + request: &gitalypb.UserDeleteTagRequest{ Repository: testRepo, User: user, TagName: []byte("i-do-not-exist"), @@ -304,13 +303,13 @@ func TestFailedUserDeleteTagDueToHooks(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "tag", tagNameInput) defer exec.Command("git", "-C", testRepoPath, "tag", "-d", tagNameInput).Run() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", } - request := &pb.UserDeleteTagRequest{ + request := &gitalypb.UserDeleteTagRequest{ Repository: testRepo, TagName: []byte(tagNameInput), User: user, @@ -347,13 +346,13 @@ func TestFailedUserCreateTagDueToHooks(t *testing.T) { testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", GlUsername: "johndoe", } - request := &pb.UserCreateTagRequest{ + request := &gitalypb.UserCreateTagRequest{ Repository: testRepo, TagName: []byte("new-tag"), TargetRevision: []byte("c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"), @@ -386,7 +385,7 @@ func TestFailedUserCreateTagRequestDueToTagExistence(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -395,14 +394,14 @@ func TestFailedUserCreateTagRequestDueToTagExistence(t *testing.T) { testCase := struct { tagName string targetRevision string - user *pb.User + user *gitalypb.User }{ tagName: "v1.1.0", targetRevision: "master", user: user, } - request := &pb.UserCreateTagRequest{ + request := &gitalypb.UserCreateTagRequest{ Repository: testRepo, TagName: []byte(testCase.tagName), TargetRevision: []byte(testCase.targetRevision), @@ -427,7 +426,7 @@ func TestFailedUserCreateTagRequestDueToValidation(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - user := &pb.User{ + user := &gitalypb.User{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), GlId: "user-123", @@ -437,7 +436,7 @@ func TestFailedUserCreateTagRequestDueToValidation(t *testing.T) { desc string tagName string targetRevision string - user *pb.User + user *gitalypb.User code codes.Code }{ { @@ -465,7 +464,7 @@ func TestFailedUserCreateTagRequestDueToValidation(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.UserCreateTagRequest{ + request := &gitalypb.UserCreateTagRequest{ Repository: testRepo, TagName: []byte(testCase.tagName), TargetRevision: []byte(testCase.targetRevision), diff --git a/internal/service/operations/testhelper_test.go b/internal/service/operations/testhelper_test.go index 182ccd97c..9c7c7c6df 100644 --- a/internal/service/operations/testhelper_test.go +++ b/internal/service/operations/testhelper_test.go @@ -9,11 +9,10 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" "google.golang.org/grpc" @@ -26,7 +25,7 @@ var ( GitlabPreHooks = gitlabPreHooks GitlabHooks []string RubyServer *rubyserver.Server - user = &pb.User{ + user = &gitalypb.User{ Name: []byte("Jane Doe"), Email: []byte("janedoe@gitlab.com"), GlId: "user-123", @@ -69,7 +68,7 @@ func runOperationServiceServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterOperationServiceServer(grpcServer, &server{RubyServer}) + gitalypb.RegisterOperationServiceServer(grpcServer, &server{RubyServer}) reflection.Register(grpcServer) go grpcServer.Serve(listener) @@ -77,7 +76,7 @@ func runOperationServiceServer(t *testing.T) (*grpc.Server, string) { return grpcServer, serverSocketPath } -func newOperationClient(t *testing.T, serverSocketPath string) (pb.OperationServiceClient, *grpc.ClientConn) { +func newOperationClient(t *testing.T, serverSocketPath string) (gitalypb.OperationServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -89,7 +88,7 @@ func newOperationClient(t *testing.T, serverSocketPath string) (pb.OperationServ t.Fatal(err) } - return pb.NewOperationServiceClient(conn), conn + return gitalypb.NewOperationServiceClient(conn), conn } var NewOperationClient = newOperationClient diff --git a/internal/service/operations/update_branches_test.go b/internal/service/operations/update_branches_test.go index bd6061f2b..6cc0aac1f 100644 --- a/internal/service/operations/update_branches_test.go +++ b/internal/service/operations/update_branches_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" @@ -33,7 +33,7 @@ func TestSuccessfulUserUpdateBranchRequest(t *testing.T) { client, conn := newOperationClient(t, serverSocketPath) defer conn.Close() - request := &pb.UserUpdateBranchRequest{ + request := &gitalypb.UserUpdateBranchRequest{ Repository: testRepo, BranchName: []byte(updateBranchName), Newrev: newrev, @@ -71,7 +71,7 @@ func TestSuccessfulGitHooksForUserUpdateBranchRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.UserUpdateBranchRequest{ + request := &gitalypb.UserUpdateBranchRequest{ Repository: testRepo, BranchName: []byte(updateBranchName), Newrev: newrev, @@ -100,7 +100,7 @@ func TestFailedUserUpdateBranchDueToHooks(t *testing.T) { client, conn := newOperationClient(t, serverSocketPath) defer conn.Close() - request := &pb.UserUpdateBranchRequest{ + request := &gitalypb.UserUpdateBranchRequest{ Repository: testRepo, BranchName: []byte(updateBranchName), Newrev: newrev, @@ -144,7 +144,7 @@ func TestFailedUserUpdateBranchRequest(t *testing.T) { branchName string newrev []byte oldrev []byte - user *pb.User + user *gitalypb.User code codes.Code }{ { @@ -207,7 +207,7 @@ func TestFailedUserUpdateBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.UserUpdateBranchRequest{ + request := &gitalypb.UserUpdateBranchRequest{ Repository: testRepo, BranchName: []byte(testCase.branchName), Newrev: testCase.newrev, diff --git a/internal/service/operations/utils.go b/internal/service/operations/utils.go index 0818907fc..1a4bc3375 100644 --- a/internal/service/operations/utils.go +++ b/internal/service/operations/utils.go @@ -3,12 +3,12 @@ package operations import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) type cherryPickOrRevertRequest interface { - GetUser() *pb.User - GetCommit() *pb.GitCommit + GetUser() *gitalypb.User + GetCommit() *gitalypb.GitCommit GetBranchName() []byte GetMessage() []byte } diff --git a/internal/service/ref/branches.go b/internal/service/ref/branches.go index e79f73b77..3f5aec1e7 100644 --- a/internal/service/ref/branches.go +++ b/internal/service/ref/branches.go @@ -1,14 +1,13 @@ package ref import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" ) -func (s *server) CreateBranch(ctx context.Context, req *pb.CreateBranchRequest) (*pb.CreateBranchResponse, error) { +func (s *server) CreateBranch(ctx context.Context, req *gitalypb.CreateBranchRequest) (*gitalypb.CreateBranchResponse, error) { client, err := s.RefServiceClient(ctx) if err != nil { return nil, err @@ -22,7 +21,7 @@ func (s *server) CreateBranch(ctx context.Context, req *pb.CreateBranchRequest) return client.CreateBranch(clientCtx, req) } -func (s *server) DeleteBranch(ctx context.Context, req *pb.DeleteBranchRequest) (*pb.DeleteBranchResponse, error) { +func (s *server) DeleteBranch(ctx context.Context, req *gitalypb.DeleteBranchRequest) (*gitalypb.DeleteBranchResponse, error) { client, err := s.RefServiceClient(ctx) if err != nil { return nil, err @@ -36,7 +35,7 @@ func (s *server) DeleteBranch(ctx context.Context, req *pb.DeleteBranchRequest) return client.DeleteBranch(clientCtx, req) } -func (s *server) FindBranch(ctx context.Context, req *pb.FindBranchRequest) (*pb.FindBranchResponse, error) { +func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest) (*gitalypb.FindBranchResponse, error) { client, err := s.RefServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/ref/branches_test.go b/internal/service/ref/branches_test.go index 54f386b36..7fe679779 100644 --- a/internal/service/ref/branches_test.go +++ b/internal/service/ref/branches_test.go @@ -5,11 +5,10 @@ import ( "os/exec" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -37,12 +36,12 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) { testCases := []struct { desc string startPoint string - expectedBranch *pb.Branch + expectedBranch *gitalypb.Branch }{ { desc: "empty start point", startPoint: "", - expectedBranch: &pb.Branch{ + expectedBranch: &gitalypb.Branch{ Name: []byte("to-be-created-soon-1"), TargetCommit: headCommit, }, @@ -50,7 +49,7 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) { { desc: "present start point", startPoint: startPoint, - expectedBranch: &pb.Branch{ + expectedBranch: &gitalypb.Branch{ Name: []byte("to-be-created-soon-2"), TargetCommit: startPointCommit, }, @@ -60,7 +59,7 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { branchName := testCase.expectedBranch.Name - request := &pb.CreateBranchRequest{ + request := &gitalypb.CreateBranchRequest{ Repository: testRepo, Name: branchName, StartPoint: []byte(testCase.startPoint), @@ -73,7 +72,7 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) { defer exec.Command("git", "-C", testRepoPath, "branch", "-D", string(branchName)).Run() require.NoError(t, err) - require.Equal(t, pb.CreateBranchResponse_OK, response.Status, "mismatched status") + require.Equal(t, gitalypb.CreateBranchResponse_OK, response.Status, "mismatched status") require.Equal(t, testCase.expectedBranch, response.Branch, "mismatched branches") }) } @@ -93,29 +92,29 @@ func TestFailedCreateBranchRequest(t *testing.T) { desc string branchName string startPoint string - status pb.CreateBranchResponse_Status + status gitalypb.CreateBranchResponse_Status }{ { desc: "branch exists", branchName: "master", - status: pb.CreateBranchResponse_ERR_EXISTS, + status: gitalypb.CreateBranchResponse_ERR_EXISTS, }, { desc: "empty branch name", branchName: "", - status: pb.CreateBranchResponse_ERR_INVALID, + status: gitalypb.CreateBranchResponse_ERR_INVALID, }, { desc: "invalid start point", branchName: "shiny-new-branch", startPoint: "i-do-not-exist", - status: pb.CreateBranchResponse_ERR_INVALID_START_POINT, + status: gitalypb.CreateBranchResponse_ERR_INVALID_START_POINT, }, } for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.CreateBranchRequest{ + request := &gitalypb.CreateBranchRequest{ Repository: testRepo, Name: []byte(testCase.branchName), StartPoint: []byte(testCase.startPoint), @@ -164,7 +163,7 @@ func TestSuccessfulDeleteBranchRequest(t *testing.T) { t.Run(testCase.desc, func(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", branchNameInput) - request := &pb.DeleteBranchRequest{ + request := &gitalypb.DeleteBranchRequest{ Repository: testRepo, Name: []byte(testCase.branchName), } @@ -210,7 +209,7 @@ func TestFailedDeleteBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.DeleteBranchRequest{ + request := &gitalypb.DeleteBranchRequest{ Repository: testRepo, Name: []byte(testCase.branchName), } @@ -241,7 +240,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) { branchTarget, err := log.GetCommit(ctx, testRepo, branchNameInput) require.NoError(t, err) - branch := &pb.Branch{ + branch := &gitalypb.Branch{ Name: []byte(branchNameInput), TargetCommit: branchTarget, } @@ -249,7 +248,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) { testCases := []struct { desc string branchName string - expectedBranch *pb.Branch + expectedBranch *gitalypb.Branch }{ { desc: "regular branch name", @@ -274,7 +273,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.FindBranchRequest{ + request := &gitalypb.FindBranchRequest{ Repository: testRepo, Name: []byte(testCase.branchName), } @@ -315,7 +314,7 @@ func TestFailedFindBranchRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - request := &pb.FindBranchRequest{ + request := &gitalypb.FindBranchRequest{ Repository: testRepo, Name: []byte(testCase.branchName), } diff --git a/internal/service/ref/delete_refs.go b/internal/service/ref/delete_refs.go index d9e88a55c..27d9f9211 100644 --- a/internal/service/ref/delete_refs.go +++ b/internal/service/ref/delete_refs.go @@ -3,14 +3,14 @@ package ref import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) DeleteRefs(ctx context.Context, in *pb.DeleteRefsRequest) (*pb.DeleteRefsResponse, error) { +func (s *server) DeleteRefs(ctx context.Context, in *gitalypb.DeleteRefsRequest) (*gitalypb.DeleteRefsResponse, error) { if err := validateDeleteRefRequest(in); err != nil { return nil, status.Errorf(codes.InvalidArgument, "DeleteRefs: %v", err) } @@ -28,7 +28,7 @@ func (s *server) DeleteRefs(ctx context.Context, in *pb.DeleteRefsRequest) (*pb. return client.DeleteRefs(clientCtx, in) } -func validateDeleteRefRequest(req *pb.DeleteRefsRequest) error { +func validateDeleteRefRequest(req *gitalypb.DeleteRefsRequest) error { if len(req.ExceptWithPrefix) > 0 && len(req.Refs) > 0 { return fmt.Errorf("ExceptWithPrefix and Refs are mutually exclusive") } diff --git a/internal/service/ref/delete_refs_test.go b/internal/service/ref/delete_refs_test.go index 54487cec8..491bc80e4 100644 --- a/internal/service/ref/delete_refs_test.go +++ b/internal/service/ref/delete_refs_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -20,17 +20,17 @@ func TestSuccessfulDeleteRefs(t *testing.T) { testCases := []struct { desc string - request *pb.DeleteRefsRequest + request *gitalypb.DeleteRefsRequest }{ { desc: "delete all except refs with certain prefixes", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ ExceptWithPrefix: [][]byte{[]byte("refs/keep"), []byte("refs/also-keep"), []byte("refs/heads/")}, }, }, { desc: "delete certain refs", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ Refs: [][]byte{[]byte("refs/delete/a"), []byte("refs/also-delete/b")}, }, }, @@ -77,7 +77,7 @@ func TestFailedDeleteRefsRequestDueToGitError(t *testing.T) { repo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.DeleteRefsRequest{ + request := &gitalypb.DeleteRefsRequest{ Repository: repo, Refs: [][]byte{[]byte(`refs\tails\invalid-ref-format`)}, } @@ -100,22 +100,22 @@ func TestFailedDeleteRefsDueToValidation(t *testing.T) { testCases := []struct { desc string - request *pb.DeleteRefsRequest - // repo *pb.Repository + request *gitalypb.DeleteRefsRequest + // repo *gitalypb.Repository // prefixes [][]byte code codes.Code }{ { desc: "Invalid repository", - request: &pb.DeleteRefsRequest{ - Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, + request: &gitalypb.DeleteRefsRequest{ + Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, ExceptWithPrefix: [][]byte{[]byte("exclude-this")}, }, code: codes.InvalidArgument, }, { desc: "Repository is nil", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ Repository: nil, ExceptWithPrefix: [][]byte{[]byte("exclude-this")}, }, @@ -123,14 +123,14 @@ func TestFailedDeleteRefsDueToValidation(t *testing.T) { }, { desc: "No prefixes nor refs", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ Repository: testRepo, }, code: codes.InvalidArgument, }, { desc: "prefixes with refs", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ Repository: testRepo, ExceptWithPrefix: [][]byte{[]byte("exclude-this")}, Refs: [][]byte{[]byte("delete-this")}, @@ -139,7 +139,7 @@ func TestFailedDeleteRefsDueToValidation(t *testing.T) { }, { desc: "Empty prefix", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ Repository: testRepo, ExceptWithPrefix: [][]byte{[]byte("exclude-this"), []byte{}}, }, @@ -147,7 +147,7 @@ func TestFailedDeleteRefsDueToValidation(t *testing.T) { }, { desc: "Empty ref", - request: &pb.DeleteRefsRequest{ + request: &gitalypb.DeleteRefsRequest{ Repository: testRepo, Refs: [][]byte{[]byte("delete-this"), []byte{}}, }, diff --git a/internal/service/ref/list_new_blobs.go b/internal/service/ref/list_new_blobs.go index bd975981c..ff3dcd3a9 100644 --- a/internal/service/ref/list_new_blobs.go +++ b/internal/service/ref/list_new_blobs.go @@ -6,14 +6,14 @@ import ( "regexp" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) ListNewBlobs(in *pb.ListNewBlobsRequest, stream pb.RefService_ListNewBlobsServer) error { +func (s *server) ListNewBlobs(in *gitalypb.ListNewBlobsRequest, stream gitalypb.RefService_ListNewBlobsServer) error { oid := in.GetCommitId() if err := validateCommitID(oid); err != nil { return err @@ -39,7 +39,7 @@ func (s *server) ListNewBlobs(in *pb.ListNewBlobsRequest, stream pb.RefService_L return status.Errorf(codes.Internal, "ListNewBlobs: catfile: %v", err) } - var newBlobs []*pb.NewBlobObject + var newBlobs []*gitalypb.NewBlobObject scanner := bufio.NewScanner(revList) for scanner.Scan() { line := scanner.Text() @@ -58,15 +58,15 @@ func (s *server) ListNewBlobs(in *pb.ListNewBlobsRequest, stream pb.RefService_L continue } - newBlobs = append(newBlobs, &pb.NewBlobObject{Oid: info.Oid, Size: info.Size, Path: []byte(parts[1])}) + newBlobs = append(newBlobs, &gitalypb.NewBlobObject{Oid: info.Oid, Size: info.Size, Path: []byte(parts[1])}) if len(newBlobs) >= 1000 { - response := &pb.ListNewBlobsResponse{NewBlobObjects: newBlobs} + response := &gitalypb.ListNewBlobsResponse{NewBlobObjects: newBlobs} stream.Send(response) newBlobs = newBlobs[:0] } } - response := &pb.ListNewBlobsResponse{NewBlobObjects: newBlobs} + response := &gitalypb.ListNewBlobsResponse{NewBlobObjects: newBlobs} stream.Send(response) return revList.Wait() diff --git a/internal/service/ref/list_new_blobs_test.go b/internal/service/ref/list_new_blobs_test.go index 940a32c44..7ad96f26e 100644 --- a/internal/service/ref/list_new_blobs_test.go +++ b/internal/service/ref/list_new_blobs_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -29,14 +29,14 @@ func TestListNewBlobs(t *testing.T) { testCases := []struct { revision string - blobs []pb.NewBlobObject + blobs []gitalypb.NewBlobObject responseCode codes.Code }{ { revision: oid, - blobs: []pb.NewBlobObject{ - pb.NewBlobObject{Oid: "389c7a36a6e133268b0d36b00e7ffc0f3a5b6651", Path: []byte("gitaly/file-with-pluses.txt"), Size: 20}, - pb.NewBlobObject{Oid: "b1e67221afe8461efd244b487afca22d46b95eb8", Path: []byte("z-short-diff"), Size: 6}, + blobs: []gitalypb.NewBlobObject{ + gitalypb.NewBlobObject{Oid: "389c7a36a6e133268b0d36b00e7ffc0f3a5b6651", Path: []byte("gitaly/file-with-pluses.txt"), Size: 20}, + gitalypb.NewBlobObject{Oid: "b1e67221afe8461efd244b487afca22d46b95eb8", Path: []byte("z-short-diff"), Size: 6}, }, }, { @@ -53,12 +53,12 @@ func TestListNewBlobs(t *testing.T) { } for _, tc := range testCases { - request := &pb.ListNewBlobsRequest{Repository: testRepo, CommitId: tc.revision, Limit: 0} + request := &gitalypb.ListNewBlobsRequest{Repository: testRepo, CommitId: tc.revision, Limit: 0} stream, err := client.ListNewBlobs(ctx, request) require.NoError(t, err) - var blobs []*pb.NewBlobObject + var blobs []*gitalypb.NewBlobObject for { msg, err := stream.Recv() diff --git a/internal/service/ref/list_new_commits.go b/internal/service/ref/list_new_commits.go index 19eed1e35..4fb50c6f6 100644 --- a/internal/service/ref/list_new_commits.go +++ b/internal/service/ref/list_new_commits.go @@ -3,7 +3,7 @@ package ref import ( "bufio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/git/log" @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) ListNewCommits(in *pb.ListNewCommitsRequest, stream pb.RefService_ListNewCommitsServer) error { +func (s *server) ListNewCommits(in *gitalypb.ListNewCommitsRequest, stream gitalypb.RefService_ListNewCommitsServer) error { oid := in.GetCommitId() if err := validateCommitID(oid); err != nil { return err @@ -32,7 +32,7 @@ func (s *server) ListNewCommits(in *pb.ListNewCommitsRequest, stream pb.RefServi return status.Errorf(codes.Internal, "ListNewCommits: catfile: %v", err) } - commits := []*pb.GitCommit{} + commits := []*gitalypb.GitCommit{} scanner := bufio.NewScanner(revList) for scanner.Scan() { line := scanner.Text() @@ -44,7 +44,7 @@ func (s *server) ListNewCommits(in *pb.ListNewCommitsRequest, stream pb.RefServi commits = append(commits, commit) if len(commits) >= 10 { - response := &pb.ListNewCommitsResponse{Commits: commits} + response := &gitalypb.ListNewCommitsResponse{Commits: commits} if err := stream.Send(response); err != nil { return err } @@ -54,7 +54,7 @@ func (s *server) ListNewCommits(in *pb.ListNewCommitsRequest, stream pb.RefServi } if len(commits) > 0 { - response := &pb.ListNewCommitsResponse{Commits: commits} + response := &gitalypb.ListNewCommitsResponse{Commits: commits} if err := stream.Send(response); err != nil { return err } diff --git a/internal/service/ref/list_new_commits_test.go b/internal/service/ref/list_new_commits_test.go index 169f4b161..2bc13b3ab 100644 --- a/internal/service/ref/list_new_commits_test.go +++ b/internal/service/ref/list_new_commits_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -65,12 +65,12 @@ func TestListNewCommits(t *testing.T) { } for _, tc := range testCases { - request := &pb.ListNewCommitsRequest{Repository: testRepo, CommitId: tc.revision} + request := &gitalypb.ListNewCommitsRequest{Repository: testRepo, CommitId: tc.revision} stream, err := client.ListNewCommits(ctx, request) require.NoError(t, err) - var commits []*pb.GitCommit + var commits []*gitalypb.GitCommit for { msg, err := stream.Recv() diff --git a/internal/service/ref/refexists.go b/internal/service/ref/refexists.go index 6b3e82a6a..6ed3b2bce 100644 --- a/internal/service/ref/refexists.go +++ b/internal/service/ref/refexists.go @@ -8,24 +8,24 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "golang.org/x/net/context" ) // RefExists returns true if the given reference exists. The ref must start with the string `ref/` -func (server) RefExists(ctx context.Context, in *pb.RefExistsRequest) (*pb.RefExistsResponse, error) { +func (server) RefExists(ctx context.Context, in *gitalypb.RefExistsRequest) (*gitalypb.RefExistsResponse, error) { ref := string(in.Ref) exists, err := refExists(ctx, in.Repository, ref) if err != nil { return nil, err } - return &pb.RefExistsResponse{Value: exists}, nil + return &gitalypb.RefExistsResponse{Value: exists}, nil } -func refExists(ctx context.Context, repo *pb.Repository, ref string) (bool, error) { +func refExists(ctx context.Context, repo *gitalypb.Repository, ref string) (bool, error) { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "ref": ref, }).Debug("refExists") diff --git a/internal/service/ref/refexists_test.go b/internal/service/ref/refexists_test.go index 0eb0379d1..69e4bdf44 100644 --- a/internal/service/ref/refexists_test.go +++ b/internal/service/ref/refexists_test.go @@ -5,7 +5,7 @@ import ( "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -14,13 +14,13 @@ func TestRefExists(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - badRepo := &pb.Repository{StorageName: "invalid", RelativePath: "/etc/"} + badRepo := &gitalypb.Repository{StorageName: "invalid", RelativePath: "/etc/"} tests := []struct { name string ref string want bool - repo *pb.Repository + repo *gitalypb.Repository wantErr codes.Code }{ {"master", "refs/heads/master", true, testRepo, codes.OK}, @@ -48,7 +48,7 @@ func TestRefExists(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - req := &pb.RefExistsRequest{Repository: tt.repo, Ref: []byte(tt.ref)} + req := &gitalypb.RefExistsRequest{Repository: tt.repo, Ref: []byte(tt.ref)} got, err := client.RefExists(ctx, req) diff --git a/internal/service/ref/refname.go b/internal/service/ref/refname.go index 4beef0da7..d1e22a09e 100644 --- a/internal/service/ref/refname.go +++ b/internal/service/ref/refname.go @@ -9,7 +9,7 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "golang.org/x/net/context" ) @@ -17,7 +17,7 @@ import ( // FindRefName returns a ref that starts with the given prefix, if one exists. // If there is more than one such ref there is no guarantee which one is // returned or that the same one is returned on each call. -func (s *server) FindRefName(ctx context.Context, in *pb.FindRefNameRequest) (*pb.FindRefNameResponse, error) { +func (s *server) FindRefName(ctx context.Context, in *gitalypb.FindRefNameRequest) (*gitalypb.FindRefNameResponse, error) { if in.CommitId == "" { return nil, status.Errorf(codes.InvalidArgument, "Bad Request (empty commit sha)") } @@ -30,11 +30,11 @@ func (s *server) FindRefName(ctx context.Context, in *pb.FindRefNameRequest) (*p return nil, status.Errorf(codes.Internal, err.Error()) } - return &pb.FindRefNameResponse{Name: []byte(ref)}, nil + return &gitalypb.FindRefNameResponse{Name: []byte(ref)}, nil } // We assume `repo` and `commitID` and `prefix` are non-empty -func findRefName(ctx context.Context, repo *pb.Repository, commitID, prefix string) (string, error) { +func findRefName(ctx context.Context, repo *gitalypb.Repository, commitID, prefix string) (string, error) { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "commitSha": commitID, "prefix": prefix, diff --git a/internal/service/ref/refname_test.go b/internal/service/ref/refname_test.go index 232f67ae1..72cd3fc60 100644 --- a/internal/service/ref/refname_test.go +++ b/internal/service/ref/refname_test.go @@ -7,7 +7,7 @@ import ( "golang.org/x/net/context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -22,7 +22,7 @@ func TestFindRefNameSuccess(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindRefNameRequest{ + rpcRequest := &gitalypb.FindRefNameRequest{ Repository: testRepo, CommitId: "0b4bc9a49b562e85de7cc9e834518ea6828729b9", Prefix: []byte(`refs/heads/`), @@ -52,7 +52,7 @@ func TestFindRefNameEmptyCommit(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindRefNameRequest{ + rpcRequest := &gitalypb.FindRefNameRequest{ Repository: testRepo, CommitId: "", Prefix: []byte(`refs/heads/`), @@ -80,8 +80,8 @@ func TestFindRefNameInvalidRepo(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - repo := &pb.Repository{StorageName: "fake", RelativePath: "path"} - rpcRequest := &pb.FindRefNameRequest{ + repo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} + rpcRequest := &gitalypb.FindRefNameRequest{ Repository: repo, CommitId: "0b4bc9a49b562e85de7cc9e834518ea6828729b9", Prefix: []byte(`refs/heads/`), @@ -113,7 +113,7 @@ func TestFindRefNameInvalidPrefix(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindRefNameRequest{ + rpcRequest := &gitalypb.FindRefNameRequest{ Repository: testRepo, CommitId: "0b4bc9a49b562e85de7cc9e834518ea6828729b9", Prefix: []byte(`refs/nonexistant/`), @@ -140,7 +140,7 @@ func TestFindRefNameInvalidObject(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindRefNameRequest{ + rpcRequest := &gitalypb.FindRefNameRequest{ Repository: testRepo, CommitId: "dead1234dead1234dead1234dead1234dead1234", } diff --git a/internal/service/ref/refs.go b/internal/service/ref/refs.go index 2db68a039..86707bcca 100644 --- a/internal/service/ref/refs.go +++ b/internal/service/ref/refs.go @@ -13,7 +13,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/helper/lines" @@ -35,7 +35,7 @@ type findRefsOpts struct { delim []byte } -func findRefs(ctx context.Context, writer lines.Sender, repo *pb.Repository, patterns []string, opts *findRefsOpts) error { +func findRefs(ctx context.Context, writer lines.Sender, repo *gitalypb.Repository, patterns []string, opts *findRefsOpts) error { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "Patterns": patterns, }).Debug("FindRefs") @@ -63,16 +63,16 @@ func findRefs(ctx context.Context, writer lines.Sender, repo *pb.Repository, pat } // FindAllBranchNames creates a stream of ref names for all branches in the given repository -func (s *server) FindAllBranchNames(in *pb.FindAllBranchNamesRequest, stream pb.RefService_FindAllBranchNamesServer) error { +func (s *server) FindAllBranchNames(in *gitalypb.FindAllBranchNamesRequest, stream gitalypb.RefService_FindAllBranchNamesServer) error { return findRefs(stream.Context(), newFindAllBranchNamesWriter(stream), in.Repository, []string{"refs/heads"}, &findRefsOpts{}) } // FindAllTagNames creates a stream of ref names for all tags in the given repository -func (s *server) FindAllTagNames(in *pb.FindAllTagNamesRequest, stream pb.RefService_FindAllTagNamesServer) error { +func (s *server) FindAllTagNames(in *gitalypb.FindAllTagNamesRequest, stream gitalypb.RefService_FindAllTagNamesServer) error { return findRefs(stream.Context(), newFindAllTagNamesWriter(stream), in.Repository, []string{"refs/tags"}, &findRefsOpts{}) } -func (s *server) FindAllTags(in *pb.FindAllTagsRequest, stream pb.RefService_FindAllTagsServer) error { +func (s *server) FindAllTags(in *gitalypb.FindAllTagsRequest, stream gitalypb.RefService_FindAllTagsServer) error { ctx := stream.Context() client, err := s.RefServiceClient(ctx) @@ -101,7 +101,7 @@ func (s *server) FindAllTags(in *pb.FindAllTagsRequest, stream pb.RefService_Fin }) } -func _findBranchNames(ctx context.Context, repo *pb.Repository) ([][]byte, error) { +func _findBranchNames(ctx context.Context, repo *gitalypb.Repository) ([][]byte, error) { var names [][]byte cmd, err := git.Command(ctx, repo, "for-each-ref", "refs/heads", "--format=%(refname)") @@ -124,7 +124,7 @@ func _findBranchNames(ctx context.Context, repo *pb.Repository) ([][]byte, error return names, nil } -func _headReference(ctx context.Context, repo *pb.Repository) ([]byte, error) { +func _headReference(ctx context.Context, repo *gitalypb.Repository) ([]byte, error) { var headRef []byte cmd, err := git.Command(ctx, repo, "rev-parse", "--symbolic-full-name", "HEAD") @@ -153,7 +153,7 @@ func _headReference(ctx context.Context, repo *pb.Repository) ([]byte, error) { } // DefaultBranchName looks up the name of the default branch given a repoPath -func DefaultBranchName(ctx context.Context, repo *pb.Repository) ([]byte, error) { +func DefaultBranchName(ctx context.Context, repo *gitalypb.Repository) ([]byte, error) { branches, err := FindBranchNames(ctx, repo) if err != nil { @@ -194,7 +194,7 @@ func DefaultBranchName(ctx context.Context, repo *pb.Repository) ([]byte, error) } // FindDefaultBranchName returns the default branch name for the given repository -func (s *server) FindDefaultBranchName(ctx context.Context, in *pb.FindDefaultBranchNameRequest) (*pb.FindDefaultBranchNameResponse, error) { +func (s *server) FindDefaultBranchName(ctx context.Context, in *gitalypb.FindDefaultBranchNameRequest) (*gitalypb.FindDefaultBranchNameResponse, error) { grpc_logrus.Extract(ctx).Debug("FindDefaultBranchName") defaultBranchName, err := DefaultBranchName(ctx, in.Repository) @@ -205,16 +205,16 @@ func (s *server) FindDefaultBranchName(ctx context.Context, in *pb.FindDefaultBr return nil, status.Errorf(codes.Internal, err.Error()) } - return &pb.FindDefaultBranchNameResponse{Name: defaultBranchName}, nil + return &gitalypb.FindDefaultBranchNameResponse{Name: defaultBranchName}, nil } -func parseSortKey(sortKey pb.FindLocalBranchesRequest_SortBy) string { +func parseSortKey(sortKey gitalypb.FindLocalBranchesRequest_SortBy) string { switch sortKey { - case pb.FindLocalBranchesRequest_NAME: + case gitalypb.FindLocalBranchesRequest_NAME: return "refname" - case pb.FindLocalBranchesRequest_UPDATED_ASC: + case gitalypb.FindLocalBranchesRequest_UPDATED_ASC: return "committerdate" - case pb.FindLocalBranchesRequest_UPDATED_DESC: + case gitalypb.FindLocalBranchesRequest_UPDATED_DESC: return "-committerdate" } @@ -222,7 +222,7 @@ func parseSortKey(sortKey pb.FindLocalBranchesRequest_SortBy) string { } // FindLocalBranches creates a stream of branches for all local branches in the given repository -func (s *server) FindLocalBranches(in *pb.FindLocalBranchesRequest, stream pb.RefService_FindLocalBranchesServer) error { +func (s *server) FindLocalBranches(in *gitalypb.FindLocalBranchesRequest, stream gitalypb.RefService_FindLocalBranchesServer) error { ctx := stream.Context() c, err := catfile.New(ctx, in.Repository) if err != nil { @@ -241,7 +241,7 @@ func (s *server) FindLocalBranches(in *pb.FindLocalBranchesRequest, stream pb.Re return findRefs(ctx, writer, in.Repository, []string{"refs/heads"}, opts) } -func (s *server) FindAllBranches(in *pb.FindAllBranchesRequest, stream pb.RefService_FindAllBranchesServer) error { +func (s *server) FindAllBranches(in *gitalypb.FindAllBranchesRequest, stream gitalypb.RefService_FindAllBranchesServer) error { args := []string{ // %00 inserts the null character into the output (see for-each-ref docs) "--format=" + strings.Join(localBranchFormatFields, "%00"), @@ -285,7 +285,7 @@ func (s *server) FindAllBranches(in *pb.FindAllBranchesRequest, stream pb.RefSer // ListBranchNamesContainingCommit returns a maximum of in.GetLimit() Branch names // which contain the SHA1 passed as argument -func (*server) ListBranchNamesContainingCommit(in *pb.ListBranchNamesContainingCommitRequest, stream pb.RefService_ListBranchNamesContainingCommitServer) error { +func (*server) ListBranchNamesContainingCommit(in *gitalypb.ListBranchNamesContainingCommitRequest, stream gitalypb.RefService_ListBranchNamesContainingCommitServer) error { if !validCommitID(in.GetCommitId()) { return status.Errorf(codes.InvalidArgument, "commit id was not a 40 character hexidecimal") } @@ -296,7 +296,7 @@ func (*server) ListBranchNamesContainingCommit(in *pb.ListBranchNamesContainingC } writer := func(refs [][]byte) error { - return stream.Send(&pb.ListBranchNamesContainingCommitResponse{BranchNames: refs}) + return stream.Send(&gitalypb.ListBranchNamesContainingCommitResponse{BranchNames: refs}) } return findRefs(stream.Context(), writer, in.Repository, []string{"refs/heads"}, @@ -308,7 +308,7 @@ func (*server) ListBranchNamesContainingCommit(in *pb.ListBranchNamesContainingC // ListTagNamesContainingCommit returns a maximum of in.GetLimit() Tag names // which contain the SHA1 passed as argument -func (*server) ListTagNamesContainingCommit(in *pb.ListTagNamesContainingCommitRequest, stream pb.RefService_ListTagNamesContainingCommitServer) error { +func (*server) ListTagNamesContainingCommit(in *gitalypb.ListTagNamesContainingCommitRequest, stream gitalypb.RefService_ListTagNamesContainingCommitServer) error { if !validCommitID(in.GetCommitId()) { return status.Errorf(codes.InvalidArgument, "commit id was not a 40 character hexidecimal") } @@ -319,7 +319,7 @@ func (*server) ListTagNamesContainingCommit(in *pb.ListTagNamesContainingCommitR } writer := func(refs [][]byte) error { - return stream.Send(&pb.ListTagNamesContainingCommitResponse{TagNames: refs}) + return stream.Send(&gitalypb.ListTagNamesContainingCommitResponse{TagNames: refs}) } return findRefs(stream.Context(), writer, in.Repository, []string{"refs/tags"}, diff --git a/internal/service/ref/refs_test.go b/internal/service/ref/refs_test.go index f9fa0fd35..f675c2c9a 100644 --- a/internal/service/ref/refs_test.go +++ b/internal/service/ref/refs_test.go @@ -9,7 +9,7 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -36,7 +36,7 @@ func TestSuccessfulFindAllBranchNames(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindAllBranchNamesRequest{Repository: testRepo} + rpcRequest := &gitalypb.FindAllBranchNamesRequest{Repository: testRepo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -69,7 +69,7 @@ func TestEmptyFindAllBranchNamesRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - rpcRequest := &pb.FindAllBranchNamesRequest{} + rpcRequest := &gitalypb.FindAllBranchNamesRequest{} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -94,8 +94,8 @@ func TestInvalidRepoFindAllBranchNamesRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - repo := &pb.Repository{StorageName: "default", RelativePath: "made/up/path"} - rpcRequest := &pb.FindAllBranchNamesRequest{Repository: repo} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: "made/up/path"} + rpcRequest := &gitalypb.FindAllBranchNamesRequest{Repository: repo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -124,7 +124,7 @@ func TestSuccessfulFindAllTagNames(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindAllTagNamesRequest{Repository: testRepo} + rpcRequest := &gitalypb.FindAllTagNamesRequest{Repository: testRepo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -158,7 +158,7 @@ func TestEmptyFindAllTagNamesRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - rpcRequest := &pb.FindAllTagNamesRequest{} + rpcRequest := &gitalypb.FindAllTagNamesRequest{} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -183,8 +183,8 @@ func TestInvalidRepoFindAllTagNamesRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - repo := &pb.Repository{StorageName: "default", RelativePath: "made/up/path"} - rpcRequest := &pb.FindAllTagNamesRequest{Repository: repo} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: "made/up/path"} + rpcRequest := &gitalypb.FindAllTagNamesRequest{Repository: repo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -253,47 +253,47 @@ func TestDefaultBranchName(t *testing.T) { testCases := []struct { desc string - findBranchNames func(context.Context, *pb.Repository) ([][]byte, error) - headReference func(context.Context, *pb.Repository) ([]byte, error) + findBranchNames func(context.Context, *gitalypb.Repository) ([][]byte, error) + headReference func(context.Context, *gitalypb.Repository) ([]byte, error) expected []byte }{ { desc: "Get first branch when only one branch exists", expected: []byte("refs/heads/foo"), - findBranchNames: func(context.Context, *pb.Repository) ([][]byte, error) { + findBranchNames: func(context.Context, *gitalypb.Repository) ([][]byte, error) { return [][]byte{[]byte("refs/heads/foo")}, nil }, - headReference: func(context.Context, *pb.Repository) ([]byte, error) { return nil, nil }, + headReference: func(context.Context, *gitalypb.Repository) ([]byte, error) { return nil, nil }, }, { desc: "Get empy ref if no branches exists", expected: nil, - findBranchNames: func(context.Context, *pb.Repository) ([][]byte, error) { return [][]byte{}, nil }, - headReference: func(context.Context, *pb.Repository) ([]byte, error) { return nil, nil }, + findBranchNames: func(context.Context, *gitalypb.Repository) ([][]byte, error) { return [][]byte{}, nil }, + headReference: func(context.Context, *gitalypb.Repository) ([]byte, error) { return nil, nil }, }, { desc: "Get the name of the head reference when more than one branch exists", expected: []byte("refs/heads/bar"), - findBranchNames: func(context.Context, *pb.Repository) ([][]byte, error) { + findBranchNames: func(context.Context, *gitalypb.Repository) ([][]byte, error) { return [][]byte{[]byte("refs/heads/foo"), []byte("refs/heads/bar")}, nil }, - headReference: func(context.Context, *pb.Repository) ([]byte, error) { return []byte("refs/heads/bar"), nil }, + headReference: func(context.Context, *gitalypb.Repository) ([]byte, error) { return []byte("refs/heads/bar"), nil }, }, { desc: "Get `ref/heads/master` when several branches exist", expected: []byte("refs/heads/master"), - findBranchNames: func(context.Context, *pb.Repository) ([][]byte, error) { + findBranchNames: func(context.Context, *gitalypb.Repository) ([][]byte, error) { return [][]byte{[]byte("refs/heads/foo"), []byte("refs/heads/master"), []byte("refs/heads/bar")}, nil }, - headReference: func(context.Context, *pb.Repository) ([]byte, error) { return nil, nil }, + headReference: func(context.Context, *gitalypb.Repository) ([]byte, error) { return nil, nil }, }, { desc: "Get the name of the first branch when several branches exists and no other conditions are met", expected: []byte("refs/heads/foo"), - findBranchNames: func(context.Context, *pb.Repository) ([][]byte, error) { + findBranchNames: func(context.Context, *gitalypb.Repository) ([][]byte, error) { return [][]byte{[]byte("refs/heads/foo"), []byte("refs/heads/bar"), []byte("refs/heads/baz")}, nil }, - headReference: func(context.Context, *pb.Repository) ([]byte, error) { return nil, nil }, + headReference: func(context.Context, *gitalypb.Repository) ([]byte, error) { return nil, nil }, }, } @@ -323,7 +323,7 @@ func TestSuccessfulFindDefaultBranchName(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindDefaultBranchNameRequest{Repository: testRepo} + rpcRequest := &gitalypb.FindDefaultBranchNameRequest{Repository: testRepo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -343,7 +343,7 @@ func TestEmptyFindDefaultBranchNameRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - rpcRequest := &pb.FindDefaultBranchNameRequest{} + rpcRequest := &gitalypb.FindDefaultBranchNameRequest{} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -360,8 +360,8 @@ func TestInvalidRepoFindDefaultBranchNameRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - repo := &pb.Repository{StorageName: "default", RelativePath: "/made/up/path"} - rpcRequest := &pb.FindDefaultBranchNameRequest{Repository: repo} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: "/made/up/path"} + rpcRequest := &gitalypb.FindDefaultBranchNameRequest{Repository: repo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -382,16 +382,16 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { blobID := "faaf198af3a36dbf41961466703cc1d47c61d051" commitID := "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9" - gitCommit := &pb.GitCommit{ + gitCommit := &gitalypb.GitCommit{ Id: commitID, Subject: []byte("More submodules"), Body: []byte("More submodules\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491261}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491261}, @@ -428,14 +428,14 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - rpcRequest := &pb.FindAllTagsRequest{Repository: testRepoCopy} + rpcRequest := &gitalypb.FindAllTagsRequest{Repository: testRepoCopy} c, err := client.FindAllTags(ctx, rpcRequest) if err != nil { t.Fatal(err) } - var receivedTags []*pb.Tag + var receivedTags []*gitalypb.Tag for { r, err := c.Recv() if err == io.EOF { @@ -447,7 +447,7 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { receivedTags = append(receivedTags, r.GetTags()...) } - expectedTags := []*pb.Tag{ + expectedTags := []*gitalypb.Tag{ { Name: []byte("v1.0.0"), Id: "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8", @@ -458,16 +458,16 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { { Name: []byte("v1.1.0"), Id: "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b", - TargetCommit: &pb.GitCommit{ + TargetCommit: &gitalypb.GitCommit{ Id: "5937ac0a7beb003549fc5fd26fc247adbce4a52e", Subject: []byte("Add submodule from gitlab.com"), Body: []byte("Add submodule from gitlab.com\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491698}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491698}, @@ -525,7 +525,7 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) { } } -func findTag(tags []*pb.Tag, tagName []byte) *pb.Tag { +func findTag(tags []*gitalypb.Tag, tagName []byte) *gitalypb.Tag { for _, t := range tags { if bytes.Equal(t.Name, tagName) { return t @@ -542,16 +542,16 @@ func TestInvalidFindAllTagsRequest(t *testing.T) { defer conn.Close() testCases := []struct { desc string - request *pb.FindAllTagsRequest + request *gitalypb.FindAllTagsRequest }{ { desc: "empty request", - request: &pb.FindAllTagsRequest{}, + request: &gitalypb.FindAllTagsRequest{}, }, { desc: "invalid repo", - request: &pb.FindAllTagsRequest{ - Repository: &pb.Repository{ + request: &gitalypb.FindAllTagsRequest{ + Repository: &gitalypb.Repository{ StorageName: "fake", RelativePath: "repo", }, @@ -588,7 +588,7 @@ func TestSuccessfulFindLocalBranches(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.FindLocalBranchesRequest{Repository: testRepo} + rpcRequest := &gitalypb.FindLocalBranchesRequest{Repository: testRepo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -597,7 +597,7 @@ func TestSuccessfulFindLocalBranches(t *testing.T) { t.Fatal(err) } - var branches []*pb.FindLocalBranchResponse + var branches []*gitalypb.FindLocalBranchResponse for { r, err := c.Recv() if err == io.EOF { @@ -610,16 +610,16 @@ func TestSuccessfulFindLocalBranches(t *testing.T) { } for name, target := range localBranches { - localBranch := &pb.FindLocalBranchResponse{ + localBranch := &gitalypb.FindLocalBranchResponse{ Name: []byte(name), CommitId: target.Id, CommitSubject: target.Subject, - CommitAuthor: &pb.FindLocalBranchCommitAuthor{ + CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{ Name: target.Author.Name, Email: target.Author.Email, Date: target.Author.Date, }, - CommitCommitter: &pb.FindLocalBranchCommitAuthor{ + CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{ Name: target.Committer.Name, Email: target.Committer.Email, Date: target.Committer.Date, @@ -651,22 +651,22 @@ func TestFindLocalBranchesSort(t *testing.T) { testCases := []struct { desc string relativeOrder []string - sortBy pb.FindLocalBranchesRequest_SortBy + sortBy gitalypb.FindLocalBranchesRequest_SortBy }{ { desc: "In ascending order by name", relativeOrder: []string{"refs/heads/'test'", "refs/heads/100%branch", "refs/heads/improve/awesome", "refs/heads/master"}, - sortBy: pb.FindLocalBranchesRequest_NAME, + sortBy: gitalypb.FindLocalBranchesRequest_NAME, }, { desc: "In ascending order by commiter date", relativeOrder: []string{"refs/heads/improve/awesome", "refs/heads/'test'", "refs/heads/100%branch", "refs/heads/master"}, - sortBy: pb.FindLocalBranchesRequest_UPDATED_ASC, + sortBy: gitalypb.FindLocalBranchesRequest_UPDATED_ASC, }, { desc: "In descending order by commiter date", relativeOrder: []string{"refs/heads/master", "refs/heads/100%branch", "refs/heads/'test'", "refs/heads/improve/awesome"}, - sortBy: pb.FindLocalBranchesRequest_UPDATED_DESC, + sortBy: gitalypb.FindLocalBranchesRequest_UPDATED_DESC, }, } @@ -681,7 +681,7 @@ func TestFindLocalBranchesSort(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - rpcRequest := &pb.FindLocalBranchesRequest{Repository: testRepo, SortBy: testCase.sortBy} + rpcRequest := &gitalypb.FindLocalBranchesRequest{Repository: testRepo, SortBy: testCase.sortBy} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -717,7 +717,7 @@ func TestEmptyFindLocalBranchesRequest(t *testing.T) { client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() - rpcRequest := &pb.FindLocalBranchesRequest{} + rpcRequest := &gitalypb.FindLocalBranchesRequest{} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -740,20 +740,20 @@ func TestSuccessfulFindAllBranchesRequest(t *testing.T) { server, serverSocketPath := runRefServiceServer(t) defer server.Stop() - remoteBranch := &pb.FindAllBranchesResponse_Branch{ + remoteBranch := &gitalypb.FindAllBranchesResponse_Branch{ Name: []byte("refs/remotes/origin/fake-remote-branch"), - Target: &pb.GitCommit{ + Target: &gitalypb.GitCommit{ Id: "913c66a37b4a45b9769037c55c2d238bd0942d2e", Subject: []byte("Files, encoding and much more"), Body: []byte("Files, encoding and much more\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), BodySize: 98, ParentIds: []string{"cfe32cf61b73a0d5e9f13e774abde7ff789b1660"}, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488896}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393488896}, @@ -767,7 +767,7 @@ func TestSuccessfulFindAllBranchesRequest(t *testing.T) { testhelper.CreateRemoteBranch(t, testRepoPath, "origin", "fake-remote-branch", remoteBranch.Target.Id) - request := &pb.FindAllBranchesRequest{Repository: testRepo} + request := &gitalypb.FindAllBranchesRequest{Repository: testRepo} client, conn := newRefServiceClient(t, serverSocketPath) defer conn.Close() ctx, cancel := context.WithCancel(context.Background()) @@ -781,7 +781,7 @@ func TestSuccessfulFindAllBranchesRequest(t *testing.T) { // It contains local branches for name, target := range localBranches { - branch := &pb.FindAllBranchesResponse_Branch{ + branch := &gitalypb.FindAllBranchesResponse_Branch{ Name: []byte(name), Target: target, } @@ -816,12 +816,12 @@ func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) { expectedRefs := []string{"refs/heads/100%branch", "refs/heads/improve/awesome", "refs/heads/'test'"} - var expectedBranches []*pb.FindAllBranchesResponse_Branch + var expectedBranches []*gitalypb.FindAllBranchesResponse_Branch for _, name := range expectedRefs { target, ok := localBranches[name] require.True(t, ok) - branch := &pb.FindAllBranchesResponse_Branch{ + branch := &gitalypb.FindAllBranchesResponse_Branch{ Name: []byte(name), Target: target, } @@ -830,19 +830,19 @@ func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) { masterCommit, err := log.GetCommit(ctx, testRepo, "master") require.NoError(t, err) - expectedBranches = append(expectedBranches, &pb.FindAllBranchesResponse_Branch{ + expectedBranches = append(expectedBranches, &gitalypb.FindAllBranchesResponse_Branch{ Name: []byte("refs/heads/master"), Target: masterCommit, }) testCases := []struct { desc string - request *pb.FindAllBranchesRequest - expectedBranches []*pb.FindAllBranchesResponse_Branch + request *gitalypb.FindAllBranchesRequest + expectedBranches []*gitalypb.FindAllBranchesResponse_Branch }{ { desc: "all merged branches", - request: &pb.FindAllBranchesRequest{ + request: &gitalypb.FindAllBranchesRequest{ Repository: testRepo, MergedOnly: true, }, @@ -850,7 +850,7 @@ func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) { }, { desc: "all merged from a list of branches", - request: &pb.FindAllBranchesRequest{ + request: &gitalypb.FindAllBranchesRequest{ Repository: testRepo, MergedOnly: true, MergedBranches: [][]byte{ @@ -893,16 +893,16 @@ func TestInvalidFindAllBranchesRequest(t *testing.T) { defer conn.Close() testCases := []struct { description string - request pb.FindAllBranchesRequest + request gitalypb.FindAllBranchesRequest }{ { description: "Empty request", - request: pb.FindAllBranchesRequest{}, + request: gitalypb.FindAllBranchesRequest{}, }, { description: "Invalid repo", - request: pb.FindAllBranchesRequest{ - Repository: &pb.Repository{ + request: gitalypb.FindAllBranchesRequest{ + Repository: &gitalypb.Repository{ StorageName: "fake", RelativePath: "repo", }, @@ -930,7 +930,7 @@ func TestInvalidFindAllBranchesRequest(t *testing.T) { } } -func readFindAllBranchesResponsesFromClient(t *testing.T, c pb.RefService_FindAllBranchesClient) (branches []*pb.FindAllBranchesResponse_Branch) { +func readFindAllBranchesResponsesFromClient(t *testing.T, c gitalypb.RefService_FindAllBranchesClient) (branches []*gitalypb.FindAllBranchesResponse_Branch) { for { r, err := c.Recv() if err == io.EOF { @@ -992,7 +992,7 @@ func TestListTagNamesContainingCommit(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.ListTagNamesContainingCommitRequest{Repository: testRepo, CommitId: tc.commitID} + request := &gitalypb.ListTagNamesContainingCommitRequest{Repository: testRepo, CommitId: tc.commitID} c, err := client.ListTagNamesContainingCommit(ctx, request) require.NoError(t, err) @@ -1086,7 +1086,7 @@ func TestListBranchNamesContainingCommit(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - request := &pb.ListBranchNamesContainingCommitRequest{Repository: testRepo, CommitId: tc.commitID} + request := &gitalypb.ListBranchNamesContainingCommitRequest{Repository: testRepo, CommitId: tc.commitID} c, err := client.ListBranchNamesContainingCommit(ctx, request) require.NoError(t, err) diff --git a/internal/service/ref/remote_branches.go b/internal/service/ref/remote_branches.go index 82162aa4f..ef582663b 100644 --- a/internal/service/ref/remote_branches.go +++ b/internal/service/ref/remote_branches.go @@ -4,13 +4,13 @@ import ( "fmt" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) FindAllRemoteBranches(req *pb.FindAllRemoteBranchesRequest, stream pb.RefService_FindAllRemoteBranchesServer) error { +func (s *server) FindAllRemoteBranches(req *gitalypb.FindAllRemoteBranchesRequest, stream gitalypb.RefService_FindAllRemoteBranchesServer) error { if err := validateFindAllRemoteBranchesRequest(req); err != nil { return status.Errorf(codes.InvalidArgument, "FindAllRemoteBranches: %v", err) } @@ -35,7 +35,7 @@ func (s *server) FindAllRemoteBranches(req *pb.FindAllRemoteBranchesRequest, str return findRefs(ctx, writer, req.GetRepository(), patterns, opts) } -func validateFindAllRemoteBranchesRequest(req *pb.FindAllRemoteBranchesRequest) error { +func validateFindAllRemoteBranchesRequest(req *gitalypb.FindAllRemoteBranchesRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/ref/remote_branches_test.go b/internal/service/ref/remote_branches_test.go index d9c2bffd0..efb411342 100644 --- a/internal/service/ref/remote_branches_test.go +++ b/internal/service/ref/remote_branches_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" @@ -43,7 +43,7 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) { testhelper.CreateRemoteBranch(t, testRepoPath, excludedRemote, branchName, commitID) } - request := &pb.FindAllRemoteBranchesRequest{Repository: testRepo, RemoteName: remoteName} + request := &gitalypb.FindAllRemoteBranchesRequest{Repository: testRepo, RemoteName: remoteName} c, err := client.FindAllRemoteBranches(ctx, request) if err != nil { @@ -57,7 +57,7 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) { targetCommit, err := log.GetCommit(ctx, testRepo, commitID) require.NoError(t, err) - expectedBranch := &pb.Branch{ + expectedBranch := &gitalypb.Branch{ Name: []byte("refs/remotes/" + remoteName + "/" + branchName), TargetCommit: targetCommit, } @@ -69,7 +69,7 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) { targetCommit, err := log.GetCommit(ctx, testRepo, commitID) require.NoError(t, err) - excludedBranch := &pb.Branch{ + excludedBranch := &gitalypb.Branch{ Name: []byte("refs/remotes/" + excludedRemote + "/" + branchName), TargetCommit: targetCommit, } @@ -90,12 +90,12 @@ func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) { testCases := []struct { description string - request pb.FindAllRemoteBranchesRequest + request gitalypb.FindAllRemoteBranchesRequest }{ { description: "Invalid repo", - request: pb.FindAllRemoteBranchesRequest{ - Repository: &pb.Repository{ + request: gitalypb.FindAllRemoteBranchesRequest{ + Repository: &gitalypb.Repository{ StorageName: "fake", RelativePath: "repo", }, @@ -103,11 +103,11 @@ func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) { }, { description: "Empty repo", - request: pb.FindAllRemoteBranchesRequest{RemoteName: "myRemote"}, + request: gitalypb.FindAllRemoteBranchesRequest{RemoteName: "myRemote"}, }, { description: "Empty remote name", - request: pb.FindAllRemoteBranchesRequest{Repository: testRepo}, + request: gitalypb.FindAllRemoteBranchesRequest{Repository: testRepo}, }, } @@ -130,8 +130,8 @@ func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) { } } -func readFindAllRemoteBranchesResponsesFromClient(t *testing.T, c pb.RefService_FindAllRemoteBranchesClient) []*pb.Branch { - var branches []*pb.Branch +func readFindAllRemoteBranchesResponsesFromClient(t *testing.T, c gitalypb.RefService_FindAllRemoteBranchesClient) []*gitalypb.Branch { + var branches []*gitalypb.Branch for { r, err := c.Recv() diff --git a/internal/service/ref/server.go b/internal/service/ref/server.go index 9641c1176..78cc7fbb0 100644 --- a/internal/service/ref/server.go +++ b/internal/service/ref/server.go @@ -1,7 +1,7 @@ package ref import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) @@ -10,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a grpc RefServer -func NewServer(rs *rubyserver.Server) pb.RefServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.RefServiceServer { return &server{rs} } diff --git a/internal/service/ref/tag_messages.go b/internal/service/ref/tag_messages.go index 543070e7f..53c5fbef0 100644 --- a/internal/service/ref/tag_messages.go +++ b/internal/service/ref/tag_messages.go @@ -3,15 +3,14 @@ package ref import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) GetTagMessages(request *pb.GetTagMessagesRequest, stream pb.RefService_GetTagMessagesServer) error { +func (s *server) GetTagMessages(request *gitalypb.GetTagMessagesRequest, stream gitalypb.RefService_GetTagMessagesServer) error { if err := validateGetTagMessagesRequest(request); err != nil { return status.Errorf(codes.InvalidArgument, "GetTagMessages: %v", err) } @@ -44,7 +43,7 @@ func (s *server) GetTagMessages(request *pb.GetTagMessagesRequest, stream pb.Ref }) } -func validateGetTagMessagesRequest(request *pb.GetTagMessagesRequest) error { +func validateGetTagMessagesRequest(request *gitalypb.GetTagMessagesRequest) error { if request.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/ref/tag_messages_test.go b/internal/service/ref/tag_messages_test.go index 3361026d2..15a2cf322 100644 --- a/internal/service/ref/tag_messages_test.go +++ b/internal/service/ref/tag_messages_test.go @@ -5,11 +5,10 @@ import ( "strings" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -33,7 +32,7 @@ func TestSuccessfulGetTagMessagesRequest(t *testing.T) { tag1ID := testhelper.CreateTag(t, testRepoPath, "big-tag-1", "master", &testhelper.CreateTagOpts{Message: message1}) tag2ID := testhelper.CreateTag(t, testRepoPath, "big-tag-2", "master~", &testhelper.CreateTagOpts{Message: message2}) - request := &pb.GetTagMessagesRequest{ + request := &gitalypb.GetTagMessagesRequest{ Repository: testRepo, TagIds: []string{tag1ID, tag2ID}, } @@ -41,7 +40,7 @@ func TestSuccessfulGetTagMessagesRequest(t *testing.T) { c, err := client.GetTagMessages(ctx, request) require.NoError(t, err) - expectedMessages := []*pb.GetTagMessagesResponse{ + expectedMessages := []*gitalypb.GetTagMessagesResponse{ { TagId: tag1ID, Message: []byte(message1 + "\n"), @@ -65,12 +64,12 @@ func TestFailedGetTagMessagesRequest(t *testing.T) { testCases := []struct { desc string - request *pb.GetTagMessagesRequest + request *gitalypb.GetTagMessagesRequest code codes.Code }{ { desc: "empty Repository", - request: &pb.GetTagMessagesRequest{ + request: &gitalypb.GetTagMessagesRequest{ Repository: nil, TagIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e"}, }, @@ -98,7 +97,7 @@ func TestFailedGetTagMessagesRequest(t *testing.T) { } } -func readAllMessagesFromClient(t *testing.T, c pb.RefService_GetTagMessagesClient) (messages []*pb.GetTagMessagesResponse) { +func readAllMessagesFromClient(t *testing.T, c gitalypb.RefService_GetTagMessagesClient) (messages []*gitalypb.GetTagMessagesResponse) { for { resp, err := c.Recv() if err == io.EOF { diff --git a/internal/service/ref/testhelper_test.go b/internal/service/ref/testhelper_test.go index 6cb262643..1d698f9fd 100644 --- a/internal/service/ref/testhelper_test.go +++ b/internal/service/ref/testhelper_test.go @@ -11,7 +11,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper/lines" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -20,19 +20,19 @@ import ( ) var ( - localBranches = map[string]*pb.GitCommit{ + localBranches = map[string]*gitalypb.GitCommit{ "refs/heads/100%branch": { Id: "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", Body: []byte("Merge branch 'add-directory-with-space' into 'master'\r\n\r\nAdd a directory containing a space in its name\r\n\r\nneeded for verifying the fix of `https://gitlab.com/gitlab-com/support-forum/issues/952` \r\n\r\nSee merge request !11"), BodySize: 221, ParentIds: []string{"6907208d755b60ebeacb2e9dfea74c92c3449a1f", "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e"}, Subject: []byte("Merge branch 'add-directory-with-space' into 'master'"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Stan Hu"), Email: []byte("stanhu@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1471558878}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Stan Hu"), Email: []byte("stanhu@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1471558878}, @@ -44,12 +44,12 @@ var ( Body: []byte("Add submodule from gitlab.com\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"), BodySize: 98, ParentIds: []string{"570e7b2abdd848b95f2f578043fc23bd6f6fd24d"}, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491698}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Dmitriy Zaporozhets"), Email: []byte("dmitriy.zaporozhets@gmail.com"), Date: ×tamp.Timestamp{Seconds: 1393491698}, @@ -61,12 +61,12 @@ var ( Body: []byte("Merge branch 'tree_helper_spec' into 'master'\n\nAdd directory structure for tree_helper spec\n\nThis directory structure is needed for a testing the method flatten_tree(tree) in the TreeHelper module\n\nSee [merge request #275](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/275#note_732774)\n\nSee merge request !2\n"), BodySize: 317, ParentIds: []string{"5937ac0a7beb003549fc5fd26fc247adbce4a52e", "4cd80ccab63c82b4bad16faa5193fbd2aa06df40"}, - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Sytse Sijbrandij"), Email: []byte("sytse@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1420925009}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Sytse Sijbrandij"), Email: []byte("sytse@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1420925009}, @@ -109,7 +109,7 @@ func runRefServiceServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterRefServiceServer(grpcServer, &server{rubyServer}) + gitalypb.RegisterRefServiceServer(grpcServer, &server{rubyServer}) reflection.Register(grpcServer) go grpcServer.Serve(listener) @@ -117,7 +117,7 @@ func runRefServiceServer(t *testing.T) (*grpc.Server, string) { return grpcServer, serverSocketPath } -func newRefServiceClient(t *testing.T, serverSocketPath string) (pb.RefServiceClient, *grpc.ClientConn) { +func newRefServiceClient(t *testing.T, serverSocketPath string) (gitalypb.RefServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -129,10 +129,10 @@ func newRefServiceClient(t *testing.T, serverSocketPath string) (pb.RefServiceCl t.Fatal(err) } - return pb.NewRefServiceClient(conn), conn + return gitalypb.NewRefServiceClient(conn), conn } -func assertContainsLocalBranch(t *testing.T, branches []*pb.FindLocalBranchResponse, branch *pb.FindLocalBranchResponse) { +func assertContainsLocalBranch(t *testing.T, branches []*gitalypb.FindLocalBranchResponse, branch *gitalypb.FindLocalBranchResponse) { for _, b := range branches { if bytes.Equal(branch.Name, b.Name) { if !testhelper.FindLocalBranchResponsesEqual(branch, b) { @@ -144,7 +144,7 @@ func assertContainsLocalBranch(t *testing.T, branches []*pb.FindLocalBranchRespo t.Errorf("Expected to find branch %q in local branches", branch.Name) } -func assertContainsBranch(t *testing.T, branches []*pb.FindAllBranchesResponse_Branch, branch *pb.FindAllBranchesResponse_Branch) { +func assertContainsBranch(t *testing.T, branches []*gitalypb.FindAllBranchesResponse_Branch, branch *gitalypb.FindAllBranchesResponse_Branch) { var branchNames [][]byte for _, b := range branches { diff --git a/internal/service/ref/util.go b/internal/service/ref/util.go index 39975b884..833f61084 100644 --- a/internal/service/ref/util.go +++ b/internal/service/ref/util.go @@ -3,7 +3,7 @@ package ref import ( "bytes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/lines" @@ -21,8 +21,8 @@ func parseRef(ref []byte) ([][]byte, error) { return elements, nil } -func buildLocalBranch(name []byte, target *pb.GitCommit) *pb.FindLocalBranchResponse { - response := &pb.FindLocalBranchResponse{ +func buildLocalBranch(name []byte, target *gitalypb.GitCommit) *gitalypb.FindLocalBranchResponse { + response := &gitalypb.FindLocalBranchResponse{ Name: name, } @@ -34,7 +34,7 @@ func buildLocalBranch(name []byte, target *pb.GitCommit) *pb.FindLocalBranchResp response.CommitSubject = target.Subject if author := target.Author; author != nil { - response.CommitAuthor = &pb.FindLocalBranchCommitAuthor{ + response.CommitAuthor = &gitalypb.FindLocalBranchCommitAuthor{ Name: author.Name, Email: author.Email, Date: author.Date, @@ -42,7 +42,7 @@ func buildLocalBranch(name []byte, target *pb.GitCommit) *pb.FindLocalBranchResp } if committer := target.Committer; committer != nil { - response.CommitCommitter = &pb.FindLocalBranchCommitAuthor{ + response.CommitCommitter = &gitalypb.FindLocalBranchCommitAuthor{ Name: committer.Name, Email: committer.Email, Date: committer.Date, @@ -52,45 +52,45 @@ func buildLocalBranch(name []byte, target *pb.GitCommit) *pb.FindLocalBranchResp return response } -func buildAllBranchesBranch(c *catfile.Batch, elements [][]byte) (*pb.FindAllBranchesResponse_Branch, error) { +func buildAllBranchesBranch(c *catfile.Batch, elements [][]byte) (*gitalypb.FindAllBranchesResponse_Branch, error) { target, err := log.GetCommitCatfile(c, string(elements[1])) if err != nil { return nil, err } - return &pb.FindAllBranchesResponse_Branch{ + return &gitalypb.FindAllBranchesResponse_Branch{ Name: elements[0], Target: target, }, nil } -func buildBranch(c *catfile.Batch, elements [][]byte) (*pb.Branch, error) { +func buildBranch(c *catfile.Batch, elements [][]byte) (*gitalypb.Branch, error) { target, err := log.GetCommitCatfile(c, string(elements[1])) if err != nil { return nil, err } - return &pb.Branch{ + return &gitalypb.Branch{ Name: elements[0], TargetCommit: target, }, nil } -func newFindAllBranchNamesWriter(stream pb.Ref_FindAllBranchNamesServer) lines.Sender { +func newFindAllBranchNamesWriter(stream gitalypb.Ref_FindAllBranchNamesServer) lines.Sender { return func(refs [][]byte) error { - return stream.Send(&pb.FindAllBranchNamesResponse{Names: refs}) + return stream.Send(&gitalypb.FindAllBranchNamesResponse{Names: refs}) } } -func newFindAllTagNamesWriter(stream pb.Ref_FindAllTagNamesServer) lines.Sender { +func newFindAllTagNamesWriter(stream gitalypb.Ref_FindAllTagNamesServer) lines.Sender { return func(refs [][]byte) error { - return stream.Send(&pb.FindAllTagNamesResponse{Names: refs}) + return stream.Send(&gitalypb.FindAllTagNamesResponse{Names: refs}) } } -func newFindLocalBranchesWriter(stream pb.Ref_FindLocalBranchesServer, c *catfile.Batch) lines.Sender { +func newFindLocalBranchesWriter(stream gitalypb.Ref_FindLocalBranchesServer, c *catfile.Batch) lines.Sender { return func(refs [][]byte) error { - var branches []*pb.FindLocalBranchResponse + var branches []*gitalypb.FindLocalBranchResponse for _, ref := range refs { elements, err := parseRef(ref) @@ -105,13 +105,13 @@ func newFindLocalBranchesWriter(stream pb.Ref_FindLocalBranchesServer, c *catfil branches = append(branches, buildLocalBranch(elements[0], target)) } - return stream.Send(&pb.FindLocalBranchesResponse{Branches: branches}) + return stream.Send(&gitalypb.FindLocalBranchesResponse{Branches: branches}) } } -func newFindAllBranchesWriter(stream pb.RefService_FindAllBranchesServer, c *catfile.Batch) lines.Sender { +func newFindAllBranchesWriter(stream gitalypb.RefService_FindAllBranchesServer, c *catfile.Batch) lines.Sender { return func(refs [][]byte) error { - var branches []*pb.FindAllBranchesResponse_Branch + var branches []*gitalypb.FindAllBranchesResponse_Branch for _, ref := range refs { elements, err := parseRef(ref) @@ -124,13 +124,13 @@ func newFindAllBranchesWriter(stream pb.RefService_FindAllBranchesServer, c *cat } branches = append(branches, branch) } - return stream.Send(&pb.FindAllBranchesResponse{Branches: branches}) + return stream.Send(&gitalypb.FindAllBranchesResponse{Branches: branches}) } } -func newFindAllRemoteBranchesWriter(stream pb.RefService_FindAllRemoteBranchesServer, c *catfile.Batch) lines.Sender { +func newFindAllRemoteBranchesWriter(stream gitalypb.RefService_FindAllRemoteBranchesServer, c *catfile.Batch) lines.Sender { return func(refs [][]byte) error { - var branches []*pb.Branch + var branches []*gitalypb.Branch for _, ref := range refs { elements, err := parseRef(ref) @@ -144,6 +144,6 @@ func newFindAllRemoteBranchesWriter(stream pb.RefService_FindAllRemoteBranchesSe branches = append(branches, branch) } - return stream.Send(&pb.FindAllRemoteBranchesResponse{Branches: branches}) + return stream.Send(&gitalypb.FindAllRemoteBranchesResponse{Branches: branches}) } } diff --git a/internal/service/ref/util_test.go b/internal/service/ref/util_test.go index 5ae38c4f6..331d2f570 100644 --- a/internal/service/ref/util_test.go +++ b/internal/service/ref/util_test.go @@ -5,27 +5,27 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) func TestBuildLocalBranch(t *testing.T) { testCases := []struct { desc string - in *pb.GitCommit - out *pb.FindLocalBranchResponse + in *gitalypb.GitCommit + out *gitalypb.FindLocalBranchResponse }{ { desc: "all required fields present", - in: &pb.GitCommit{ + in: &gitalypb.GitCommit{ Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, }, - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -36,16 +36,16 @@ func TestBuildLocalBranch(t *testing.T) { }, BodySize: 162, }, - out: &pb.FindLocalBranchResponse{ + out: &gitalypb.FindLocalBranchResponse{ Name: []byte("my-branch"), CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"), - CommitAuthor: &pb.FindLocalBranchCommitAuthor{ + CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, }, - CommitCommitter: &pb.FindLocalBranchCommitAuthor{ + CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -54,11 +54,11 @@ func TestBuildLocalBranch(t *testing.T) { }, { desc: "missing author", - in: &pb.GitCommit{ + in: &gitalypb.GitCommit{ Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), - Committer: &pb.CommitAuthor{ + Committer: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -69,12 +69,12 @@ func TestBuildLocalBranch(t *testing.T) { }, BodySize: 162, }, - out: &pb.FindLocalBranchResponse{ + out: &gitalypb.FindLocalBranchResponse{ Name: []byte("my-branch"), CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"), CommitAuthor: nil, - CommitCommitter: &pb.FindLocalBranchCommitAuthor{ + CommitCommitter: &gitalypb.FindLocalBranchCommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -83,11 +83,11 @@ func TestBuildLocalBranch(t *testing.T) { }, { desc: "missing committer", - in: &pb.GitCommit{ + in: &gitalypb.GitCommit{ Id: "b83d6e391c22777fca1ed3012fce84f633d7fed0", Subject: []byte("Merge branch 'branch-merged' into 'master'"), Body: []byte("Merge branch 'branch-merged' into 'master'\r\n\r\nadds bar folder and branch-test text file to check Repository merged_to_root_ref method\r\n\r\n\r\n\r\nSee merge request !12"), - Author: &pb.CommitAuthor{ + Author: &gitalypb.CommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -98,11 +98,11 @@ func TestBuildLocalBranch(t *testing.T) { }, BodySize: 162, }, - out: &pb.FindLocalBranchResponse{ + out: &gitalypb.FindLocalBranchResponse{ Name: []byte("my-branch"), CommitId: "b83d6e391c22777fca1ed3012fce84f633d7fed0", CommitSubject: []byte("Merge branch 'branch-merged' into 'master'"), - CommitAuthor: &pb.FindLocalBranchCommitAuthor{ + CommitAuthor: &gitalypb.FindLocalBranchCommitAuthor{ Name: []byte("Job van der Voort"), Email: []byte("job@gitlab.com"), Date: ×tamp.Timestamp{Seconds: 1474987066}, @@ -113,7 +113,7 @@ func TestBuildLocalBranch(t *testing.T) { { desc: "nil commit", in: nil, - out: &pb.FindLocalBranchResponse{ + out: &gitalypb.FindLocalBranchResponse{ Name: []byte("my-branch"), }, }, diff --git a/internal/service/register.go b/internal/service/register.go index 2e5bba4ce..f0b95047e 100644 --- a/internal/service/register.go +++ b/internal/service/register.go @@ -1,7 +1,7 @@ package service import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/service/blob" "gitlab.com/gitlab-org/gitaly/internal/service/commit" @@ -26,20 +26,20 @@ import ( // RegisterAll will register all the known grpc services with // the specified grpc service instance func RegisterAll(grpcServer *grpc.Server, rubyServer *rubyserver.Server) { - pb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer)) - pb.RegisterCommitServiceServer(grpcServer, commit.NewServer(rubyServer)) - pb.RegisterDiffServiceServer(grpcServer, diff.NewServer(rubyServer)) - pb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer()) - pb.RegisterOperationServiceServer(grpcServer, operations.NewServer(rubyServer)) - pb.RegisterRefServiceServer(grpcServer, ref.NewServer(rubyServer)) - pb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer)) - pb.RegisterSSHServiceServer(grpcServer, ssh.NewServer()) - pb.RegisterSmartHTTPServiceServer(grpcServer, smarthttp.NewServer()) - pb.RegisterWikiServiceServer(grpcServer, wiki.NewServer(rubyServer)) - pb.RegisterConflictsServiceServer(grpcServer, conflicts.NewServer(rubyServer)) - pb.RegisterRemoteServiceServer(grpcServer, remote.NewServer(rubyServer)) - pb.RegisterServerServiceServer(grpcServer, server.NewServer()) - pb.RegisterStorageServiceServer(grpcServer, storage.NewServer()) + gitalypb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer)) + gitalypb.RegisterCommitServiceServer(grpcServer, commit.NewServer(rubyServer)) + gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer(rubyServer)) + gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer()) + gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(rubyServer)) + gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(rubyServer)) + gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer)) + gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer()) + gitalypb.RegisterSmartHTTPServiceServer(grpcServer, smarthttp.NewServer()) + gitalypb.RegisterWikiServiceServer(grpcServer, wiki.NewServer(rubyServer)) + gitalypb.RegisterConflictsServiceServer(grpcServer, conflicts.NewServer(rubyServer)) + gitalypb.RegisterRemoteServiceServer(grpcServer, remote.NewServer(rubyServer)) + gitalypb.RegisterServerServiceServer(grpcServer, server.NewServer()) + gitalypb.RegisterStorageServiceServer(grpcServer, storage.NewServer()) healthpb.RegisterHealthServer(grpcServer, health.NewServer()) } diff --git a/internal/service/remote/fetch_internal_remote.go b/internal/service/remote/fetch_internal_remote.go index f63b377e1..36e550b16 100644 --- a/internal/service/remote/fetch_internal_remote.go +++ b/internal/service/remote/fetch_internal_remote.go @@ -7,12 +7,12 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) // FetchInternalRemote fetches another Gitaly repository set as a remote -func (s *server) FetchInternalRemote(ctx context.Context, req *pb.FetchInternalRemoteRequest) (*pb.FetchInternalRemoteResponse, error) { +func (s *server) FetchInternalRemote(ctx context.Context, req *gitalypb.FetchInternalRemoteRequest) (*gitalypb.FetchInternalRemoteResponse, error) { if err := validateFetchInternalRemoteRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "FetchInternalRemote: %v", err) } @@ -30,7 +30,7 @@ func (s *server) FetchInternalRemote(ctx context.Context, req *pb.FetchInternalR return client.FetchInternalRemote(clientCtx, req) } -func validateFetchInternalRemoteRequest(req *pb.FetchInternalRemoteRequest) error { +func validateFetchInternalRemoteRequest(req *gitalypb.FetchInternalRemoteRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/remote/fetch_internal_remote_test.go b/internal/service/remote/fetch_internal_remote_test.go index 940e05e3d..a49e4cd2f 100644 --- a/internal/service/remote/fetch_internal_remote_test.go +++ b/internal/service/remote/fetch_internal_remote_test.go @@ -5,6 +5,7 @@ import ( "net" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/service/remote" "google.golang.org/grpc" @@ -14,7 +15,6 @@ import ( "github.com/stretchr/testify/require" serverPkg "gitlab.com/gitlab-org/gitaly/internal/server" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -37,7 +37,7 @@ func TestSuccessfulFetchInternalRemote(t *testing.T) { md := testhelper.GitalyServersMetadata(t, serverSocketPath) ctx := metadata.NewOutgoingContext(ctxOuter, md) - request := &pb.FetchInternalRemoteRequest{ + request := &gitalypb.FetchInternalRemoteRequest{ Repository: repo, RemoteRepository: remoteRepo, } @@ -68,9 +68,9 @@ func TestFailedFetchInternalRemote(t *testing.T) { ctx := metadata.NewOutgoingContext(ctxOuter, md) // Non-existing remote repo - remoteRepo := &pb.Repository{StorageName: "default", RelativePath: "fake.git"} + remoteRepo := &gitalypb.Repository{StorageName: "default", RelativePath: "fake.git"} - request := &pb.FetchInternalRemoteRequest{ + request := &gitalypb.FetchInternalRemoteRequest{ Repository: repo, RemoteRepository: remoteRepo, } @@ -90,19 +90,19 @@ func TestFailedFetchInternalRemoteDueToValidations(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - repo := &pb.Repository{StorageName: "default", RelativePath: "repo.git"} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: "repo.git"} testCases := []struct { desc string - request *pb.FetchInternalRemoteRequest + request *gitalypb.FetchInternalRemoteRequest }{ { desc: "empty Repository", - request: &pb.FetchInternalRemoteRequest{RemoteRepository: repo}, + request: &gitalypb.FetchInternalRemoteRequest{RemoteRepository: repo}, }, { desc: "empty Remote Repository", - request: &pb.FetchInternalRemoteRequest{Repository: repo}, + request: &gitalypb.FetchInternalRemoteRequest{Repository: repo}, }, } diff --git a/internal/service/remote/find_remote_root_ref.go b/internal/service/remote/find_remote_root_ref.go index 91c906a8d..aac0527f2 100644 --- a/internal/service/remote/find_remote_root_ref.go +++ b/internal/service/remote/find_remote_root_ref.go @@ -8,13 +8,13 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" ) const headPrefix = "HEAD branch: " -func findRemoteRootRef(ctx context.Context, repo *pb.Repository, remote string) (string, error) { +func findRemoteRootRef(ctx context.Context, repo *gitalypb.Repository, remote string) (string, error) { cmd, err := git.Command(ctx, repo, "remote", "show", remote) if err != nil { return "", err @@ -41,7 +41,7 @@ func findRemoteRootRef(ctx context.Context, repo *pb.Repository, remote string) } // FindRemoteRootRef queries the remote to determine its HEAD -func (s *server) FindRemoteRootRef(ctx context.Context, in *pb.FindRemoteRootRefRequest) (*pb.FindRemoteRootRefResponse, error) { +func (s *server) FindRemoteRootRef(ctx context.Context, in *gitalypb.FindRemoteRootRefRequest) (*gitalypb.FindRemoteRootRefResponse, error) { remote := in.GetRemote() if remote == "" { return nil, status.Error(codes.InvalidArgument, "empty remote can't be queried") @@ -56,5 +56,5 @@ func (s *server) FindRemoteRootRef(ctx context.Context, in *pb.FindRemoteRootRef return nil, status.Errorf(codes.Internal, err.Error()) } - return &pb.FindRemoteRootRefResponse{Ref: ref}, nil + return &gitalypb.FindRemoteRootRefResponse{Ref: ref}, nil } diff --git a/internal/service/remote/find_remote_root_ref_test.go b/internal/service/remote/find_remote_root_ref_test.go index f5f556110..a37a597e5 100644 --- a/internal/service/remote/find_remote_root_ref_test.go +++ b/internal/service/remote/find_remote_root_ref_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) @@ -19,7 +19,7 @@ func TestFindRemoteRootRefSuccess(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.FindRemoteRootRefRequest{Repository: testRepo, Remote: "origin"} + request := &gitalypb.FindRemoteRootRefRequest{Repository: testRepo, Remote: "origin"} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() @@ -35,34 +35,34 @@ func TestFindRemoteRootRefFailedDueToValidation(t *testing.T) { client, conn := NewRemoteClient(t, serverSocketPath) defer conn.Close() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() testCases := []struct { desc string - request *pb.FindRemoteRootRefRequest + request *gitalypb.FindRemoteRootRefRequest code codes.Code }{ { desc: "Invalid repository", - request: &pb.FindRemoteRootRefRequest{Repository: invalidRepo}, + request: &gitalypb.FindRemoteRootRefRequest{Repository: invalidRepo}, code: codes.InvalidArgument, }, { desc: "Repository is nil", - request: &pb.FindRemoteRootRefRequest{}, + request: &gitalypb.FindRemoteRootRefRequest{}, code: codes.InvalidArgument, }, { desc: "Remote is nil", - request: &pb.FindRemoteRootRefRequest{Repository: testRepo}, + request: &gitalypb.FindRemoteRootRefRequest{Repository: testRepo}, code: codes.InvalidArgument, }, { desc: "Remote is empty", - request: &pb.FindRemoteRootRefRequest{Repository: testRepo, Remote: ""}, + request: &gitalypb.FindRemoteRootRefRequest{Repository: testRepo, Remote: ""}, code: codes.InvalidArgument, }, } @@ -86,7 +86,7 @@ func TestFindRemoteRootRefFailedDueToInvalidRemote(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.FindRemoteRootRefRequest{Repository: testRepo, Remote: "invalid"} + request := &gitalypb.FindRemoteRootRefRequest{Repository: testRepo, Remote: "invalid"} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() diff --git a/internal/service/remote/remotes.go b/internal/service/remote/remotes.go index d7a98d4cb..ab0805530 100644 --- a/internal/service/remote/remotes.go +++ b/internal/service/remote/remotes.go @@ -11,13 +11,13 @@ import ( "golang.org/x/net/context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) // AddRemote adds a remote to the repository -func (s *server) AddRemote(ctx context.Context, req *pb.AddRemoteRequest) (*pb.AddRemoteResponse, error) { +func (s *server) AddRemote(ctx context.Context, req *gitalypb.AddRemoteRequest) (*gitalypb.AddRemoteResponse, error) { if err := validateAddRemoteRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "AddRemote: %v", err) } @@ -35,7 +35,7 @@ func (s *server) AddRemote(ctx context.Context, req *pb.AddRemoteRequest) (*pb.A return client.AddRemote(clientCtx, req) } -func validateAddRemoteRequest(req *pb.AddRemoteRequest) error { +func validateAddRemoteRequest(req *gitalypb.AddRemoteRequest) error { if strings.TrimSpace(req.GetName()) == "" { return fmt.Errorf("empty remote name") } @@ -47,7 +47,7 @@ func validateAddRemoteRequest(req *pb.AddRemoteRequest) error { } // RemoveRemote removes the given remote -func (s *server) RemoveRemote(ctx context.Context, req *pb.RemoveRemoteRequest) (*pb.RemoveRemoteResponse, error) { +func (s *server) RemoveRemote(ctx context.Context, req *gitalypb.RemoveRemoteRequest) (*gitalypb.RemoveRemoteResponse, error) { if err := validateRemoveRemoteRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "AddRemote: %v", err) } @@ -65,7 +65,7 @@ func (s *server) RemoveRemote(ctx context.Context, req *pb.RemoveRemoteRequest) return client.RemoveRemote(clientCtx, req) } -func (s *server) FindRemoteRepository(ctx context.Context, req *pb.FindRemoteRepositoryRequest) (*pb.FindRemoteRepositoryResponse, error) { +func (s *server) FindRemoteRepository(ctx context.Context, req *gitalypb.FindRemoteRepositoryRequest) (*gitalypb.FindRemoteRepositoryResponse, error) { if req.GetRemote() == "" { return nil, status.Error(codes.InvalidArgument, "FindRemoteRepository: empty remote can't be checked.") } @@ -81,7 +81,7 @@ func (s *server) FindRemoteRepository(ctx context.Context, req *pb.FindRemoteRep return nil, status.Errorf(codes.Internal, "unable to read stdout: %s", err) } if err := cmd.Wait(); err != nil { - return &pb.FindRemoteRepositoryResponse{Exists: false}, nil + return &gitalypb.FindRemoteRepositoryResponse{Exists: false}, nil } // The output of a successful command is structured like @@ -90,10 +90,10 @@ func (s *server) FindRemoteRepository(ctx context.Context, req *pb.FindRemoteRep fields := bytes.Fields(output) match := len(fields) == 2 && len(fields[0]) == 40 && string(fields[1]) == "HEAD" - return &pb.FindRemoteRepositoryResponse{Exists: match}, nil + return &gitalypb.FindRemoteRepositoryResponse{Exists: match}, nil } -func validateRemoveRemoteRequest(req *pb.RemoveRemoteRequest) error { +func validateRemoveRemoteRequest(req *gitalypb.RemoveRemoteRequest) error { if req.GetName() == "" { return fmt.Errorf("empty remote name") } diff --git a/internal/service/remote/remotes_test.go b/internal/service/remote/remotes_test.go index a3c33e1ff..68e96ef82 100644 --- a/internal/service/remote/remotes_test.go +++ b/internal/service/remote/remotes_test.go @@ -14,7 +14,7 @@ import ( "golang.org/x/net/context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -72,7 +72,7 @@ func TestSuccessfulAddRemote(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - request := &pb.AddRemoteRequest{ + request := &gitalypb.AddRemoteRequest{ Repository: testRepo, Name: tc.remoteName, Url: tc.url, @@ -137,7 +137,7 @@ func TestFailedAddRemoteDueToValidation(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - request := &pb.AddRemoteRequest{ + request := &gitalypb.AddRemoteRequest{ Repository: testRepo, Name: tc.remoteName, Url: tc.url, @@ -183,7 +183,7 @@ func TestSuccessfulRemoveRemote(t *testing.T) { for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - request := &pb.RemoveRemoteRequest{ + request := &gitalypb.RemoveRemoteRequest{ Repository: testRepo, Name: tc.remoteName, } @@ -212,7 +212,7 @@ func TestFailedRemoveRemoteDueToValidation(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - request := &pb.RemoveRemoteRequest{Repository: testRepo} // Remote name empty + request := &gitalypb.RemoveRemoteRequest{Repository: testRepo} // Remote name empty _, err := client.RemoveRemote(ctx, request) testhelper.RequireGrpcError(t, err, codes.InvalidArgument) @@ -235,7 +235,7 @@ func TestFindRemoteRepository(t *testing.T) { })) defer ts.Close() - resp, err := client.FindRemoteRepository(ctx, &pb.FindRemoteRepositoryRequest{Remote: ts.URL}) + resp, err := client.FindRemoteRepository(ctx, &gitalypb.FindRemoteRepositoryRequest{Remote: ts.URL}) require.NoError(t, err) require.True(t, resp.Exists) @@ -262,7 +262,7 @@ func TestFailedFindRemoteRepository(t *testing.T) { } for _, tc := range testCases { - resp, err := client.FindRemoteRepository(ctx, &pb.FindRemoteRepositoryRequest{Remote: tc.remote}) + resp, err := client.FindRemoteRepository(ctx, &gitalypb.FindRemoteRepositoryRequest{Remote: tc.remote}) if tc.code == codes.OK { require.NoError(t, err) } else { diff --git a/internal/service/remote/server.go b/internal/service/remote/server.go index e215b87bb..858efed9f 100644 --- a/internal/service/remote/server.go +++ b/internal/service/remote/server.go @@ -1,7 +1,7 @@ package remote import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) @@ -10,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a grpc RemoteServiceServer -func NewServer(rs *rubyserver.Server) pb.RemoteServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.RemoteServiceServer { return &server{rs} } diff --git a/internal/service/remote/testhelper_test.go b/internal/service/remote/testhelper_test.go index ece4482c7..152c5b2be 100644 --- a/internal/service/remote/testhelper_test.go +++ b/internal/service/remote/testhelper_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc" @@ -46,7 +46,7 @@ func runRemoteServiceServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterRemoteServiceServer(grpcServer, &server{RubyServer}) + gitalypb.RegisterRemoteServiceServer(grpcServer, &server{RubyServer}) reflection.Register(grpcServer) go grpcServer.Serve(listener) @@ -54,7 +54,7 @@ func runRemoteServiceServer(t *testing.T) (*grpc.Server, string) { return grpcServer, serverSocketPath } -func NewRemoteClient(t *testing.T, serverSocketPath string) (pb.RemoteServiceClient, *grpc.ClientConn) { +func NewRemoteClient(t *testing.T, serverSocketPath string) (gitalypb.RemoteServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -66,5 +66,5 @@ func NewRemoteClient(t *testing.T, serverSocketPath string) (pb.RemoteServiceCli t.Fatal(err) } - return pb.NewRemoteServiceClient(conn), conn + return gitalypb.NewRemoteServiceClient(conn), conn } diff --git a/internal/service/remote/update_remote_mirror.go b/internal/service/remote/update_remote_mirror.go index db2ada3ce..a35441928 100644 --- a/internal/service/remote/update_remote_mirror.go +++ b/internal/service/remote/update_remote_mirror.go @@ -3,13 +3,13 @@ package remote import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) UpdateRemoteMirror(stream pb.RemoteService_UpdateRemoteMirrorServer) error { +func (s *server) UpdateRemoteMirror(stream gitalypb.RemoteService_UpdateRemoteMirrorServer) error { firstRequest, err := stream.Recv() if err != nil { return err @@ -59,7 +59,7 @@ func (s *server) UpdateRemoteMirror(stream pb.RemoteService_UpdateRemoteMirrorSe return stream.SendAndClose(response) } -func validateUpdateRemoteMirrorRequest(req *pb.UpdateRemoteMirrorRequest) error { +func validateUpdateRemoteMirrorRequest(req *gitalypb.UpdateRemoteMirrorRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/remote/update_remote_mirror_test.go b/internal/service/remote/update_remote_mirror_test.go index ebacc13e8..e382dc5e0 100644 --- a/internal/service/remote/update_remote_mirror_test.go +++ b/internal/service/remote/update_remote_mirror_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -47,15 +47,15 @@ func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - firstRequest := &pb.UpdateRemoteMirrorRequest{ + firstRequest := &gitalypb.UpdateRemoteMirrorRequest{ Repository: testRepo, RefName: remoteName, OnlyBranchesMatching: nil, } - matchingRequest1 := &pb.UpdateRemoteMirrorRequest{ + matchingRequest1 := &gitalypb.UpdateRemoteMirrorRequest{ OnlyBranchesMatching: [][]byte{[]byte("new-branch"), []byte("empty-branch")}, } - matchingRequest2 := &pb.UpdateRemoteMirrorRequest{ + matchingRequest2 := &gitalypb.UpdateRemoteMirrorRequest{ OnlyBranchesMatching: [][]byte{[]byte("not-merged-branch"), []byte("matcher-without-matches")}, } @@ -91,18 +91,18 @@ func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) { testCases := []struct { desc string - request *pb.UpdateRemoteMirrorRequest + request *gitalypb.UpdateRemoteMirrorRequest }{ { desc: "empty Repository", - request: &pb.UpdateRemoteMirrorRequest{ + request: &gitalypb.UpdateRemoteMirrorRequest{ Repository: nil, RefName: "remote_mirror_1", }, }, { desc: "empty RefName", - request: &pb.UpdateRemoteMirrorRequest{ + request: &gitalypb.UpdateRemoteMirrorRequest{ Repository: testRepo, RefName: "", }, diff --git a/internal/service/repository/apply_gitattributes.go b/internal/service/repository/apply_gitattributes.go index 7f28f558f..e7103f03b 100644 --- a/internal/service/repository/apply_gitattributes.go +++ b/internal/service/repository/apply_gitattributes.go @@ -7,7 +7,7 @@ import ( "os" "path" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -72,7 +72,7 @@ func applyGitattributes(c *catfile.Batch, repoPath string, revision []byte) erro return os.Rename(tempFile.Name(), attributesPath) } -func (server) ApplyGitattributes(ctx context.Context, in *pb.ApplyGitattributesRequest) (*pb.ApplyGitattributesResponse, error) { +func (server) ApplyGitattributes(ctx context.Context, in *gitalypb.ApplyGitattributesRequest) (*gitalypb.ApplyGitattributesResponse, error) { repo := in.GetRepository() repoPath, err := helper.GetRepoPath(repo) if err != nil { @@ -92,5 +92,5 @@ func (server) ApplyGitattributes(ctx context.Context, in *pb.ApplyGitattributesR return nil, err } - return &pb.ApplyGitattributesResponse{}, nil + return &gitalypb.ApplyGitattributesResponse{}, nil } diff --git a/internal/service/repository/apply_gitattributes_test.go b/internal/service/repository/apply_gitattributes_test.go index 76688c92d..16fdfa703 100644 --- a/internal/service/repository/apply_gitattributes_test.go +++ b/internal/service/repository/apply_gitattributes_test.go @@ -10,7 +10,7 @@ import ( "google.golang.org/grpc/codes" "github.com/stretchr/testify/assert" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -77,7 +77,7 @@ func TestApplyGitattributesFailure(t *testing.T) { defer cleanupFn() tests := []struct { - repo *pb.Repository + repo *gitalypb.Repository revision []byte code codes.Code }{ @@ -87,17 +87,17 @@ func TestApplyGitattributesFailure(t *testing.T) { code: codes.InvalidArgument, }, { - repo: &pb.Repository{StorageName: "foo"}, + repo: &gitalypb.Repository{StorageName: "foo"}, revision: []byte("master"), code: codes.InvalidArgument, }, { - repo: &pb.Repository{RelativePath: "bar"}, + repo: &gitalypb.Repository{RelativePath: "bar"}, revision: []byte("master"), code: codes.InvalidArgument, }, { - repo: &pb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar"}, + repo: &gitalypb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar"}, revision: []byte("master"), code: codes.NotFound, }, @@ -118,18 +118,18 @@ func TestApplyGitattributesFailure(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.ApplyGitattributesRequest{Repository: test.repo, Revision: test.revision} + req := &gitalypb.ApplyGitattributesRequest{Repository: test.repo, Revision: test.revision} _, err := client.ApplyGitattributes(ctx, req) testhelper.RequireGrpcError(t, err, test.code) }) } } -func assertGitattributesApplied(t *testing.T, client pb.RepositoryServiceClient, testRepo *pb.Repository, attributesPath string, revision, expectedContents []byte) { +func assertGitattributesApplied(t *testing.T, client gitalypb.RepositoryServiceClient, testRepo *gitalypb.Repository, attributesPath string, revision, expectedContents []byte) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.ApplyGitattributesRequest{Repository: testRepo, Revision: revision} + req := &gitalypb.ApplyGitattributesRequest{Repository: testRepo, Revision: revision} c, err := client.ApplyGitattributes(ctx, req) assert.NoError(t, err) diff --git a/internal/service/repository/archive.go b/internal/service/repository/archive.go index 0540e271b..50918848a 100644 --- a/internal/service/repository/archive.go +++ b/internal/service/repository/archive.go @@ -8,30 +8,30 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/internal/git" ) -func parseArchiveFormat(format pb.GetArchiveRequest_Format) (*exec.Cmd, string) { +func parseArchiveFormat(format gitalypb.GetArchiveRequest_Format) (*exec.Cmd, string) { switch format { - case pb.GetArchiveRequest_TAR: + case gitalypb.GetArchiveRequest_TAR: return nil, "tar" - case pb.GetArchiveRequest_TAR_GZ: + case gitalypb.GetArchiveRequest_TAR_GZ: return exec.Command("gzip", "-c", "-n"), "tar" - case pb.GetArchiveRequest_TAR_BZ2: + case gitalypb.GetArchiveRequest_TAR_BZ2: return exec.Command("bzip2", "-c"), "tar" - case pb.GetArchiveRequest_ZIP: + case gitalypb.GetArchiveRequest_ZIP: return nil, "zip" } return nil, "" } -func handleArchive(ctx context.Context, writer io.Writer, repo *pb.Repository, - format pb.GetArchiveRequest_Format, prefix, commitID string) error { +func handleArchive(ctx context.Context, writer io.Writer, repo *gitalypb.Repository, + format gitalypb.GetArchiveRequest_Format, prefix, commitID string) error { compressCmd, formatArg := parseArchiveFormat(format) if len(formatArg) == 0 { return status.Errorf(codes.InvalidArgument, "invalid format") @@ -59,13 +59,13 @@ func handleArchive(ctx context.Context, writer io.Writer, repo *pb.Repository, return archiveCommand.Wait() } -func (s *server) GetArchive(in *pb.GetArchiveRequest, stream pb.RepositoryService_GetArchiveServer) error { +func (s *server) GetArchive(in *gitalypb.GetArchiveRequest, stream gitalypb.RepositoryService_GetArchiveServer) error { if err := git.ValidateRevision([]byte(in.CommitId)); err != nil { return status.Errorf(codes.InvalidArgument, "invalid commitId: %v", err) } writer := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.GetArchiveResponse{Data: p}) + return stream.Send(&gitalypb.GetArchiveResponse{Data: p}) }) return handleArchive(stream.Context(), writer, in.Repository, in.Format, in.Prefix, in.CommitId) diff --git a/internal/service/repository/archive_test.go b/internal/service/repository/archive_test.go index 2f543f373..f4d573de3 100644 --- a/internal/service/repository/archive_test.go +++ b/internal/service/repository/archive_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" ) @@ -25,11 +25,11 @@ func TestGetArchiveSuccess(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - formats := []pb.GetArchiveRequest_Format{ - pb.GetArchiveRequest_ZIP, - pb.GetArchiveRequest_TAR, - pb.GetArchiveRequest_TAR_GZ, - pb.GetArchiveRequest_TAR_BZ2, + formats := []gitalypb.GetArchiveRequest_Format{ + gitalypb.GetArchiveRequest_ZIP, + gitalypb.GetArchiveRequest_TAR, + gitalypb.GetArchiveRequest_TAR_GZ, + gitalypb.GetArchiveRequest_TAR_BZ2, } testCases := []struct { @@ -57,7 +57,7 @@ func TestGetArchiveSuccess(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.GetArchiveRequest{ + req := &gitalypb.GetArchiveRequest{ Repository: testRepo, CommitId: tc.commitID, Prefix: tc.prefix, @@ -100,18 +100,18 @@ func TestGetArchiveFailure(t *testing.T) { testCases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository prefix string commitID string - format pb.GetArchiveRequest_Format + format gitalypb.GetArchiveRequest_Format code codes.Code }{ { desc: "Repository doesn't exist", - repo: &pb.Repository{StorageName: "fake", RelativePath: "path"}, + repo: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, prefix: "", commitID: commitID, - format: pb.GetArchiveRequest_ZIP, + format: gitalypb.GetArchiveRequest_ZIP, code: codes.InvalidArgument, }, { @@ -119,7 +119,7 @@ func TestGetArchiveFailure(t *testing.T) { repo: nil, prefix: "", commitID: commitID, - format: pb.GetArchiveRequest_ZIP, + format: gitalypb.GetArchiveRequest_ZIP, code: codes.InvalidArgument, }, { @@ -127,7 +127,7 @@ func TestGetArchiveFailure(t *testing.T) { repo: testRepo, prefix: "", commitID: "", - format: pb.GetArchiveRequest_ZIP, + format: gitalypb.GetArchiveRequest_ZIP, code: codes.InvalidArgument, }, { @@ -135,7 +135,7 @@ func TestGetArchiveFailure(t *testing.T) { repo: testRepo, prefix: "", commitID: "", - format: pb.GetArchiveRequest_Format(-1), + format: gitalypb.GetArchiveRequest_Format(-1), code: codes.InvalidArgument, }, } @@ -145,7 +145,7 @@ func TestGetArchiveFailure(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.GetArchiveRequest{ + req := &gitalypb.GetArchiveRequest{ Repository: tc.repo, CommitId: tc.commitID, Prefix: tc.prefix, @@ -160,22 +160,22 @@ func TestGetArchiveFailure(t *testing.T) { } } -func compressedFileContents(t *testing.T, format pb.GetArchiveRequest_Format, name string) []byte { +func compressedFileContents(t *testing.T, format gitalypb.GetArchiveRequest_Format, name string) []byte { switch format { - case pb.GetArchiveRequest_TAR: + case gitalypb.GetArchiveRequest_TAR: return testhelper.MustRunCommand(t, nil, "tar", "tf", name) - case pb.GetArchiveRequest_TAR_GZ: + case gitalypb.GetArchiveRequest_TAR_GZ: return testhelper.MustRunCommand(t, nil, "tar", "ztf", name) - case pb.GetArchiveRequest_TAR_BZ2: + case gitalypb.GetArchiveRequest_TAR_BZ2: return testhelper.MustRunCommand(t, nil, "tar", "jtf", name) - case pb.GetArchiveRequest_ZIP: + case gitalypb.GetArchiveRequest_ZIP: return testhelper.MustRunCommand(t, nil, "unzip", "-l", name) } return nil } -func consumeArchive(stream pb.RepositoryService_GetArchiveClient) ([]byte, error) { +func consumeArchive(stream gitalypb.RepositoryService_GetArchiveClient) ([]byte, error) { reader := streamio.NewReader(func() ([]byte, error) { response, err := stream.Recv() return response.GetData(), err diff --git a/internal/service/repository/backup_custom_hooks.go b/internal/service/repository/backup_custom_hooks.go index 12fabc7f0..ce4354f2a 100644 --- a/internal/service/repository/backup_custom_hooks.go +++ b/internal/service/repository/backup_custom_hooks.go @@ -5,7 +5,7 @@ import ( "os/exec" "path" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -15,14 +15,14 @@ import ( const customHooksDir = "custom_hooks" -func (s *server) BackupCustomHooks(in *pb.BackupCustomHooksRequest, stream pb.RepositoryService_BackupCustomHooksServer) error { +func (s *server) BackupCustomHooks(in *gitalypb.BackupCustomHooksRequest, stream gitalypb.RepositoryService_BackupCustomHooksServer) error { repoPath, err := helper.GetPath(in.Repository) if err != nil { return status.Errorf(codes.Internal, "BackupCustomHooks: getting repo path failed %v", err) } writer := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.BackupCustomHooksResponse{Data: p}) + return stream.Send(&gitalypb.BackupCustomHooksResponse{Data: p}) }) if _, err := os.Lstat(path.Join(repoPath, customHooksDir)); os.IsNotExist(err) { diff --git a/internal/service/repository/backup_custom_hooks_test.go b/internal/service/repository/backup_custom_hooks_test.go index 94c7a96a9..2e2b6677f 100644 --- a/internal/service/repository/backup_custom_hooks_test.go +++ b/internal/service/repository/backup_custom_hooks_test.go @@ -10,12 +10,11 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" ) @@ -46,7 +45,7 @@ func TestSuccessfullBackupCustomHooksRequest(t *testing.T) { require.NoError(t, ioutil.WriteFile(path.Join(repoPath, fileName), []byte("Some hooks"), 0700), fmt.Sprintf("Could not create %s", fileName)) } - backupRequest := &pb.BackupCustomHooksRequest{Repository: testRepo} + backupRequest := &gitalypb.BackupCustomHooksRequest{Repository: testRepo} backupStream, err := client.BackupCustomHooks(ctx, backupRequest) require.NoError(t, err) @@ -87,7 +86,7 @@ func TestSuccessfullBackupCustomHooksSymlink(t *testing.T) { linkTarget := "/var/empty" require.NoError(t, os.Symlink(linkTarget, path.Join(repoPath, "custom_hooks")), "Could not create custom_hooks symlink") - backupRequest := &pb.BackupCustomHooksRequest{Repository: testRepo} + backupRequest := &gitalypb.BackupCustomHooksRequest{Repository: testRepo} backupStream, err := client.BackupCustomHooks(ctx, backupRequest) require.NoError(t, err) @@ -120,7 +119,7 @@ func TestSuccessfullBackupCustomHooksRequestWithNoHooks(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - backupRequest := &pb.BackupCustomHooksRequest{Repository: testRepo} + backupRequest := &gitalypb.BackupCustomHooksRequest{Repository: testRepo} backupStream, err := client.BackupCustomHooks(ctx, backupRequest) require.NoError(t, err) diff --git a/internal/service/repository/calculate_checksum.go b/internal/service/repository/calculate_checksum.go index 9b89e69e1..4bb3f2ad7 100644 --- a/internal/service/repository/calculate_checksum.go +++ b/internal/service/repository/calculate_checksum.go @@ -10,7 +10,7 @@ import ( "regexp" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/alternates" @@ -25,7 +25,7 @@ const blankChecksum = "0000000000000000000000000000000000000000" var refWhitelist = regexp.MustCompile(`HEAD|(refs/(heads|tags|keep-around|merge-requests|environments|notes)/)`) -func (s *server) CalculateChecksum(ctx context.Context, in *pb.CalculateChecksumRequest) (*pb.CalculateChecksumResponse, error) { +func (s *server) CalculateChecksum(ctx context.Context, in *gitalypb.CalculateChecksumRequest) (*gitalypb.CalculateChecksumResponse, error) { repo := in.GetRepository() repoPath, err := helper.GetRepoPath(repo) @@ -76,16 +76,16 @@ func (s *server) CalculateChecksum(ctx context.Context, in *pb.CalculateChecksum if err := cmd.Wait(); err != nil { if isValidRepo(ctx, repo) { - return &pb.CalculateChecksumResponse{Checksum: blankChecksum}, nil + return &gitalypb.CalculateChecksumResponse{Checksum: blankChecksum}, nil } return nil, status.Errorf(codes.DataLoss, "CalculateChecksum: not a git repository '%s'", repoPath) } - return &pb.CalculateChecksumResponse{Checksum: hex.EncodeToString(checksum.Bytes())}, nil + return &gitalypb.CalculateChecksumResponse{Checksum: hex.EncodeToString(checksum.Bytes())}, nil } -func isValidRepo(ctx context.Context, repo *pb.Repository) bool { +func isValidRepo(ctx context.Context, repo *gitalypb.Repository) bool { repoPath, env, err := alternates.PathAndEnv(repo) if err != nil { return false diff --git a/internal/service/repository/calculate_checksum_test.go b/internal/service/repository/calculate_checksum_test.go index c0508d4ba..76f99902d 100644 --- a/internal/service/repository/calculate_checksum_test.go +++ b/internal/service/repository/calculate_checksum_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) @@ -30,7 +30,7 @@ func TestSuccessfulCalculateChecksum(t *testing.T) { require.NoError(t, exec.Command("cp", "testdata/checksum-test-packed-refs", path.Join(testRepoPath, "packed-refs")).Run()) require.NoError(t, exec.Command("git", "-C", testRepoPath, "symbolic-ref", "HEAD", "refs/heads/feature").Run()) - request := &pb.CalculateChecksumRequest{Repository: testRepo} + request := &gitalypb.CalculateChecksumRequest{Repository: testRepo} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() @@ -79,7 +79,7 @@ func TestEmptyRepositoryCalculateChecksum(t *testing.T) { repo, _, cleanupFn := testhelper.InitBareRepo(t) defer cleanupFn() - request := &pb.CalculateChecksumRequest{Repository: repo} + request := &gitalypb.CalculateChecksumRequest{Repository: repo} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() @@ -101,7 +101,7 @@ func TestBrokenRepositoryCalculateChecksum(t *testing.T) { // Force an empty HEAD file require.NoError(t, os.Truncate(path.Join(testRepoPath, "HEAD"), 0)) - request := &pb.CalculateChecksumRequest{Repository: repo} + request := &gitalypb.CalculateChecksumRequest{Repository: repo} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() @@ -116,21 +116,21 @@ func TestFailedCalculateChecksum(t *testing.T) { client, conn := newRepositoryClient(t, serverSocketPath) defer conn.Close() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { desc string - request *pb.CalculateChecksumRequest + request *gitalypb.CalculateChecksumRequest code codes.Code }{ { desc: "Invalid repository", - request: &pb.CalculateChecksumRequest{Repository: invalidRepo}, + request: &gitalypb.CalculateChecksumRequest{Repository: invalidRepo}, code: codes.InvalidArgument, }, { desc: "Repository is nil", - request: &pb.CalculateChecksumRequest{}, + request: &gitalypb.CalculateChecksumRequest{}, code: codes.InvalidArgument, }, } diff --git a/internal/service/repository/cleanup.go b/internal/service/repository/cleanup.go index 9f076316c..03cd50f6c 100644 --- a/internal/service/repository/cleanup.go +++ b/internal/service/repository/cleanup.go @@ -11,13 +11,13 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" ) var lockFiles = []string{"config.lock", "HEAD.lock"} -func (server) Cleanup(_ctx context.Context, in *pb.CleanupRequest) (*pb.CleanupResponse, error) { +func (server) Cleanup(_ctx context.Context, in *gitalypb.CleanupRequest) (*gitalypb.CleanupResponse, error) { repoPath, err := helper.GetRepoPath(in.GetRepository()) if err != nil { return nil, err @@ -27,7 +27,7 @@ func (server) Cleanup(_ctx context.Context, in *pb.CleanupRequest) (*pb.CleanupR return nil, err } - return &pb.CleanupResponse{}, nil + return &gitalypb.CleanupResponse{}, nil } func cleanupRepo(repoPath string) error { diff --git a/internal/service/repository/cleanup_test.go b/internal/service/repository/cleanup_test.go index 0a24cf767..da88cce37 100644 --- a/internal/service/repository/cleanup_test.go +++ b/internal/service/repository/cleanup_test.go @@ -8,9 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) func TestCleanupDeletesRefsLocks(t *testing.T) { @@ -26,7 +25,7 @@ func TestCleanupDeletesRefsLocks(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.CleanupRequest{Repository: testRepo} + req := &gitalypb.CleanupRequest{Repository: testRepo} refsPath := filepath.Join(testRepoPath, "refs") keepRefPath := filepath.Join(refsPath, "heads", "keepthis") @@ -95,7 +94,7 @@ func TestCleanupDeletesPackedRefsLock(t *testing.T) { packedRefsPath := filepath.Join(testRepoPath, "packed-refs") os.Chtimes(packedRefsPath, oldTime, oldTime) - req := &pb.CleanupRequest{Repository: testRepo} + req := &gitalypb.CleanupRequest{Repository: testRepo} lockPath := filepath.Join(testRepoPath, "packed-refs.lock") if tc.lockTime != nil { @@ -157,7 +156,7 @@ func TestCleanupDeletesStaleWorktrees(t *testing.T) { testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - req := &pb.CleanupRequest{Repository: testRepo} + req := &gitalypb.CleanupRequest{Repository: testRepo} testhelper.AddWorktree(t, testRepoPath, "test-worktree") basePath := filepath.Join(testRepoPath, "worktrees") @@ -199,7 +198,7 @@ func TestCleanupFileLocks(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.CleanupRequest{Repository: testRepo} + req := &gitalypb.CleanupRequest{Repository: testRepo} for _, fileName := range lockFiles { lockPath := filepath.Join(testRepoPath, fileName) diff --git a/internal/service/repository/config.go b/internal/service/repository/config.go index 23dad7422..7f2db6610 100644 --- a/internal/service/repository/config.go +++ b/internal/service/repository/config.go @@ -1,17 +1,17 @@ package repository import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (*server) DeleteConfig(ctx context.Context, req *pb.DeleteConfigRequest) (*pb.DeleteConfigResponse, error) { +func (*server) DeleteConfig(ctx context.Context, req *gitalypb.DeleteConfigRequest) (*gitalypb.DeleteConfigResponse, error) { for _, k := range req.Keys { // We assume k does not contain any secrets; it is leaked via 'ps'. cmd, err := git.Command(ctx, req.Repository, "config", "--unset-all", k) @@ -29,10 +29,10 @@ func (*server) DeleteConfig(ctx context.Context, req *pb.DeleteConfigRequest) (* } } - return &pb.DeleteConfigResponse{}, nil + return &gitalypb.DeleteConfigResponse{}, nil } -func (s *server) SetConfig(ctx context.Context, req *pb.SetConfigRequest) (*pb.SetConfigResponse, error) { +func (s *server) SetConfig(ctx context.Context, req *gitalypb.SetConfigRequest) (*gitalypb.SetConfigResponse, error) { // We use gitaly-ruby here because in gitaly-ruby we can use Rugged, and // Rugged lets us set config values without leaking secrets via 'ps'. We // can't use `git config foo.bar secret` because that leaks secrets. diff --git a/internal/service/repository/config_test.go b/internal/service/repository/config_test.go index 87a9c7fbd..b39c4c457 100644 --- a/internal/service/repository/config_test.go +++ b/internal/service/repository/config_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -52,7 +52,7 @@ func TestDeleteConfig(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "config", k, "blabla") } - _, err := client.DeleteConfig(ctx, &pb.DeleteConfigRequest{Repository: testRepo, Keys: tc.reqKeys}) + _, err := client.DeleteConfig(ctx, &gitalypb.DeleteConfigRequest{Repository: testRepo, Keys: tc.reqKeys}) if tc.code == codes.OK { require.NoError(t, err) } else { @@ -82,7 +82,7 @@ func TestSetConfig(t *testing.T) { testcases := []struct { desc string - entries []*pb.SetConfigRequest_Entry + entries []*gitalypb.SetConfigRequest_Entry expected []string code codes.Code }{ @@ -91,10 +91,10 @@ func TestSetConfig(t *testing.T) { }, { desc: "mix of different types", - entries: []*pb.SetConfigRequest_Entry{ - &pb.SetConfigRequest_Entry{Key: "test.foo1", Value: &pb.SetConfigRequest_Entry_ValueStr{"hello world"}}, - &pb.SetConfigRequest_Entry{Key: "test.foo2", Value: &pb.SetConfigRequest_Entry_ValueInt32{1234}}, - &pb.SetConfigRequest_Entry{Key: "test.foo3", Value: &pb.SetConfigRequest_Entry_ValueBool{true}}, + entries: []*gitalypb.SetConfigRequest_Entry{ + &gitalypb.SetConfigRequest_Entry{Key: "test.foo1", Value: &gitalypb.SetConfigRequest_Entry_ValueStr{"hello world"}}, + &gitalypb.SetConfigRequest_Entry{Key: "test.foo2", Value: &gitalypb.SetConfigRequest_Entry_ValueInt32{1234}}, + &gitalypb.SetConfigRequest_Entry{Key: "test.foo3", Value: &gitalypb.SetConfigRequest_Entry_ValueBool{true}}, }, expected: []string{ "test.foo1=hello world", @@ -112,7 +112,7 @@ func TestSetConfig(t *testing.T) { testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - _, err := client.SetConfig(ctx, &pb.SetConfigRequest{Repository: testRepo, Entries: tc.entries}) + _, err := client.SetConfig(ctx, &gitalypb.SetConfigRequest{Repository: testRepo, Entries: tc.entries}) if tc.code == codes.OK { require.NoError(t, err) } else { diff --git a/internal/service/repository/create.go b/internal/service/repository/create.go index 9116e9c51..4831cf09b 100644 --- a/internal/service/repository/create.go +++ b/internal/service/repository/create.go @@ -1,13 +1,13 @@ package repository import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" ) -func (s *server) CreateRepository(ctx context.Context, req *pb.CreateRepositoryRequest) (*pb.CreateRepositoryResponse, error) { +func (s *server) CreateRepository(ctx context.Context, req *gitalypb.CreateRepositoryRequest) (*gitalypb.CreateRepositoryResponse, error) { client, err := s.RepositoryServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/repository/create_bundle.go b/internal/service/repository/create_bundle.go index 83ea5e7a2..94458abb4 100644 --- a/internal/service/repository/create_bundle.go +++ b/internal/service/repository/create_bundle.go @@ -3,16 +3,15 @@ package repository import ( "io" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) CreateBundle(req *pb.CreateBundleRequest, stream pb.RepositoryService_CreateBundleServer) error { +func (s *server) CreateBundle(req *gitalypb.CreateBundleRequest, stream gitalypb.RepositoryService_CreateBundleServer) error { repo := req.GetRepository() if repo == nil { return status.Errorf(codes.InvalidArgument, "CreateBundle: empty Repository") @@ -26,7 +25,7 @@ func (s *server) CreateBundle(req *pb.CreateBundleRequest, stream pb.RepositoryS } writer := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.CreateBundleResponse{Data: p}) + return stream.Send(&gitalypb.CreateBundleResponse{Data: p}) }) _, err = io.Copy(writer, cmd) diff --git a/internal/service/repository/create_bundle_test.go b/internal/service/repository/create_bundle_test.go index 6efe22338..6fbe85b85 100644 --- a/internal/service/repository/create_bundle_test.go +++ b/internal/service/repository/create_bundle_test.go @@ -6,12 +6,11 @@ import ( "os" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/tempdir" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -29,7 +28,7 @@ func TestSuccessfulCreateBundleRequest(t *testing.T) { testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.CreateBundleRequest{Repository: testRepo} + request := &gitalypb.CreateBundleRequest{Repository: testRepo} c, err := client.CreateBundle(ctx, request) require.NoError(t, err) @@ -63,12 +62,12 @@ func TestFailedCreateBundleRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.CreateBundleRequest + request *gitalypb.CreateBundleRequest code codes.Code }{ { desc: "empty repository", - request: &pb.CreateBundleRequest{}, + request: &gitalypb.CreateBundleRequest{}, code: codes.InvalidArgument, }, } diff --git a/internal/service/repository/create_from_bundle.go b/internal/service/repository/create_from_bundle.go index 07c930197..8703c6416 100644 --- a/internal/service/repository/create_from_bundle.go +++ b/internal/service/repository/create_from_bundle.go @@ -8,18 +8,17 @@ import ( "path" "strings" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/tempdir" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) CreateRepositoryFromBundle(stream pb.RepositoryService_CreateRepositoryFromBundleServer) error { +func (s *server) CreateRepositoryFromBundle(stream gitalypb.RepositoryService_CreateRepositoryFromBundleServer) error { firstRequest, err := stream.Recv() if err != nil { return status.Errorf(codes.Internal, "CreateRepositoryFromBundle: first request failed: %v", err) @@ -104,12 +103,12 @@ func (s *server) CreateRepositoryFromBundle(stream pb.RepositoryService_CreateRe } // CreateRepository is harmless on existing repositories with the side effect that it creates the hook symlink. - if _, err := s.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: repo}); err != nil { + if _, err := s.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: repo}); err != nil { cleanError := sanitizedError(repoPath, "CreateRepositoryFromBundle: create hooks failed: %v", err) return status.Error(codes.Internal, cleanError) } - return stream.SendAndClose(&pb.CreateRepositoryFromBundleResponse{}) + return stream.SendAndClose(&gitalypb.CreateRepositoryFromBundleResponse{}) } func sanitizedError(path, format string, a ...interface{}) string { diff --git a/internal/service/repository/create_from_bundle_test.go b/internal/service/repository/create_from_bundle_test.go index fbdf094cf..50b00c86d 100644 --- a/internal/service/repository/create_from_bundle_test.go +++ b/internal/service/repository/create_from_bundle_test.go @@ -6,14 +6,13 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/tempdir" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -44,7 +43,7 @@ func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) { stream, err := client.CreateRepositoryFromBundle(ctx) require.NoError(t, err) - importedRepo := &pb.Repository{ + importedRepo := &gitalypb.Repository{ StorageName: testhelper.DefaultStorageName, RelativePath: "a-repo-from-bundle", } @@ -52,7 +51,7 @@ func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) { require.NoError(t, err) defer os.RemoveAll(importedRepoPath) - request := &pb.CreateRepositoryFromBundleRequest{Repository: importedRepo} + request := &gitalypb.CreateRepositoryFromBundleRequest{Repository: importedRepo} writer := streamio.NewWriter(func(p []byte) error { request.Data = p @@ -60,7 +59,7 @@ func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) { return err } - request = &pb.CreateRepositoryFromBundleRequest{} + request = &gitalypb.CreateRepositoryFromBundleRequest{} return nil }) @@ -99,7 +98,7 @@ func TestFailedCreateRepositoryFromBundleRequestDueToValidations(t *testing.T) { stream, err := client.CreateRepositoryFromBundle(ctx) require.NoError(t, err) - require.NoError(t, stream.Send(&pb.CreateRepositoryFromBundleRequest{})) + require.NoError(t, stream.Send(&gitalypb.CreateRepositoryFromBundleRequest{})) _, err = stream.CloseAndRecv() testhelper.RequireGrpcError(t, err, codes.InvalidArgument) diff --git a/internal/service/repository/create_from_snapshot.go b/internal/service/repository/create_from_snapshot.go index 66055123b..fd539c0bc 100644 --- a/internal/service/repository/create_from_snapshot.go +++ b/internal/service/repository/create_from_snapshot.go @@ -7,11 +7,11 @@ import ( "os/exec" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/tempdir" @@ -45,7 +45,7 @@ var httpClient = &http.Client{ }, } -func untar(ctx context.Context, path string, in *pb.CreateRepositoryFromSnapshotRequest) error { +func untar(ctx context.Context, path string, in *gitalypb.CreateRepositoryFromSnapshotRequest) error { req, err := http.NewRequest("GET", in.HttpUrl, nil) if err != nil { return status.Errorf(codes.InvalidArgument, "Bad HTTP URL: %v", err) @@ -73,7 +73,7 @@ func untar(ctx context.Context, path string, in *pb.CreateRepositoryFromSnapshot return cmd.Wait() } -func (s *server) CreateRepositoryFromSnapshot(ctx context.Context, in *pb.CreateRepositoryFromSnapshotRequest) (*pb.CreateRepositoryFromSnapshotResponse, error) { +func (s *server) CreateRepositoryFromSnapshot(ctx context.Context, in *gitalypb.CreateRepositoryFromSnapshotRequest) (*gitalypb.CreateRepositoryFromSnapshotResponse, error) { realPath, err := helper.GetPath(in.Repository) if err != nil { return nil, err @@ -98,7 +98,7 @@ func (s *server) CreateRepositoryFromSnapshot(ctx context.Context, in *pb.Create // // NOTE: The received archive is trusted *a lot*. Before pointing this RPC // at endpoints not under our control, it should undergo a lot of hardning. - crr := &pb.CreateRepositoryRequest{Repository: tempRepo} + crr := &gitalypb.CreateRepositoryRequest{Repository: tempRepo} if _, err := s.CreateRepository(ctx, crr); err != nil { return nil, status.Errorf(codes.Internal, "couldn't create empty bare repository: %v", err) } @@ -111,5 +111,5 @@ func (s *server) CreateRepositoryFromSnapshot(ctx context.Context, in *pb.Create return nil, status.Errorf(codes.Internal, "Promoting temporary directory failed: %v", err) } - return &pb.CreateRepositoryFromSnapshotResponse{}, nil + return &gitalypb.CreateRepositoryFromSnapshotResponse{}, nil } diff --git a/internal/service/repository/create_from_snapshot_test.go b/internal/service/repository/create_from_snapshot_test.go index 4cdafce45..1f1654e2c 100644 --- a/internal/service/repository/create_from_snapshot_test.go +++ b/internal/service/repository/create_from_snapshot_test.go @@ -11,9 +11,9 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "google.golang.org/grpc/codes" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/archive" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -54,7 +54,7 @@ func generateTarFile(t *testing.T, path string) ([]byte, []string) { return data, entries } -func createFromSnapshot(t *testing.T, req *pb.CreateRepositoryFromSnapshotRequest) (*pb.CreateRepositoryFromSnapshotResponse, error) { +func createFromSnapshot(t *testing.T, req *gitalypb.CreateRepositoryFromSnapshotRequest) (*gitalypb.CreateRepositoryFromSnapshotResponse, error) { server, serverSocketPath := runRepoServer(t) defer server.Stop() @@ -84,7 +84,7 @@ func TestCreateRepositoryFromSnapshotSuccess(t *testing.T) { // Delete the repository so we can re-use the path require.NoError(t, os.RemoveAll(repoPath)) - req := &pb.CreateRepositoryFromSnapshotRequest{ + req := &gitalypb.CreateRepositoryFromSnapshotRequest{ Repository: testRepo, HttpUrl: srv.URL + tarPath, HttpAuth: secret, @@ -93,7 +93,7 @@ func TestCreateRepositoryFromSnapshotSuccess(t *testing.T) { rsp, err := createFromSnapshot(t, req) require.NoError(t, err) - require.Equal(t, rsp, &pb.CreateRepositoryFromSnapshotResponse{}) + require.Equal(t, rsp, &gitalypb.CreateRepositoryFromSnapshotResponse{}) require.DirExists(t, repoPath) for _, entry := range entries { @@ -116,7 +116,7 @@ func TestCreateRepositoryFromSnapshotFailsIfRepositoryExists(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - req := &pb.CreateRepositoryFromSnapshotRequest{Repository: testRepo} + req := &gitalypb.CreateRepositoryFromSnapshotRequest{Repository: testRepo} rsp, err := createFromSnapshot(t, req) testhelper.RequireGrpcError(t, err, codes.InvalidArgument) require.Contains(t, err.Error(), "destination directory exists") @@ -127,7 +127,7 @@ func TestCreateRepositoryFromSnapshotFailsIfBadURL(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) cleanupFn() // free up the destination dir for use - req := &pb.CreateRepositoryFromSnapshotRequest{ + req := &gitalypb.CreateRepositoryFromSnapshotRequest{ Repository: testRepo, HttpUrl: "invalid!scheme://invalid.invalid", } @@ -177,7 +177,7 @@ func TestCreateRepositoryFromSnapshotBadRequests(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - req := &pb.CreateRepositoryFromSnapshotRequest{ + req := &gitalypb.CreateRepositoryFromSnapshotRequest{ Repository: testRepo, HttpUrl: srv.URL + tc.url, HttpAuth: tc.auth, @@ -209,7 +209,7 @@ func TestCreateRepositoryFromSnapshotHandlesMalformedResponse(t *testing.T) { // Delete the repository so we can re-use the path require.NoError(t, os.RemoveAll(repoPath)) - req := &pb.CreateRepositoryFromSnapshotRequest{ + req := &gitalypb.CreateRepositoryFromSnapshotRequest{ Repository: testRepo, HttpUrl: srv.URL + tarPath, HttpAuth: secret, diff --git a/internal/service/repository/create_from_url.go b/internal/service/repository/create_from_url.go index fb2b26328..75eb01467 100644 --- a/internal/service/repository/create_from_url.go +++ b/internal/service/repository/create_from_url.go @@ -5,17 +5,16 @@ import ( "os" "os/exec" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) CreateRepositoryFromURL(ctx context.Context, req *pb.CreateRepositoryFromURLRequest) (*pb.CreateRepositoryFromURLResponse, error) { +func (s *server) CreateRepositoryFromURL(ctx context.Context, req *gitalypb.CreateRepositoryFromURLRequest) (*gitalypb.CreateRepositoryFromURLResponse, error) { if err := validateCreateRepositoryFromURLRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "CreateRepositoryFromURL: %v", err) } @@ -48,7 +47,7 @@ func (s *server) CreateRepositoryFromURL(ctx context.Context, req *pb.CreateRepo } // CreateRepository is harmless on existing repositories with the side effect that it creates the hook symlink. - if _, err := s.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: repository}); err != nil { + if _, err := s.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: repository}); err != nil { return nil, status.Errorf(codes.Internal, "CreateRepositoryFromURL: create hooks failed: %v", err) } @@ -56,10 +55,10 @@ func (s *server) CreateRepositoryFromURL(ctx context.Context, req *pb.CreateRepo return nil, status.Errorf(codes.Internal, "CreateRepositoryFromURL: %v", err) } - return &pb.CreateRepositoryFromURLResponse{}, nil + return &gitalypb.CreateRepositoryFromURLResponse{}, nil } -func validateCreateRepositoryFromURLRequest(req *pb.CreateRepositoryFromURLRequest) error { +func validateCreateRepositoryFromURLRequest(req *gitalypb.CreateRepositoryFromURLRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/repository/create_from_url_test.go b/internal/service/repository/create_from_url_test.go index 79e997245..7c780f51e 100644 --- a/internal/service/repository/create_from_url_test.go +++ b/internal/service/repository/create_from_url_test.go @@ -6,11 +6,10 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -25,12 +24,12 @@ func TestSuccessfulCreateRepositoryFromURLRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - importedRepo := &pb.Repository{ + importedRepo := &gitalypb.Repository{ RelativePath: "imports/test-repo-imported.git", StorageName: testhelper.DefaultStorageName, } - req := &pb.CreateRepositoryFromURLRequest{ + req := &gitalypb.CreateRepositoryFromURLRequest{ Repository: importedRepo, Url: "https://gitlab.com/gitlab-org/gitlab-test.git", } @@ -81,7 +80,7 @@ func TestFailedCreateRepositoryFromURLRequestDueToExistingTarget(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - importedRepo := &pb.Repository{ + importedRepo := &gitalypb.Repository{ RelativePath: "imports/test-repo-imported.git", StorageName: testhelper.DefaultStorageName, } @@ -96,7 +95,7 @@ func TestFailedCreateRepositoryFromURLRequestDueToExistingTarget(t *testing.T) { } defer os.RemoveAll(importedRepoPath) - req := &pb.CreateRepositoryFromURLRequest{ + req := &gitalypb.CreateRepositoryFromURLRequest{ Repository: importedRepo, Url: "https://gitlab.com/gitlab-org/gitlab-test.git", } diff --git a/internal/service/repository/create_test.go b/internal/service/repository/create_test.go index 5817af8e7..724005003 100644 --- a/internal/service/repository/create_test.go +++ b/internal/service/repository/create_test.go @@ -6,7 +6,7 @@ import ( "path" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -31,8 +31,8 @@ func TestCreateRepositorySuccess(t *testing.T) { repoDir := path.Join(storageDir, relativePath) require.NoError(t, os.RemoveAll(repoDir)) - repo := &pb.Repository{StorageName: "default", RelativePath: relativePath} - req := &pb.CreateRepositoryRequest{Repository: repo} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: relativePath} + req := &gitalypb.CreateRepositoryRequest{Repository: repo} _, err = client.CreateRepository(ctx, req) require.NoError(t, err) @@ -71,8 +71,8 @@ func TestCreateRepositoryFailure(t *testing.T) { require.NoError(t, err) defer os.RemoveAll(fullPath) - _, err = client.CreateRepository(ctx, &pb.CreateRepositoryRequest{ - Repository: &pb.Repository{StorageName: "default", RelativePath: "foo.git"}, + _, err = client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{ + Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "foo.git"}, }) testhelper.RequireGrpcError(t, err, codes.Unknown) @@ -89,18 +89,18 @@ func TestCreateRepositoryFailureInvalidArgs(t *testing.T) { defer cancel() testCases := []struct { - repo *pb.Repository + repo *gitalypb.Repository code codes.Code }{ { - repo: &pb.Repository{StorageName: "does not exist", RelativePath: "foobar.git"}, + repo: &gitalypb.Repository{StorageName: "does not exist", RelativePath: "foobar.git"}, code: codes.InvalidArgument, }, } for _, tc := range testCases { t.Run(fmt.Sprintf("%+v", tc.repo), func(t *testing.T) { - _, err := client.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: tc.repo}) + _, err := client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: tc.repo}) require.Error(t, err) testhelper.RequireGrpcError(t, err, tc.code) diff --git a/internal/service/repository/fetch.go b/internal/service/repository/fetch.go index bd5dfb499..9b0cca68c 100644 --- a/internal/service/repository/fetch.go +++ b/internal/service/repository/fetch.go @@ -1,13 +1,13 @@ package repository import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "golang.org/x/net/context" ) -func (s *server) FetchSourceBranch(ctx context.Context, req *pb.FetchSourceBranchRequest) (*pb.FetchSourceBranchResponse, error) { +func (s *server) FetchSourceBranch(ctx context.Context, req *gitalypb.FetchSourceBranchRequest) (*gitalypb.FetchSourceBranchResponse, error) { client, err := s.RepositoryServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/repository/fetch_remote.go b/internal/service/repository/fetch_remote.go index 3a6de02fa..6527735a2 100644 --- a/internal/service/repository/fetch_remote.go +++ b/internal/service/repository/fetch_remote.go @@ -5,11 +5,11 @@ import ( log "github.com/sirupsen/logrus" "golang.org/x/net/context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) -func (s *server) FetchRemote(ctx context.Context, in *pb.FetchRemoteRequest) (*pb.FetchRemoteResponse, error) { +func (s *server) FetchRemote(ctx context.Context, in *gitalypb.FetchRemoteRequest) (*gitalypb.FetchRemoteResponse, error) { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "Remote": in.GetRemote(), "Force": in.GetForce(), diff --git a/internal/service/repository/fetch_remote_test.go b/internal/service/repository/fetch_remote_test.go index f202e7b15..d1ca628c4 100644 --- a/internal/service/repository/fetch_remote_test.go +++ b/internal/service/repository/fetch_remote_test.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -15,11 +15,11 @@ import ( "github.com/stretchr/testify/require" ) -func copyRepoWithNewRemote(t *testing.T, repo *pb.Repository, remote string) *pb.Repository { +func copyRepoWithNewRemote(t *testing.T, repo *gitalypb.Repository, remote string) *gitalypb.Repository { repoPath, err := helper.GetRepoPath(repo) require.NoError(t, err) - cloneRepo := &pb.Repository{StorageName: repo.GetStorageName(), RelativePath: "fetch-remote-clone.git"} + cloneRepo := &gitalypb.Repository{StorageName: repo.GetStorageName(), RelativePath: "fetch-remote-clone.git"} clonePath := path.Join(testhelper.GitlabTestStoragePath(), "fetch-remote-clone.git") t.Logf("clonePath: %q", clonePath) @@ -45,7 +45,7 @@ func TestFetchRemoteSuccess(t *testing.T) { client, _ := newRepositoryClient(t, serverSocketPath) cloneRepo := copyRepoWithNewRemote(t, testRepo, "my-remote") - defer func(r *pb.Repository) { + defer func(r *gitalypb.Repository) { path, err := helper.GetRepoPath(r) if err != nil { panic(err) @@ -53,7 +53,7 @@ func TestFetchRemoteSuccess(t *testing.T) { os.RemoveAll(path) }(cloneRepo) - resp, err := client.FetchRemote(ctx, &pb.FetchRemoteRequest{ + resp, err := client.FetchRemote(ctx, &gitalypb.FetchRemoteRequest{ Repository: cloneRepo, Remote: "my-remote", Timeout: 120, @@ -70,13 +70,13 @@ func TestFetchRemoteFailure(t *testing.T) { tests := []struct { desc string - req *pb.FetchRemoteRequest + req *gitalypb.FetchRemoteRequest code codes.Code err string }{ { desc: "invalid storage", - req: &pb.FetchRemoteRequest{Repository: &pb.Repository{StorageName: "invalid", RelativePath: "foobar.git"}}, + req: &gitalypb.FetchRemoteRequest{Repository: &gitalypb.Repository{StorageName: "invalid", RelativePath: "foobar.git"}}, code: codes.InvalidArgument, err: "Storage can not be found by name 'invalid'", }, diff --git a/internal/service/repository/fetch_test.go b/internal/service/repository/fetch_test.go index 8ff989c1d..3515d511f 100644 --- a/internal/service/repository/fetch_test.go +++ b/internal/service/repository/fetch_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitLog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper" serverPkg "gitlab.com/gitlab-org/gitaly/internal/server" @@ -40,7 +40,7 @@ func TestFetchSourceBranchSourceRepositorySuccess(t *testing.T) { newCommitID := testhelper.CreateCommit(t, sourcePath, sourceBranch, nil) targetRef := "refs/tmp/fetch-source-branch-test" - req := &pb.FetchSourceBranchRequest{ + req := &gitalypb.FetchSourceBranchRequest{ Repository: targetRepo, SourceRepository: sourceRepo, SourceBranch: []byte(sourceBranch), @@ -75,7 +75,7 @@ func TestFetchSourceBranchSameRepositorySuccess(t *testing.T) { newCommitID := testhelper.CreateCommit(t, repoPath, sourceBranch, nil) targetRef := "refs/tmp/fetch-source-branch-test" - req := &pb.FetchSourceBranchRequest{ + req := &gitalypb.FetchSourceBranchRequest{ Repository: repo, SourceRepository: repo, SourceBranch: []byte(sourceBranch), @@ -111,12 +111,12 @@ func TestFetchSourceBranchBranchNotFound(t *testing.T) { targetRef := "refs/tmp/fetch-source-branch-test" testCases := []struct { - req *pb.FetchSourceBranchRequest + req *gitalypb.FetchSourceBranchRequest desc string }{ { desc: "target different from source", - req: &pb.FetchSourceBranchRequest{ + req: &gitalypb.FetchSourceBranchRequest{ Repository: targetRepo, SourceRepository: sourceRepo, SourceBranch: []byte(sourceBranch), @@ -125,7 +125,7 @@ func TestFetchSourceBranchBranchNotFound(t *testing.T) { }, { desc: "target same as source", - req: &pb.FetchSourceBranchRequest{ + req: &gitalypb.FetchSourceBranchRequest{ Repository: sourceRepo, SourceRepository: sourceRepo, SourceBranch: []byte(sourceBranch), @@ -172,11 +172,11 @@ func TestFetchFullServerRequiresAuthentication(t *testing.T) { testhelper.RequireGrpcError(t, err, codes.Unauthenticated) } -func newTestRepo(t *testing.T, relativePath string) (*pb.Repository, string) { +func newTestRepo(t *testing.T, relativePath string) (*gitalypb.Repository, string) { _, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - repo := &pb.Repository{StorageName: "default", RelativePath: relativePath} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: relativePath} repoPath, err := helper.GetPath(repo) require.NoError(t, err) diff --git a/internal/service/repository/fork.go b/internal/service/repository/fork.go index e626ba9be..8e75ddb0e 100644 --- a/internal/service/repository/fork.go +++ b/internal/service/repository/fork.go @@ -6,13 +6,12 @@ import ( "os/exec" "path" + "github.com/golang/protobuf/jsonpb" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - - "github.com/golang/protobuf/jsonpb" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -20,7 +19,7 @@ import ( const gitalyInternalURL = "ssh://gitaly/internal.git" -func (s *server) CreateFork(ctx context.Context, req *pb.CreateForkRequest) (*pb.CreateForkResponse, error) { +func (s *server) CreateFork(ctx context.Context, req *gitalypb.CreateForkRequest) (*gitalypb.CreateForkResponse, error) { targetRepository := req.Repository sourceRepository := req.SourceRepository @@ -61,7 +60,7 @@ func (s *server) CreateFork(ctx context.Context, req *pb.CreateForkRequest) (*pb sourceRepositoryGitalyToken := sourceRepositoryStorageInfo["token"] - cloneReq := &pb.SSHUploadPackRequest{Repository: sourceRepository} + cloneReq := &gitalypb.SSHUploadPackRequest{Repository: sourceRepository} pbMarshaler := &jsonpb.Marshaler{} payload, err := pbMarshaler.MarshalToString(cloneReq) if err != nil { @@ -97,9 +96,9 @@ func (s *server) CreateFork(ctx context.Context, req *pb.CreateForkRequest) (*pb } // CreateRepository is harmless on existing repositories with the side effect that it creates the hook symlink. - if _, err := s.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: targetRepository}); err != nil { + if _, err := s.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: targetRepository}); err != nil { return nil, status.Errorf(codes.Internal, "CreateFork: create hooks failed: %v", err) } - return &pb.CreateForkResponse{}, nil + return &gitalypb.CreateForkResponse{}, nil } diff --git a/internal/service/repository/fork_test.go b/internal/service/repository/fork_test.go index 0d06858e7..fe1eac701 100644 --- a/internal/service/repository/fork_test.go +++ b/internal/service/repository/fork_test.go @@ -6,12 +6,11 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/service/repository" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" @@ -33,12 +32,12 @@ func TestSuccessfulCreateForkRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - forkedRepo := &pb.Repository{ + forkedRepo := &gitalypb.Repository{ RelativePath: "forks/test-repo-fork.git", StorageName: testRepo.StorageName, } - req := &pb.CreateForkRequest{ + req := &gitalypb.CreateForkRequest{ Repository: forkedRepo, SourceRepository: testRepo, } @@ -95,7 +94,7 @@ func TestFailedCreateForkRequestDueToExistingTarget(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - forkedRepo := &pb.Repository{ + forkedRepo := &gitalypb.Repository{ RelativePath: testCase.repoPath, StorageName: testRepo.StorageName, } @@ -110,7 +109,7 @@ func TestFailedCreateForkRequestDueToExistingTarget(t *testing.T) { } defer os.RemoveAll(forkedRepoPath) - req := &pb.CreateForkRequest{ + req := &gitalypb.CreateForkRequest{ Repository: forkedRepo, SourceRepository: testRepo, } diff --git a/internal/service/repository/fsck.go b/internal/service/repository/fsck.go index a7764661e..3f2886802 100644 --- a/internal/service/repository/fsck.go +++ b/internal/service/repository/fsck.go @@ -4,14 +4,14 @@ import ( "bytes" "os/exec" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git/alternates" "golang.org/x/net/context" ) -func (s *server) Fsck(ctx context.Context, req *pb.FsckRequest) (*pb.FsckResponse, error) { +func (s *server) Fsck(ctx context.Context, req *gitalypb.FsckRequest) (*gitalypb.FsckResponse, error) { var stdout, stderr bytes.Buffer repoPath, env, err := alternates.PathAndEnv(req.GetRepository()) @@ -27,8 +27,8 @@ func (s *server) Fsck(ctx context.Context, req *pb.FsckRequest) (*pb.FsckRespons } if err = cmd.Wait(); err != nil { - return &pb.FsckResponse{Error: append(stdout.Bytes(), stderr.Bytes()...)}, nil + return &gitalypb.FsckResponse{Error: append(stdout.Bytes(), stderr.Bytes()...)}, nil } - return &pb.FsckResponse{}, nil + return &gitalypb.FsckResponse{}, nil } diff --git a/internal/service/repository/fsck_test.go b/internal/service/repository/fsck_test.go index e8777df67..a1c6ca850 100644 --- a/internal/service/repository/fsck_test.go +++ b/internal/service/repository/fsck_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -25,7 +25,7 @@ func TestFsckSuccess(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - c, err := client.Fsck(ctx, &pb.FsckRequest{Repository: testRepo}) + c, err := client.Fsck(ctx, &gitalypb.FsckRequest{Repository: testRepo}) assert.NoError(t, err) assert.NotNil(t, c) assert.Empty(t, c.GetError()) @@ -51,7 +51,7 @@ func TestFsckFailureSeverlyBrokenRepo(t *testing.T) { require.NoError(t, err) require.NoError(t, fd.Close()) - c, err := client.Fsck(ctx, &pb.FsckRequest{Repository: testRepo}) + c, err := client.Fsck(ctx, &gitalypb.FsckRequest{Repository: testRepo}) assert.NoError(t, err) assert.NotNil(t, c) assert.Contains(t, strings.ToLower(string(c.GetError())), "not a git repository") @@ -74,7 +74,7 @@ func TestFsckFailureSlightlyBrokenRepo(t *testing.T) { // proper repo, but `fsck` complains about broken refs... require.NoError(t, os.RemoveAll(path.Join(testRepoPath, "objects", "pack"))) - c, err := client.Fsck(ctx, &pb.FsckRequest{Repository: testRepo}) + c, err := client.Fsck(ctx, &gitalypb.FsckRequest{Repository: testRepo}) assert.NoError(t, err) assert.NotNil(t, c) assert.NotEmpty(t, string(c.GetError())) diff --git a/internal/service/repository/gc.go b/internal/service/repository/gc.go index 0c9ec9ec4..b1a1914f8 100644 --- a/internal/service/repository/gc.go +++ b/internal/service/repository/gc.go @@ -3,17 +3,17 @@ package repository import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper/housekeeping" "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" ) -func (server) GarbageCollect(ctx context.Context, in *pb.GarbageCollectRequest) (*pb.GarbageCollectResponse, error) { +func (server) GarbageCollect(ctx context.Context, in *gitalypb.GarbageCollectRequest) (*gitalypb.GarbageCollectResponse, error) { ctxlogger := grpc_logrus.Extract(ctx) ctxlogger.WithFields(log.Fields{ "WriteBitmaps": in.GetCreateBitmap(), @@ -53,5 +53,5 @@ func (server) GarbageCollect(ctx context.Context, in *pb.GarbageCollectRequest) ctxlogger.WithError(err).Warn("Post gc housekeeping failed") } - return &pb.GarbageCollectResponse{}, nil + return &gitalypb.GarbageCollectResponse{}, nil } diff --git a/internal/service/repository/gc_test.go b/internal/service/repository/gc_test.go index bdfb074be..416bf3a01 100644 --- a/internal/service/repository/gc_test.go +++ b/internal/service/repository/gc_test.go @@ -14,9 +14,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) var ( @@ -36,15 +35,15 @@ func TestGarbageCollectSuccess(t *testing.T) { defer cleanupFn() tests := []struct { - req *pb.GarbageCollectRequest + req *gitalypb.GarbageCollectRequest desc string }{ { - req: &pb.GarbageCollectRequest{Repository: testRepo, CreateBitmap: false}, + req: &gitalypb.GarbageCollectRequest{Repository: testRepo, CreateBitmap: false}, desc: "without bitmap", }, { - req: &pb.GarbageCollectRequest{Repository: testRepo, CreateBitmap: true}, + req: &gitalypb.GarbageCollectRequest{Repository: testRepo, CreateBitmap: true}, desc: "with bitmap", }, } @@ -96,7 +95,7 @@ func TestGarbageCollectDeletesRefsLocks(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.GarbageCollectRequest{Repository: testRepo} + req := &gitalypb.GarbageCollectRequest{Repository: testRepo} refsPath := filepath.Join(testRepoPath, "refs") // Note: Creating refs this way makes `git gc` crash but this actually works @@ -142,20 +141,20 @@ func TestGarbageCollectFailure(t *testing.T) { defer cleanupFn() tests := []struct { - repo *pb.Repository + repo *gitalypb.Repository code codes.Code }{ {repo: nil, code: codes.InvalidArgument}, - {repo: &pb.Repository{StorageName: "foo"}, code: codes.InvalidArgument}, - {repo: &pb.Repository{RelativePath: "bar"}, code: codes.InvalidArgument}, - {repo: &pb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar"}, code: codes.NotFound}, + {repo: &gitalypb.Repository{StorageName: "foo"}, code: codes.InvalidArgument}, + {repo: &gitalypb.Repository{RelativePath: "bar"}, code: codes.InvalidArgument}, + {repo: &gitalypb.Repository{StorageName: testRepo.GetStorageName(), RelativePath: "bar"}, code: codes.NotFound}, } for _, test := range tests { t.Run(fmt.Sprintf("%v", test.repo), func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - _, err := client.GarbageCollect(ctx, &pb.GarbageCollectRequest{Repository: test.repo}) + _, err := client.GarbageCollect(ctx, &gitalypb.GarbageCollectRequest{Repository: test.repo}) testhelper.RequireGrpcError(t, err, test.code) }) } diff --git a/internal/service/repository/info_attributes.go b/internal/service/repository/info_attributes.go index 9cca3d09c..ea6c7f624 100644 --- a/internal/service/repository/info_attributes.go +++ b/internal/service/repository/info_attributes.go @@ -5,7 +5,7 @@ import ( "os" "path" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -13,7 +13,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) GetInfoAttributes(in *pb.GetInfoAttributesRequest, stream pb.RepositoryService_GetInfoAttributesServer) error { +func (s *server) GetInfoAttributes(in *gitalypb.GetInfoAttributesRequest, stream gitalypb.RepositoryService_GetInfoAttributesServer) error { repoPath, err := helper.GetRepoPath(in.GetRepository()) if err != nil { return err @@ -23,7 +23,7 @@ func (s *server) GetInfoAttributes(in *pb.GetInfoAttributesRequest, stream pb.Re f, err := os.Open(attrFile) if err != nil { if os.IsNotExist(err) { - stream.Send(&pb.GetInfoAttributesResponse{}) + stream.Send(&gitalypb.GetInfoAttributesResponse{}) return nil } @@ -31,7 +31,7 @@ func (s *server) GetInfoAttributes(in *pb.GetInfoAttributesRequest, stream pb.Re } sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.GetInfoAttributesResponse{ + return stream.Send(&gitalypb.GetInfoAttributesResponse{ Attributes: p, }) }) diff --git a/internal/service/repository/info_attributes_test.go b/internal/service/repository/info_attributes_test.go index d33cfa265..4f55fc87f 100644 --- a/internal/service/repository/info_attributes_test.go +++ b/internal/service/repository/info_attributes_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" ) @@ -32,7 +32,7 @@ func TestGetInfoAttributesExisting(t *testing.T) { err := ioutil.WriteFile(attrsPath, data, 0644) require.NoError(t, err) - request := &pb.GetInfoAttributesRequest{Repository: testRepo} + request := &gitalypb.GetInfoAttributesRequest{Repository: testRepo} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() @@ -58,7 +58,7 @@ func TestGetInfoAttributesNonExisting(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - request := &pb.GetInfoAttributesRequest{Repository: testRepo} + request := &gitalypb.GetInfoAttributesRequest{Repository: testRepo} testCtx, cancelCtx := testhelper.Context() defer cancelCtx() diff --git a/internal/service/repository/license.go b/internal/service/repository/license.go index bc2641b46..9997d4e64 100644 --- a/internal/service/repository/license.go +++ b/internal/service/repository/license.go @@ -3,12 +3,11 @@ package repository import ( "golang.org/x/net/context" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) -func (s *server) FindLicense(ctx context.Context, in *pb.FindLicenseRequest) (*pb.FindLicenseResponse, error) { +func (s *server) FindLicense(ctx context.Context, in *gitalypb.FindLicenseRequest) (*gitalypb.FindLicenseResponse, error) { client, err := s.RepositoryServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/repository/license_test.go b/internal/service/repository/license_test.go index e09427be5..fe016f7a6 100644 --- a/internal/service/repository/license_test.go +++ b/internal/service/repository/license_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -21,7 +21,7 @@ func TestSuccessfulFindLicenseRequest(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - req := &pb.FindLicenseRequest{Repository: testRepo} + req := &gitalypb.FindLicenseRequest{Repository: testRepo} ctx, cancel := testhelper.Context() defer cancel() @@ -42,19 +42,19 @@ func TestFindLicenseRequestEmptyRepo(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - emptyRepo := &pb.Repository{ + emptyRepo := &gitalypb.Repository{ RelativePath: "test-liceense-empty-repo.git", StorageName: testhelper.DefaultStorageName, } - _, err := client.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: emptyRepo}) + _, err := client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{Repository: emptyRepo}) require.NoError(t, err) emptyRepoPath, err := helper.GetRepoPath(emptyRepo) require.NoError(t, err) defer os.RemoveAll(emptyRepoPath) - req := &pb.FindLicenseRequest{Repository: emptyRepo} + req := &gitalypb.FindLicenseRequest{Repository: emptyRepo} resp, err := client.FindLicense(ctx, req) require.NoError(t, err) diff --git a/internal/service/repository/merge_base.go b/internal/service/repository/merge_base.go index 597f5bee1..d180c857d 100644 --- a/internal/service/repository/merge_base.go +++ b/internal/service/repository/merge_base.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "golang.org/x/net/context" @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) FindMergeBase(ctx context.Context, req *pb.FindMergeBaseRequest) (*pb.FindMergeBaseResponse, error) { +func (s *server) FindMergeBase(ctx context.Context, req *gitalypb.FindMergeBaseRequest) (*gitalypb.FindMergeBaseResponse, error) { revisions := req.GetRevisions() if len(revisions) < 2 { return nil, status.Errorf(codes.InvalidArgument, "FindMergeBase: at least 2 revisions are required") @@ -40,8 +40,8 @@ func (s *server) FindMergeBase(ctx context.Context, req *pb.FindMergeBaseRequest if err := cmd.Wait(); err != nil { // On error just return an empty merge base - return &pb.FindMergeBaseResponse{Base: ""}, nil + return &gitalypb.FindMergeBaseResponse{Base: ""}, nil } - return &pb.FindMergeBaseResponse{Base: mergeBaseStr}, nil + return &gitalypb.FindMergeBaseResponse{Base: mergeBaseStr}, nil } diff --git a/internal/service/repository/merge_base_test.go b/internal/service/repository/merge_base_test.go index 53cc54d3b..681cc895c 100644 --- a/internal/service/repository/merge_base_test.go +++ b/internal/service/repository/merge_base_test.go @@ -3,10 +3,9 @@ package repository import ( "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -74,7 +73,7 @@ func TestSuccessfulFindFindMergeBaseRequest(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.FindMergeBaseRequest{ + request := &gitalypb.FindMergeBaseRequest{ Repository: testRepo, Revisions: testCase.revisions, } @@ -100,7 +99,7 @@ func TestFailedFindMergeBaseRequestDueToValidations(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.FindMergeBaseRequest{ + request := &gitalypb.FindMergeBaseRequest{ Repository: testRepo, Revisions: [][]byte{ []byte("372ab6950519549b14d220271ee2322caa44d4eb"), diff --git a/internal/service/repository/raw_changes.go b/internal/service/repository/raw_changes.go index 7e7faa95b..7495f8bda 100644 --- a/internal/service/repository/raw_changes.go +++ b/internal/service/repository/raw_changes.go @@ -1,14 +1,14 @@ package repository import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) GetRawChanges(req *pb.GetRawChangesRequest, stream pb.RepositoryService_GetRawChangesServer) error { +func (s *server) GetRawChanges(req *gitalypb.GetRawChangesRequest, stream gitalypb.RepositoryService_GetRawChangesServer) error { if req.GetRepository() == nil { return status.Errorf(codes.InvalidArgument, "repository argument must be present") } diff --git a/internal/service/repository/raw_changes_test.go b/internal/service/repository/raw_changes_test.go index 200071ff9..5d1af5d86 100644 --- a/internal/service/repository/raw_changes_test.go +++ b/internal/service/repository/raw_changes_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) @@ -22,18 +22,18 @@ func TestGetRawChanges(t *testing.T) { testCases := []struct { oldRev string newRev string - changes []*pb.GetRawChangesResponse_RawChange + changes []*gitalypb.GetRawChangesResponse_RawChange }{ { oldRev: "55bc176024cfa3baaceb71db584c7e5df900ea65", newRev: "7975be0116940bf2ad4321f79d02a55c5f7779aa", - changes: []*pb.GetRawChangesResponse_RawChange{ + changes: []*gitalypb.GetRawChangesResponse_RawChange{ { BlobId: "c60514b6d3d6bf4bec1030f70026e34dfbd69ad5", Size: 824, NewPath: "README.md", OldPath: "README.md", - Operation: pb.GetRawChangesResponse_RawChange_MODIFIED, + Operation: gitalypb.GetRawChangesResponse_RawChange_MODIFIED, OldMode: 0100644, NewMode: 0100644, }, @@ -41,7 +41,7 @@ func TestGetRawChanges(t *testing.T) { BlobId: "723c2c3f4c8a2a1e957f878c8813acfc08cda2b6", Size: 1219696, NewPath: "files/images/emoji.png", - Operation: pb.GetRawChangesResponse_RawChange_ADDED, + Operation: gitalypb.GetRawChangesResponse_RawChange_ADDED, NewMode: 0100644, }, }, @@ -49,26 +49,26 @@ func TestGetRawChanges(t *testing.T) { { oldRev: "0000000000000000000000000000000000000000", newRev: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863", - changes: []*pb.GetRawChangesResponse_RawChange{ + changes: []*gitalypb.GetRawChangesResponse_RawChange{ { BlobId: "470ad2fcf1e33798f1afc5781d08e60c40f51e7a", Size: 231, NewPath: ".gitignore", - Operation: pb.GetRawChangesResponse_RawChange_ADDED, + Operation: gitalypb.GetRawChangesResponse_RawChange_ADDED, NewMode: 0100644, }, { BlobId: "50b27c6518be44c42c4d87966ae2481ce895624c", Size: 1075, NewPath: "LICENSE", - Operation: pb.GetRawChangesResponse_RawChange_ADDED, + Operation: gitalypb.GetRawChangesResponse_RawChange_ADDED, NewMode: 0100644, }, { BlobId: "faaf198af3a36dbf41961466703cc1d47c61d051", Size: 55, NewPath: "README.md", - Operation: pb.GetRawChangesResponse_RawChange_ADDED, + Operation: gitalypb.GetRawChangesResponse_RawChange_ADDED, NewMode: 0100644, }, }, @@ -76,13 +76,13 @@ func TestGetRawChanges(t *testing.T) { { oldRev: "6b8dc4a827797aa025ff6b8f425e583858a10d4f", newRev: "06041ab2037429d243a38abb55957818dd9f948d", - changes: []*pb.GetRawChangesResponse_RawChange{ + changes: []*gitalypb.GetRawChangesResponse_RawChange{ { BlobId: "c84acd1ff0b844201312052f9bb3b7259eb2e177", Size: 23, NewPath: "files/executables/ls", OldPath: "files/executables/ls", - Operation: pb.GetRawChangesResponse_RawChange_MODIFIED, + Operation: gitalypb.GetRawChangesResponse_RawChange_MODIFIED, OldMode: 0100755, NewMode: 0100644, }, @@ -94,7 +94,7 @@ func TestGetRawChanges(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.GetRawChangesRequest{testRepo, tc.oldRev, tc.newRev} + req := &gitalypb.GetRawChangesRequest{testRepo, tc.oldRev, tc.newRev} resp, err := client.GetRawChanges(ctx, req) require.NoError(t, err) @@ -139,7 +139,7 @@ func TestGetRawChangesFailures(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.GetRawChangesRequest{testRepo, tc.oldRev, tc.newRev} + req := &gitalypb.GetRawChangesRequest{testRepo, tc.oldRev, tc.newRev} resp, err := client.GetRawChanges(ctx, req) require.NoError(t, err) @@ -163,12 +163,12 @@ func TestGetRawChangesManyFiles(t *testing.T) { defer cancel() initCommit := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863" - req := &pb.GetRawChangesRequest{testRepo, initCommit, "many_files"} + req := &gitalypb.GetRawChangesRequest{testRepo, initCommit, "many_files"} c, err := client.GetRawChanges(ctx, req) require.NoError(t, err) - changes := []*pb.GetRawChangesResponse_RawChange{} + changes := []*gitalypb.GetRawChangesResponse_RawChange{} for { resp, err := c.Recv() if err == io.EOF { @@ -196,7 +196,7 @@ func TestGetRawChangesMappingOperations(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - req := &pb.GetRawChangesRequest{ + req := &gitalypb.GetRawChangesRequest{ testRepo, "1b12f15a11fc6e62177bef08f47bc7b5ce50b141", "94bb47ca1297b7b3731ff2a36923640991e9236f", @@ -207,23 +207,23 @@ func TestGetRawChangesMappingOperations(t *testing.T) { msg, err := c.Recv() require.NoError(t, err) - ops := []pb.GetRawChangesResponse_RawChange_Operation{} + ops := []gitalypb.GetRawChangesResponse_RawChange_Operation{} for _, change := range msg.GetRawChanges() { ops = append(ops, change.GetOperation()) } - expected := []pb.GetRawChangesResponse_RawChange_Operation{ - pb.GetRawChangesResponse_RawChange_RENAMED, - pb.GetRawChangesResponse_RawChange_MODIFIED, - pb.GetRawChangesResponse_RawChange_ADDED, + expected := []gitalypb.GetRawChangesResponse_RawChange_Operation{ + gitalypb.GetRawChangesResponse_RawChange_RENAMED, + gitalypb.GetRawChangesResponse_RawChange_MODIFIED, + gitalypb.GetRawChangesResponse_RawChange_ADDED, } - firstChange := &pb.GetRawChangesResponse_RawChange{ + firstChange := &gitalypb.GetRawChangesResponse_RawChange{ BlobId: "53855584db773c3df5b5f61f72974cb298822fbb", Size: 22846, NewPath: "CHANGELOG.md", OldPath: "CHANGELOG", - Operation: pb.GetRawChangesResponse_RawChange_RENAMED, + Operation: gitalypb.GetRawChangesResponse_RawChange_RENAMED, OldMode: 0100644, NewMode: 0100644, } diff --git a/internal/service/repository/rebase_in_progress.go b/internal/service/repository/rebase_in_progress.go index dc7d16b6e..3ba5eb511 100644 --- a/internal/service/repository/rebase_in_progress.go +++ b/internal/service/repository/rebase_in_progress.go @@ -7,7 +7,7 @@ import ( "strings" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/helper/housekeeping" @@ -22,7 +22,7 @@ const ( freshTimeout = 15 * time.Minute ) -func (s *server) IsRebaseInProgress(ctx context.Context, req *pb.IsRebaseInProgressRequest) (*pb.IsRebaseInProgressResponse, error) { +func (s *server) IsRebaseInProgress(ctx context.Context, req *gitalypb.IsRebaseInProgressRequest) (*gitalypb.IsRebaseInProgressResponse, error) { if err := validateIsRebaseInProgressRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "IsRebaseInProgress: %v", err) } @@ -36,7 +36,7 @@ func (s *server) IsRebaseInProgress(ctx context.Context, req *pb.IsRebaseInProgr if err != nil { return nil, err } - return &pb.IsRebaseInProgressResponse{InProgress: inProg}, nil + return &gitalypb.IsRebaseInProgressResponse{InProgress: inProg}, nil } func freshWorktree(repoPath, prefix, id string) (bool, error) { @@ -60,7 +60,7 @@ func freshWorktree(repoPath, prefix, id string) (bool, error) { return true, nil } -func validateIsRebaseInProgressRequest(req *pb.IsRebaseInProgressRequest) error { +func validateIsRebaseInProgressRequest(req *gitalypb.IsRebaseInProgressRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/repository/rebase_in_progress_test.go b/internal/service/repository/rebase_in_progress_test.go index ab0c212e3..30501ee80 100644 --- a/internal/service/repository/rebase_in_progress_test.go +++ b/internal/service/repository/rebase_in_progress_test.go @@ -7,10 +7,9 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -45,12 +44,12 @@ func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) { testCases := []struct { desc string - request *pb.IsRebaseInProgressRequest + request *gitalypb.IsRebaseInProgressRequest inProgress bool }{ { desc: "rebase in progress", - request: &pb.IsRebaseInProgressRequest{ + request: &gitalypb.IsRebaseInProgressRequest{ Repository: testRepo1, RebaseId: "1", }, @@ -58,7 +57,7 @@ func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) { }, { desc: "broken rebase in progress", - request: &pb.IsRebaseInProgressRequest{ + request: &gitalypb.IsRebaseInProgressRequest{ Repository: testRepo1, RebaseId: "2", }, @@ -66,7 +65,7 @@ func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) { }, { desc: "expired rebase in progress", - request: &pb.IsRebaseInProgressRequest{ + request: &gitalypb.IsRebaseInProgressRequest{ Repository: testRepo1, RebaseId: "3", }, @@ -74,7 +73,7 @@ func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) { }, { desc: "no rebase in progress", - request: &pb.IsRebaseInProgressRequest{ + request: &gitalypb.IsRebaseInProgressRequest{ Repository: testRepo2, RebaseId: "2", }, @@ -104,17 +103,17 @@ func TestFailedIsRebaseInProgressRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.IsRebaseInProgressRequest + request *gitalypb.IsRebaseInProgressRequest code codes.Code }{ { desc: "empty repository", - request: &pb.IsRebaseInProgressRequest{RebaseId: "1"}, + request: &gitalypb.IsRebaseInProgressRequest{RebaseId: "1"}, code: codes.InvalidArgument, }, { desc: "empty rebase id", - request: &pb.IsRebaseInProgressRequest{Repository: &pb.Repository{}}, + request: &gitalypb.IsRebaseInProgressRequest{Repository: &gitalypb.Repository{}}, code: codes.InvalidArgument, }, } diff --git a/internal/service/repository/repack.go b/internal/service/repository/repack.go index 14c455bf1..9a5fca46f 100644 --- a/internal/service/repository/repack.go +++ b/internal/service/repository/repack.go @@ -7,25 +7,25 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" ) -func (server) RepackFull(ctx context.Context, in *pb.RepackFullRequest) (*pb.RepackFullResponse, error) { +func (server) RepackFull(ctx context.Context, in *gitalypb.RepackFullRequest) (*gitalypb.RepackFullResponse, error) { if err := repackCommand(ctx, "RepackFull", in.GetRepository(), in.GetCreateBitmap(), "-A", "--pack-kept-objects"); err != nil { return nil, err } - return &pb.RepackFullResponse{}, nil + return &gitalypb.RepackFullResponse{}, nil } -func (server) RepackIncremental(ctx context.Context, in *pb.RepackIncrementalRequest) (*pb.RepackIncrementalResponse, error) { +func (server) RepackIncremental(ctx context.Context, in *gitalypb.RepackIncrementalRequest) (*gitalypb.RepackIncrementalResponse, error) { if err := repackCommand(ctx, "RepackIncremental", in.GetRepository(), false); err != nil { return nil, err } - return &pb.RepackIncrementalResponse{}, nil + return &gitalypb.RepackIncrementalResponse{}, nil } -func repackCommand(ctx context.Context, rpcName string, repo *pb.Repository, bitmap bool, args ...string) error { +func repackCommand(ctx context.Context, rpcName string, repo *gitalypb.Repository, bitmap bool, args ...string) error { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "WriteBitmaps": bitmap, }).Debug(rpcName) diff --git a/internal/service/repository/repack_test.go b/internal/service/repository/repack_test.go index c3f3bc6d8..f7053d912 100644 --- a/internal/service/repository/repack_test.go +++ b/internal/service/repository/repack_test.go @@ -10,9 +10,8 @@ import ( "google.golang.org/grpc/codes" "github.com/stretchr/testify/assert" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) func TestRepackIncrementalSuccess(t *testing.T) { @@ -34,7 +33,7 @@ func TestRepackIncrementalSuccess(t *testing.T) { testTime := time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC) ctx, cancel := context.WithCancel(context.Background()) defer cancel() - c, err := client.RepackIncremental(ctx, &pb.RepackIncrementalRequest{Repository: testRepo}) + c, err := client.RepackIncremental(ctx, &gitalypb.RepackIncrementalRequest{Repository: testRepo}) assert.NoError(t, err) assert.NotNil(t, c) @@ -50,21 +49,21 @@ func TestRepackIncrementalFailure(t *testing.T) { defer conn.Close() tests := []struct { - repo *pb.Repository + repo *gitalypb.Repository code codes.Code desc string }{ {desc: "nil repo", repo: nil, code: codes.InvalidArgument}, - {desc: "invalid storage name", repo: &pb.Repository{StorageName: "foo"}, code: codes.InvalidArgument}, - {desc: "no storage name", repo: &pb.Repository{RelativePath: "bar"}, code: codes.InvalidArgument}, - {desc: "non-existing repo", repo: &pb.Repository{StorageName: testhelper.TestRepository().GetStorageName(), RelativePath: "bar"}, code: codes.NotFound}, + {desc: "invalid storage name", repo: &gitalypb.Repository{StorageName: "foo"}, code: codes.InvalidArgument}, + {desc: "no storage name", repo: &gitalypb.Repository{RelativePath: "bar"}, code: codes.InvalidArgument}, + {desc: "non-existing repo", repo: &gitalypb.Repository{StorageName: testhelper.TestRepository().GetStorageName(), RelativePath: "bar"}, code: codes.NotFound}, } for _, test := range tests { t.Run(test.desc, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - _, err := client.RepackIncremental(ctx, &pb.RepackIncrementalRequest{Repository: test.repo}) + _, err := client.RepackIncremental(ctx, &gitalypb.RepackIncrementalRequest{Repository: test.repo}) testhelper.RequireGrpcError(t, err, test.code) }) } @@ -81,11 +80,11 @@ func TestRepackFullSuccess(t *testing.T) { defer cleanupFn() tests := []struct { - req *pb.RepackFullRequest + req *gitalypb.RepackFullRequest desc string }{ - {req: &pb.RepackFullRequest{Repository: testRepo, CreateBitmap: true}, desc: "with bitmap"}, - {req: &pb.RepackFullRequest{Repository: testRepo, CreateBitmap: false}, desc: "without bitmap"}, + {req: &gitalypb.RepackFullRequest{Repository: testRepo, CreateBitmap: true}, desc: "with bitmap"}, + {req: &gitalypb.RepackFullRequest{Repository: testRepo, CreateBitmap: false}, desc: "without bitmap"}, } packPath := path.Join(testRepoPath, "objects", "pack") @@ -130,21 +129,21 @@ func TestRepackFullFailure(t *testing.T) { defer conn.Close() tests := []struct { - repo *pb.Repository + repo *gitalypb.Repository code codes.Code desc string }{ {desc: "nil repo", repo: nil, code: codes.InvalidArgument}, - {desc: "invalid storage name", repo: &pb.Repository{StorageName: "foo"}, code: codes.InvalidArgument}, - {desc: "no storage name", repo: &pb.Repository{RelativePath: "bar"}, code: codes.InvalidArgument}, - {desc: "non-existing repo", repo: &pb.Repository{StorageName: testhelper.TestRepository().GetStorageName(), RelativePath: "bar"}, code: codes.NotFound}, + {desc: "invalid storage name", repo: &gitalypb.Repository{StorageName: "foo"}, code: codes.InvalidArgument}, + {desc: "no storage name", repo: &gitalypb.Repository{RelativePath: "bar"}, code: codes.InvalidArgument}, + {desc: "non-existing repo", repo: &gitalypb.Repository{StorageName: testhelper.TestRepository().GetStorageName(), RelativePath: "bar"}, code: codes.NotFound}, } for _, test := range tests { t.Run(test.desc, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - _, err := client.RepackFull(ctx, &pb.RepackFullRequest{Repository: test.repo}) + _, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: test.repo}) testhelper.RequireGrpcError(t, err, test.code) }) } diff --git a/internal/service/repository/repository.go b/internal/service/repository/repository.go index 27ae78b83..38ac363e2 100644 --- a/internal/service/repository/repository.go +++ b/internal/service/repository/repository.go @@ -7,26 +7,26 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" ) // Deprecated -func (s *server) Exists(ctx context.Context, in *pb.RepositoryExistsRequest) (*pb.RepositoryExistsResponse, error) { +func (s *server) Exists(ctx context.Context, in *gitalypb.RepositoryExistsRequest) (*gitalypb.RepositoryExistsResponse, error) { return nil, helper.Unimplemented } -func (s *server) RepositoryExists(ctx context.Context, in *pb.RepositoryExistsRequest) (*pb.RepositoryExistsResponse, error) { +func (s *server) RepositoryExists(ctx context.Context, in *gitalypb.RepositoryExistsRequest) (*gitalypb.RepositoryExistsResponse, error) { path, err := helper.GetPath(in.Repository) if err != nil { return nil, err } - return &pb.RepositoryExistsResponse{Exists: helper.IsGitDirectory(path)}, nil + return &gitalypb.RepositoryExistsResponse{Exists: helper.IsGitDirectory(path)}, nil } -func (s *server) HasLocalBranches(ctx context.Context, in *pb.HasLocalBranchesRequest) (*pb.HasLocalBranchesResponse, error) { +func (s *server) HasLocalBranches(ctx context.Context, in *gitalypb.HasLocalBranchesRequest) (*gitalypb.HasLocalBranchesResponse, error) { args := []string{"for-each-ref", "--count=1", "refs/heads"} cmd, err := git.Command(ctx, in.GetRepository(), args...) if err != nil { @@ -45,5 +45,5 @@ func (s *server) HasLocalBranches(ctx context.Context, in *pb.HasLocalBranchesRe return nil, status.Errorf(codes.Internal, "HasLocalBranches: cmd wait: %v", err) } - return &pb.HasLocalBranchesResponse{Value: len(buff) > 0}, nil + return &gitalypb.HasLocalBranchesResponse{Value: len(buff) > 0}, nil } diff --git a/internal/service/repository/repository_test.go b/internal/service/repository/repository_test.go index 5c03ebd26..dfc3e2cc7 100644 --- a/internal/service/repository/repository_test.go +++ b/internal/service/repository/repository_test.go @@ -6,7 +6,7 @@ import ( "path" "testing" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -41,21 +41,21 @@ func TestRepositoryExists(t *testing.T) { queries := []struct { desc string - request *pb.RepositoryExistsRequest + request *gitalypb.RepositoryExistsRequest errorCode codes.Code exists bool }{ { desc: "repository nil", - request: &pb.RepositoryExistsRequest{ + request: &gitalypb.RepositoryExistsRequest{ Repository: nil, }, errorCode: codes.InvalidArgument, }, { desc: "storage name empty", - request: &pb.RepositoryExistsRequest{ - Repository: &pb.Repository{ + request: &gitalypb.RepositoryExistsRequest{ + Repository: &gitalypb.Repository{ StorageName: "", RelativePath: testhelper.TestRelativePath, }, @@ -64,8 +64,8 @@ func TestRepositoryExists(t *testing.T) { }, { desc: "relative path empty", - request: &pb.RepositoryExistsRequest{ - Repository: &pb.Repository{ + request: &gitalypb.RepositoryExistsRequest{ + Repository: &gitalypb.Repository{ StorageName: "default", RelativePath: "", }, @@ -74,8 +74,8 @@ func TestRepositoryExists(t *testing.T) { }, { desc: "exists true", - request: &pb.RepositoryExistsRequest{ - Repository: &pb.Repository{ + request: &gitalypb.RepositoryExistsRequest{ + Repository: &gitalypb.Repository{ StorageName: "default", RelativePath: testhelper.TestRelativePath, }, @@ -84,8 +84,8 @@ func TestRepositoryExists(t *testing.T) { }, { desc: "exists false, wrong storage", - request: &pb.RepositoryExistsRequest{ - Repository: &pb.Repository{ + request: &gitalypb.RepositoryExistsRequest{ + Repository: &gitalypb.Repository{ StorageName: "other", RelativePath: testhelper.TestRelativePath, }, @@ -94,8 +94,8 @@ func TestRepositoryExists(t *testing.T) { }, { desc: "storage directory does not exist", - request: &pb.RepositoryExistsRequest{ - Repository: &pb.Repository{ + request: &gitalypb.RepositoryExistsRequest{ + Repository: &gitalypb.Repository{ StorageName: "broken", RelativePath: "foobar.git", }, @@ -139,19 +139,19 @@ func TestSuccessfulHasLocalBranches(t *testing.T) { testCases := []struct { desc string - request *pb.HasLocalBranchesRequest + request *gitalypb.HasLocalBranchesRequest value bool errorCode codes.Code }{ { desc: "repository has branches", - request: &pb.HasLocalBranchesRequest{Repository: testRepo}, + request: &gitalypb.HasLocalBranchesRequest{Repository: testRepo}, value: true, }, { desc: "repository doesn't have branches", - request: &pb.HasLocalBranchesRequest{ - Repository: &pb.Repository{ + request: &gitalypb.HasLocalBranchesRequest{ + Repository: &gitalypb.Repository{ StorageName: "default", RelativePath: emptyRepoName, }, @@ -186,7 +186,7 @@ func TestFailedHasLocalBranches(t *testing.T) { testCases := []struct { desc string - repository *pb.Repository + repository *gitalypb.Repository errorCode codes.Code }{ { @@ -196,7 +196,7 @@ func TestFailedHasLocalBranches(t *testing.T) { }, { desc: "repository doesn't exist", - repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, + repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, errorCode: codes.InvalidArgument, }, } @@ -206,7 +206,7 @@ func TestFailedHasLocalBranches(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - request := &pb.HasLocalBranchesRequest{Repository: tc.repository} + request := &gitalypb.HasLocalBranchesRequest{Repository: tc.repository} _, err := client.HasLocalBranches(ctx, request) require.Equal(t, tc.errorCode, helper.GrpcCode(err)) diff --git a/internal/service/repository/restore_custom_hooks.go b/internal/service/repository/restore_custom_hooks.go index 988f7fbd2..d68a2df3b 100644 --- a/internal/service/repository/restore_custom_hooks.go +++ b/internal/service/repository/restore_custom_hooks.go @@ -3,7 +3,7 @@ package repository import ( "os/exec" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) RestoreCustomHooks(stream pb.RepositoryService_RestoreCustomHooksServer) error { +func (s *server) RestoreCustomHooks(stream gitalypb.RepositoryService_RestoreCustomHooksServer) error { firstRequest, err := stream.Recv() if err != nil { return status.Errorf(codes.Internal, "RestoreCustomHooks: first request failed %v", err) @@ -56,5 +56,5 @@ func (s *server) RestoreCustomHooks(stream pb.RepositoryService_RestoreCustomHoo return status.Errorf(codes.Internal, "RestoreCustomHooks: cmd wait failed: %v", err) } - return stream.SendAndClose(&pb.RestoreCustomHooksResponse{}) + return stream.SendAndClose(&gitalypb.RestoreCustomHooksResponse{}) } diff --git a/internal/service/repository/restore_custom_hooks_test.go b/internal/service/repository/restore_custom_hooks_test.go index b0d8f59c2..238ca72db 100644 --- a/internal/service/repository/restore_custom_hooks_test.go +++ b/internal/service/repository/restore_custom_hooks_test.go @@ -6,13 +6,12 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" ) @@ -37,14 +36,14 @@ func TestSuccessfullRestoreCustomHooksRequest(t *testing.T) { repoPath, err := helper.GetPath(testRepo) require.NoError(t, err) defer os.RemoveAll(repoPath) - request := &pb.RestoreCustomHooksRequest{Repository: testRepo} + request := &gitalypb.RestoreCustomHooksRequest{Repository: testRepo} writer := streamio.NewWriter(func(p []byte) error { request.Data = p if err := stream.Send(request); err != nil { return err } - request = &pb.RestoreCustomHooksRequest{} + request = &gitalypb.RestoreCustomHooksRequest{} return nil }) @@ -73,7 +72,7 @@ func TestFailedRestoreCustomHooksDueToValidations(t *testing.T) { stream, err := client.RestoreCustomHooks(ctx) require.NoError(t, err) - require.NoError(t, stream.Send(&pb.RestoreCustomHooksRequest{})) + require.NoError(t, stream.Send(&gitalypb.RestoreCustomHooksRequest{})) _, err = stream.CloseAndRecv() testhelper.RequireGrpcError(t, err, codes.InvalidArgument) @@ -100,14 +99,14 @@ func TestFailedRestoreCustomHooksDueToBadTar(t *testing.T) { repoPath, err := helper.GetPath(testRepo) require.NoError(t, err) defer os.RemoveAll(repoPath) - request := &pb.RestoreCustomHooksRequest{Repository: testRepo} + request := &gitalypb.RestoreCustomHooksRequest{Repository: testRepo} writer := streamio.NewWriter(func(p []byte) error { request.Data = p if err := stream.Send(request); err != nil { return err } - request = &pb.RestoreCustomHooksRequest{} + request = &gitalypb.RestoreCustomHooksRequest{} return nil }) diff --git a/internal/service/repository/search_files.go b/internal/service/repository/search_files.go index 56c6d0318..def8fa702 100644 --- a/internal/service/repository/search_files.go +++ b/internal/service/repository/search_files.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/helper/lines" @@ -17,7 +17,7 @@ const surroundContext = "2" var contentDelimiter = []byte("--\n") -func (s *server) SearchFilesByContent(req *pb.SearchFilesByContentRequest, stream pb.RepositoryService_SearchFilesByContentServer) error { +func (s *server) SearchFilesByContent(req *gitalypb.SearchFilesByContentRequest, stream gitalypb.RepositoryService_SearchFilesByContentServer) error { if err := validateSearchFilesRequest(req); err != nil { return helper.DecorateError(codes.InvalidArgument, err) } @@ -58,7 +58,7 @@ func (s *server) SearchFilesByContent(req *pb.SearchFilesByContentRequest, strea } } if len(matches) > 0 { - err = stream.Send(&pb.SearchFilesByContentResponse{Matches: matches}) + err = stream.Send(&gitalypb.SearchFilesByContentResponse{Matches: matches}) matches = nil return err } @@ -73,12 +73,12 @@ func (s *server) SearchFilesByContent(req *pb.SearchFilesByContentRequest, strea matches = append(matches, buf) } if len(matches) > 0 { - return stream.Send(&pb.SearchFilesByContentResponse{Matches: matches}) + return stream.Send(&gitalypb.SearchFilesByContentResponse{Matches: matches}) } return nil } -func (s *server) SearchFilesByName(req *pb.SearchFilesByNameRequest, stream pb.RepositoryService_SearchFilesByNameServer) error { +func (s *server) SearchFilesByName(req *gitalypb.SearchFilesByNameRequest, stream gitalypb.RepositoryService_SearchFilesByNameServer) error { if err := validateSearchFilesRequest(req); err != nil { return helper.DecorateError(codes.InvalidArgument, err) } @@ -94,7 +94,7 @@ func (s *server) SearchFilesByName(req *pb.SearchFilesByNameRequest, stream pb.R } lr := func(objs [][]byte) error { - return stream.Send(&pb.SearchFilesByNameResponse{Files: objs}) + return stream.Send(&gitalypb.SearchFilesByNameResponse{Files: objs}) } return lines.Send(cmd, lr, []byte{'\n'}) diff --git a/internal/service/repository/search_files_test.go b/internal/service/repository/search_files_test.go index 51a61d2af..ac3448935 100644 --- a/internal/service/repository/search_files_test.go +++ b/internal/service/repository/search_files_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) @@ -113,7 +113,7 @@ func TestSearchFilesByContentSuccessful(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - stream, err := client.SearchFilesByContent(ctx, &pb.SearchFilesByContentRequest{ + stream, err := client.SearchFilesByContent(ctx, &gitalypb.SearchFilesByContentRequest{ Repository: testRepo, Query: tc.query, Ref: []byte(tc.ref), @@ -144,7 +144,7 @@ func TestSearchFilesByContentFailure(t *testing.T) { testCases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository query string ref string code codes.Code @@ -173,7 +173,7 @@ func TestSearchFilesByContentFailure(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - stream, err := client.SearchFilesByContent(ctx, &pb.SearchFilesByContentRequest{ + stream, err := client.SearchFilesByContent(ctx, &gitalypb.SearchFilesByContentRequest{ Repository: tc.repo, Query: tc.query, Ref: []byte(tc.ref), @@ -221,7 +221,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) { } for _, tc := range testCases { - stream, err := client.SearchFilesByName(ctx, &pb.SearchFilesByNameRequest{ + stream, err := client.SearchFilesByName(ctx, &gitalypb.SearchFilesByNameRequest{ Repository: testRepo, Ref: tc.ref, Query: tc.query, @@ -249,7 +249,7 @@ func TestSearchFilesByNameFailure(t *testing.T) { testCases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository query string ref string code codes.Code @@ -278,7 +278,7 @@ func TestSearchFilesByNameFailure(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - stream, err := client.SearchFilesByName(ctx, &pb.SearchFilesByNameRequest{ + stream, err := client.SearchFilesByName(ctx, &gitalypb.SearchFilesByNameRequest{ Repository: tc.repo, Query: tc.query, Ref: []byte(tc.ref), @@ -292,7 +292,7 @@ func TestSearchFilesByNameFailure(t *testing.T) { } } -func consumeFilenameByContent(stream pb.RepositoryService_SearchFilesByContentClient) ([][]byte, error) { +func consumeFilenameByContent(stream gitalypb.RepositoryService_SearchFilesByContentClient) ([][]byte, error) { ret := make([][]byte, 0) for done := false; !done; { resp, err := stream.Recv() @@ -307,7 +307,7 @@ func consumeFilenameByContent(stream pb.RepositoryService_SearchFilesByContentCl return ret, nil } -func consumeFilenameByName(stream pb.RepositoryService_SearchFilesByNameClient) ([][]byte, error) { +func consumeFilenameByName(stream gitalypb.RepositoryService_SearchFilesByNameClient) ([][]byte, error) { ret := make([][]byte, 0) for done := false; !done; { resp, err := stream.Recv() diff --git a/internal/service/repository/server.go b/internal/service/repository/server.go index 13d859902..ef6749ba0 100644 --- a/internal/service/repository/server.go +++ b/internal/service/repository/server.go @@ -1,9 +1,8 @@ package repository import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) type server struct { @@ -11,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a gRPC repo server -func NewServer(rs *rubyserver.Server) pb.RepositoryServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.RepositoryServiceServer { return &server{rs} } diff --git a/internal/service/repository/size.go b/internal/service/repository/size.go index d9605ea30..24c272ff9 100644 --- a/internal/service/repository/size.go +++ b/internal/service/repository/size.go @@ -7,16 +7,15 @@ import ( "os/exec" "strconv" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" "golang.org/x/net/context" ) -func (s *server) RepositorySize(ctx context.Context, in *pb.RepositorySizeRequest) (*pb.RepositorySizeResponse, error) { +func (s *server) RepositorySize(ctx context.Context, in *gitalypb.RepositorySizeRequest) (*gitalypb.RepositorySizeResponse, error) { path, err := helper.GetPath(in.Repository) if err != nil { return nil, err @@ -54,6 +53,6 @@ func (s *server) RepositorySize(ctx context.Context, in *pb.RepositorySizeReques return repositorySizeResponse(size), nil } -func repositorySizeResponse(size int64) *pb.RepositorySizeResponse { - return &pb.RepositorySizeResponse{Size: size} +func repositorySizeResponse(size int64) *gitalypb.RepositorySizeResponse { + return &gitalypb.RepositorySizeResponse{Size: size} } diff --git a/internal/service/repository/size_test.go b/internal/service/repository/size_test.go index c8aff97fe..74d79b21c 100644 --- a/internal/service/repository/size_test.go +++ b/internal/service/repository/size_test.go @@ -5,11 +5,10 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -35,8 +34,8 @@ func TestSuccessfulRepositorySizeRequest(t *testing.T) { testhelper.MustRunCommand(t, nil, "sync") defer os.RemoveAll(repoCopyPath) - request := &pb.RepositorySizeRequest{ - Repository: &pb.Repository{ + request := &gitalypb.RepositorySizeRequest{ + Repository: &gitalypb.Repository{ StorageName: storageName, RelativePath: "fixed-size-repo.git", }, @@ -58,11 +57,11 @@ func TestFailedRepositorySizeRequest(t *testing.T) { client, conn := newRepositoryClient(t, serverSocketPath) defer conn.Close() - invalidRepo := &pb.Repository{StorageName: "fake", RelativePath: "path"} + invalidRepo := &gitalypb.Repository{StorageName: "fake", RelativePath: "path"} testCases := []struct { description string - repo *pb.Repository + repo *gitalypb.Repository }{ {repo: invalidRepo, description: "Invalid repo"}, } @@ -70,7 +69,7 @@ func TestFailedRepositorySizeRequest(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.description, func(t *testing.T) { - request := &pb.RepositorySizeRequest{ + request := &gitalypb.RepositorySizeRequest{ Repository: testCase.repo, } diff --git a/internal/service/repository/snapshot.go b/internal/service/repository/snapshot.go index 418a274a5..7197efee7 100644 --- a/internal/service/repository/snapshot.go +++ b/internal/service/repository/snapshot.go @@ -3,10 +3,10 @@ package repository import ( "regexp" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/archive" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -17,14 +17,14 @@ var objectFiles = []*regexp.Regexp{ regexp.MustCompile(`/pack/pack\-[[:xdigit:]]{40}\.(pack|idx)\z`), } -func (s *server) GetSnapshot(in *pb.GetSnapshotRequest, stream pb.RepositoryService_GetSnapshotServer) error { +func (s *server) GetSnapshot(in *gitalypb.GetSnapshotRequest, stream gitalypb.RepositoryService_GetSnapshotServer) error { path, err := helper.GetRepoPath(in.Repository) if err != nil { return err } writer := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.GetSnapshotResponse{Data: p}) + return stream.Send(&gitalypb.GetSnapshotResponse{Data: p}) }) // Building a raw archive may race with `git push`, but GitLab can enforce diff --git a/internal/service/repository/snapshot_test.go b/internal/service/repository/snapshot_test.go index 1d8c91ba7..16c41331d 100644 --- a/internal/service/repository/snapshot_test.go +++ b/internal/service/repository/snapshot_test.go @@ -11,15 +11,15 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "google.golang.org/grpc/codes" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/archive" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" ) -func getSnapshot(t *testing.T, req *pb.GetSnapshotRequest) ([]byte, error) { +func getSnapshot(t *testing.T, req *gitalypb.GetSnapshotRequest) ([]byte, error) { server, serverSocketPath := runRepoServer(t) defer server.Stop() @@ -65,7 +65,7 @@ func TestGetSnapshotSuccess(t *testing.T) { touch(t, filepath.Join(repoPath, "objects/pack/pack-%s.idx"), zeroes) touch(t, filepath.Join(repoPath, "objects/this-should-not-be-included")) - req := &pb.GetSnapshotRequest{Repository: testRepo} + req := &gitalypb.GetSnapshotRequest{Repository: testRepo} data, err := getSnapshot(t, req) require.NoError(t, err) @@ -89,7 +89,7 @@ func TestGetSnapshotFailsIfRepositoryMissing(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) cleanupFn() // Remove the repo - req := &pb.GetSnapshotRequest{Repository: testRepo} + req := &gitalypb.GetSnapshotRequest{Repository: testRepo} data, err := getSnapshot(t, req) testhelper.RequireGrpcError(t, err, codes.NotFound) require.Empty(t, data) @@ -104,7 +104,7 @@ func TestGetSnapshotFailsIfRepositoryContainsSymlink(t *testing.T) { require.NoError(t, os.Remove(packedRefsFile)) require.NoError(t, os.Symlink("HEAD", packedRefsFile)) - req := &pb.GetSnapshotRequest{Repository: testRepo} + req := &gitalypb.GetSnapshotRequest{Repository: testRepo} data, err := getSnapshot(t, req) testhelper.RequireGrpcError(t, err, codes.Internal) require.Contains(t, err.Error(), "Building snapshot failed") diff --git a/internal/service/repository/squash_in_progress.go b/internal/service/repository/squash_in_progress.go index 2e284faa2..71f62fdd7 100644 --- a/internal/service/repository/squash_in_progress.go +++ b/internal/service/repository/squash_in_progress.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "golang.org/x/net/context" @@ -16,7 +16,7 @@ const ( squashWorktreePrefix = "squash" ) -func (s *server) IsSquashInProgress(ctx context.Context, req *pb.IsSquashInProgressRequest) (*pb.IsSquashInProgressResponse, error) { +func (s *server) IsSquashInProgress(ctx context.Context, req *gitalypb.IsSquashInProgressRequest) (*gitalypb.IsSquashInProgressResponse, error) { if err := validateIsSquashInProgressRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "IsSquashInProgress: %v", err) } @@ -30,10 +30,10 @@ func (s *server) IsSquashInProgress(ctx context.Context, req *pb.IsSquashInProgr if err != nil { return nil, err } - return &pb.IsSquashInProgressResponse{InProgress: inProg}, nil + return &gitalypb.IsSquashInProgressResponse{InProgress: inProg}, nil } -func validateIsSquashInProgressRequest(req *pb.IsSquashInProgressRequest) error { +func validateIsSquashInProgressRequest(req *gitalypb.IsSquashInProgressRequest) error { if req.GetRepository() == nil { return fmt.Errorf("empty Repository") } diff --git a/internal/service/repository/squash_in_progress_test.go b/internal/service/repository/squash_in_progress_test.go index 97b8df802..dc8c36194 100644 --- a/internal/service/repository/squash_in_progress_test.go +++ b/internal/service/repository/squash_in_progress_test.go @@ -4,10 +4,9 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -29,12 +28,12 @@ func TestSuccessfulIsSquashInProgressRequest(t *testing.T) { testCases := []struct { desc string - request *pb.IsSquashInProgressRequest + request *gitalypb.IsSquashInProgressRequest inProgress bool }{ { desc: "Squash in progress", - request: &pb.IsSquashInProgressRequest{ + request: &gitalypb.IsSquashInProgressRequest{ Repository: testRepo1, SquashId: "1", }, @@ -42,7 +41,7 @@ func TestSuccessfulIsSquashInProgressRequest(t *testing.T) { }, { desc: "no Squash in progress", - request: &pb.IsSquashInProgressRequest{ + request: &gitalypb.IsSquashInProgressRequest{ Repository: testRepo2, SquashId: "2", }, @@ -72,17 +71,17 @@ func TestFailedIsSquashInProgressRequestDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.IsSquashInProgressRequest + request *gitalypb.IsSquashInProgressRequest code codes.Code }{ { desc: "empty repository", - request: &pb.IsSquashInProgressRequest{SquashId: "1"}, + request: &gitalypb.IsSquashInProgressRequest{SquashId: "1"}, code: codes.InvalidArgument, }, { desc: "empty Squash id", - request: &pb.IsSquashInProgressRequest{Repository: &pb.Repository{}}, + request: &gitalypb.IsSquashInProgressRequest{Repository: &gitalypb.Repository{}}, code: codes.InvalidArgument, }, } diff --git a/internal/service/repository/testhelper_test.go b/internal/service/repository/testhelper_test.go index 81fa27c7d..89a64530c 100644 --- a/internal/service/repository/testhelper_test.go +++ b/internal/service/repository/testhelper_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitalyauth "gitlab.com/gitlab-org/gitaly/auth" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" @@ -28,7 +28,7 @@ var ( RubyServer *rubyserver.Server ) -func newRepositoryClient(t *testing.T, serverSocketPath string) (pb.RepositoryServiceClient, *grpc.ClientConn) { +func newRepositoryClient(t *testing.T, serverSocketPath string) (gitalypb.RepositoryServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -41,7 +41,7 @@ func newRepositoryClient(t *testing.T, serverSocketPath string) (pb.RepositorySe t.Fatal(err) } - return pb.NewRepositoryServiceClient(conn), conn + return gitalypb.NewRepositoryServiceClient(conn), conn } var NewRepositoryClient = newRepositoryClient @@ -58,7 +58,7 @@ func runRepoServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterRepositoryServiceServer(server, NewServer(RubyServer)) + gitalypb.RegisterRepositoryServiceServer(server, NewServer(RubyServer)) reflection.Register(server) go server.Serve(listener) diff --git a/internal/service/repository/util.go b/internal/service/repository/util.go index ad7d36146..248163bda 100644 --- a/internal/service/repository/util.go +++ b/internal/service/repository/util.go @@ -3,14 +3,13 @@ package repository import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" ) -func removeOriginInRepo(ctx context.Context, repository *pb.Repository) error { +func removeOriginInRepo(ctx context.Context, repository *gitalypb.Repository) error { cmd, err := git.Command(ctx, repository, "remote", "remove", "origin") if err != nil { diff --git a/internal/service/repository/write_config.go b/internal/service/repository/write_config.go index 9ed61e86c..0e89e0949 100644 --- a/internal/service/repository/write_config.go +++ b/internal/service/repository/write_config.go @@ -3,11 +3,11 @@ package repository import ( "golang.org/x/net/context" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" ) -func (s *server) WriteConfig(ctx context.Context, req *pb.WriteConfigRequest) (*pb.WriteConfigResponse, error) { +func (s *server) WriteConfig(ctx context.Context, req *gitalypb.WriteConfigRequest) (*gitalypb.WriteConfigResponse, error) { client, err := s.RepositoryServiceClient(ctx) if err != nil { return nil, err diff --git a/internal/service/repository/write_config_test.go b/internal/service/repository/write_config_test.go index cbd4a3ee9..135025b50 100644 --- a/internal/service/repository/write_config_test.go +++ b/internal/service/repository/write_config_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) @@ -22,7 +22,7 @@ func TestWriteConfigSuccessful(t *testing.T) { testcases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository path string setPath string }{ @@ -44,7 +44,7 @@ func TestWriteConfigSuccessful(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - c, err := client.WriteConfig(ctx, &pb.WriteConfigRequest{Repository: tc.repo, FullPath: tc.path}) + c, err := client.WriteConfig(ctx, &gitalypb.WriteConfigRequest{Repository: tc.repo, FullPath: tc.path}) require.NoError(t, err) require.NotNil(t, c) require.Empty(t, string(c.GetError())) @@ -64,12 +64,12 @@ func TestWriteConfigFailure(t *testing.T) { testcases := []struct { desc string - repo *pb.Repository + repo *gitalypb.Repository path string }{ { desc: "invalid repo", - repo: &pb.Repository{StorageName: testhelper.DefaultStorageName, RelativePath: "non-existing.git"}, + repo: &gitalypb.Repository{StorageName: testhelper.DefaultStorageName, RelativePath: "non-existing.git"}, path: "non-existing.git", }, } @@ -79,7 +79,7 @@ func TestWriteConfigFailure(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - c, err := client.WriteConfig(ctx, &pb.WriteConfigRequest{Repository: tc.repo, FullPath: tc.path}) + c, err := client.WriteConfig(ctx, &gitalypb.WriteConfigRequest{Repository: tc.repo, FullPath: tc.path}) testhelper.RequireGrpcError(t, err, codes.NotFound) require.Nil(t, c) require.Empty(t, c.GetError()) diff --git a/internal/service/repository/write_ref.go b/internal/service/repository/write_ref.go index 01b98ac42..afc3c477d 100644 --- a/internal/service/repository/write_ref.go +++ b/internal/service/repository/write_ref.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "google.golang.org/grpc/codes" @@ -13,7 +13,7 @@ import ( "golang.org/x/net/context" ) -func (s *server) WriteRef(ctx context.Context, req *pb.WriteRefRequest) (*pb.WriteRefResponse, error) { +func (s *server) WriteRef(ctx context.Context, req *gitalypb.WriteRefRequest) (*gitalypb.WriteRefResponse, error) { if err := validateWriteRefRequest(req); err != nil { return nil, status.Errorf(codes.InvalidArgument, "WriteRef: %v", err) } @@ -31,7 +31,7 @@ func (s *server) WriteRef(ctx context.Context, req *pb.WriteRefRequest) (*pb.Wri return client.WriteRef(clientCtx, req) } -func validateWriteRefRequest(req *pb.WriteRefRequest) error { +func validateWriteRefRequest(req *gitalypb.WriteRefRequest) error { if err := git.ValidateRevision(req.Ref); err != nil { return fmt.Errorf("Validate Ref: %v", err) } diff --git a/internal/service/repository/write_ref_test.go b/internal/service/repository/write_ref_test.go index 3557631da..b8b8601a5 100644 --- a/internal/service/repository/write_ref_test.go +++ b/internal/service/repository/write_ref_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc/codes" ) @@ -23,11 +23,11 @@ func TestWriteRefSuccessful(t *testing.T) { testCases := []struct { desc string - req *pb.WriteRefRequest + req *gitalypb.WriteRefRequest }{ { desc: "rugged update refs/heads/master", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/heads/master"), Revision: []byte("4a24d82dbca5c11c61556f3b35ca472b7463187e"), @@ -36,7 +36,7 @@ func TestWriteRefSuccessful(t *testing.T) { }, { desc: "rugged update refs/keep-around/4a24d82dbca5c11c61556f3b35ca472b7463187e", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/keep-around/4a24d82dbca5c11c61556f3b35ca472b7463187e"), Revision: []byte("4a24d82dbca5c11c61556f3b35ca472b7463187e"), @@ -45,7 +45,7 @@ func TestWriteRefSuccessful(t *testing.T) { }, { desc: "rugged update HEAD to refs/heads/master", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("HEAD"), Revision: []byte("refs/heads/master"), @@ -54,7 +54,7 @@ func TestWriteRefSuccessful(t *testing.T) { }, { desc: "shell update refs/heads/master", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/heads/master"), Revision: []byte("b83d6e391c22777fca1ed3012fce84f633d7fed0"), @@ -63,7 +63,7 @@ func TestWriteRefSuccessful(t *testing.T) { }, { desc: "shell update refs/heads/master w/ validation", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/heads/master"), Revision: []byte("498214de67004b1da3d820901307bed2a68a8ef6"), @@ -110,25 +110,25 @@ func TestWriteRefValidationError(t *testing.T) { testCases := []struct { desc string - req *pb.WriteRefRequest + req *gitalypb.WriteRefRequest }{ { desc: "empty revision", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/heads/master"), }, }, { desc: "empty ref name", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Revision: []byte("498214de67004b1da3d820901307bed2a68a8ef6"), }, }, { desc: "non-prefixed ref name for shell", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("master"), Revision: []byte("498214de67004b1da3d820901307bed2a68a8ef6"), @@ -137,7 +137,7 @@ func TestWriteRefValidationError(t *testing.T) { }, { desc: "revision contains \\x00", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/heads/master"), Revision: []byte("012301230123\x001243"), @@ -145,7 +145,7 @@ func TestWriteRefValidationError(t *testing.T) { }, { desc: "ref contains \\x00", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/head\x00s/master\x00"), Revision: []byte("0123012301231243"), @@ -153,7 +153,7 @@ func TestWriteRefValidationError(t *testing.T) { }, { desc: "ref contains whitespace", - req: &pb.WriteRefRequest{ + req: &gitalypb.WriteRefRequest{ Repository: testRepo, Ref: []byte("refs/heads /master"), Revision: []byte("0123012301231243"), diff --git a/internal/service/server/info.go b/internal/service/server/info.go index 6881a9153..b46ad12d1 100644 --- a/internal/service/server/info.go +++ b/internal/service/server/info.go @@ -5,7 +5,7 @@ import ( "os" "path" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/version" @@ -13,13 +13,13 @@ import ( "golang.org/x/net/context" ) -func (s *server) ServerInfo(ctx context.Context, in *pb.ServerInfoRequest) (*pb.ServerInfoResponse, error) { +func (s *server) ServerInfo(ctx context.Context, in *gitalypb.ServerInfoRequest) (*gitalypb.ServerInfoResponse, error) { gitVersion, err := git.Version() - var storageStatuses []*pb.ServerInfoResponse_StorageStatus + var storageStatuses []*gitalypb.ServerInfoResponse_StorageStatus for _, shard := range config.Config.Storages { readable, writeable := shardCheck(shard.Path) - storageStatuses = append(storageStatuses, &pb.ServerInfoResponse_StorageStatus{ + storageStatuses = append(storageStatuses, &gitalypb.ServerInfoResponse_StorageStatus{ StorageName: shard.Name, Readable: readable, Writeable: writeable, @@ -27,7 +27,7 @@ func (s *server) ServerInfo(ctx context.Context, in *pb.ServerInfoRequest) (*pb. } - return &pb.ServerInfoResponse{ + return &gitalypb.ServerInfoResponse{ ServerVersion: version.GetVersion(), GitVersion: gitVersion, StorageStatuses: storageStatuses, diff --git a/internal/service/server/info_test.go b/internal/service/server/info_test.go index 1872df6f6..4e1f016a5 100644 --- a/internal/service/server/info_test.go +++ b/internal/service/server/info_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitalyauth "gitlab.com/gitlab-org/gitaly/auth" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/git" @@ -38,7 +38,7 @@ func TestGitalyServerInfo(t *testing.T) { }(config.Config.Storages) config.Config.Storages = testStorages - c, err := client.ServerInfo(ctx, &pb.ServerInfoRequest{}) + c, err := client.ServerInfo(ctx, &gitalypb.ServerInfoRequest{}) require.NoError(t, err) require.Equal(t, version.GetVersion(), c.GetServerVersion()) @@ -67,7 +67,7 @@ func runServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterServerServiceServer(server, NewServer()) + gitalypb.RegisterServerServiceServer(server, NewServer()) reflection.Register(server) go server.Serve(listener) @@ -75,7 +75,7 @@ func runServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func newServerClient(t *testing.T, serverSocketPath string) (pb.ServerServiceClient, *grpc.ClientConn) { +func newServerClient(t *testing.T, serverSocketPath string) (gitalypb.ServerServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -88,5 +88,5 @@ func newServerClient(t *testing.T, serverSocketPath string) (pb.ServerServiceCli t.Fatal(err) } - return pb.NewServerServiceClient(conn), conn + return gitalypb.NewServerServiceClient(conn), conn } diff --git a/internal/service/server/server.go b/internal/service/server/server.go index 5314ada3b..389e9afb9 100644 --- a/internal/service/server/server.go +++ b/internal/service/server/server.go @@ -1,12 +1,10 @@ package server -import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" -) +import "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" type server struct{} // NewServer creates a new instance of a grpc ServerServiceServer -func NewServer() pb.ServerServiceServer { +func NewServer() gitalypb.ServerServiceServer { return &server{} } diff --git a/internal/service/smarthttp/inforefs.go b/internal/service/smarthttp/inforefs.go index 76defd99f..bd7418647 100644 --- a/internal/service/smarthttp/inforefs.go +++ b/internal/service/smarthttp/inforefs.go @@ -7,7 +7,7 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/pktline" "gitlab.com/gitlab-org/gitaly/internal/helper" @@ -17,21 +17,21 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) InfoRefsUploadPack(in *pb.InfoRefsRequest, stream pb.SmartHTTPService_InfoRefsUploadPackServer) error { +func (s *server) InfoRefsUploadPack(in *gitalypb.InfoRefsRequest, stream gitalypb.SmartHTTPService_InfoRefsUploadPackServer) error { w := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.InfoRefsResponse{Data: p}) + return stream.Send(&gitalypb.InfoRefsResponse{Data: p}) }) return handleInfoRefs(stream.Context(), "upload-pack", in, w) } -func (s *server) InfoRefsReceivePack(in *pb.InfoRefsRequest, stream pb.SmartHTTPService_InfoRefsReceivePackServer) error { +func (s *server) InfoRefsReceivePack(in *gitalypb.InfoRefsRequest, stream gitalypb.SmartHTTPService_InfoRefsReceivePackServer) error { w := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.InfoRefsResponse{Data: p}) + return stream.Send(&gitalypb.InfoRefsResponse{Data: p}) }) return handleInfoRefs(stream.Context(), "receive-pack", in, w) } -func handleInfoRefs(ctx context.Context, service string, req *pb.InfoRefsRequest, w io.Writer) error { +func handleInfoRefs(ctx context.Context, service string, req *gitalypb.InfoRefsRequest, w io.Writer) error { grpc_logrus.Extract(ctx).WithFields(log.Fields{ "service": service, }).Debug("handleInfoRefs") diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go index 24ca0760a..51570d4e7 100644 --- a/internal/service/smarthttp/inforefs_test.go +++ b/internal/service/smarthttp/inforefs_test.go @@ -5,11 +5,10 @@ import ( "strings" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/streamio" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "golang.org/x/net/context" "google.golang.org/grpc/codes" @@ -22,7 +21,7 @@ func TestSuccessfulInfoRefsUploadPack(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.InfoRefsRequest{Repository: testRepo} + rpcRequest := &gitalypb.InfoRefsRequest{Repository: testRepo} response, err := makeInfoRefsUploadPackRequest(t, serverSocketPath, rpcRequest) require.NoError(t, err) @@ -41,7 +40,7 @@ func TestSuccessfulInfoRefsUploadPackWithGitConfigOptions(t *testing.T) { // transfer.hideRefs=refs will hide every ref that info-refs would normally // output, allowing us to test that the custom configuration is respected - rpcRequest := &pb.InfoRefsRequest{ + rpcRequest := &gitalypb.InfoRefsRequest{ Repository: testRepo, GitConfigOptions: []string{"transfer.hideRefs=refs"}, } @@ -51,7 +50,7 @@ func TestSuccessfulInfoRefsUploadPackWithGitConfigOptions(t *testing.T) { assertGitRefAdvertisement(t, "InfoRefsUploadPack", string(response), "001e# service=git-upload-pack", "0000", []string{}) } -func makeInfoRefsUploadPackRequest(t *testing.T, serverSocketPath string, rpcRequest *pb.InfoRefsRequest) ([]byte, error) { +func makeInfoRefsUploadPackRequest(t *testing.T, serverSocketPath string, rpcRequest *gitalypb.InfoRefsRequest) ([]byte, error) { client, conn := newSmartHTTPClient(t, serverSocketPath) defer conn.Close() @@ -78,7 +77,7 @@ func TestSuccessfulInfoRefsReceivePack(t *testing.T) { testRepo, _, cleanupFn := testhelper.NewTestRepo(t) defer cleanupFn() - rpcRequest := &pb.InfoRefsRequest{Repository: testRepo} + rpcRequest := &gitalypb.InfoRefsRequest{Repository: testRepo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -107,8 +106,8 @@ func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) { client, conn := newSmartHTTPClient(t, serverSocketPath) defer conn.Close() - repo := &pb.Repository{StorageName: "default", RelativePath: "testdata/data/another_repo"} - rpcRequest := &pb.InfoRefsRequest{Repository: repo} + repo := &gitalypb.Repository{StorageName: "default", RelativePath: "testdata/data/another_repo"} + rpcRequest := &gitalypb.InfoRefsRequest{Repository: repo} ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -129,7 +128,7 @@ func TestFailureRepoNotSetInfoRefsReceivePack(t *testing.T) { client, conn := newSmartHTTPClient(t, serverSocketPath) defer conn.Close() - rpcRequest := &pb.InfoRefsRequest{} + rpcRequest := &gitalypb.InfoRefsRequest{} ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/internal/service/smarthttp/receive_pack.go b/internal/service/smarthttp/receive_pack.go index e342f051e..c48800676 100644 --- a/internal/service/smarthttp/receive_pack.go +++ b/internal/service/smarthttp/receive_pack.go @@ -6,17 +6,17 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) PostReceivePack(stream pb.SmartHTTPService_PostReceivePackServer) error { +func (s *server) PostReceivePack(stream gitalypb.SmartHTTPService_PostReceivePackServer) error { req, err := stream.Recv() // First request contains only Repository and GlId if err != nil { return err @@ -38,7 +38,7 @@ func (s *server) PostReceivePack(stream pb.SmartHTTPService_PostReceivePackServe return resp.GetData(), err }) stdout := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.PostReceivePackResponse{Data: p}) + return stream.Send(&gitalypb.PostReceivePackResponse{Data: p}) }) env := []string{ fmt.Sprintf("GL_ID=%s", req.GlId), @@ -70,7 +70,7 @@ func (s *server) PostReceivePack(stream pb.SmartHTTPService_PostReceivePackServe return nil } -func validateReceivePackRequest(req *pb.PostReceivePackRequest) error { +func validateReceivePackRequest(req *gitalypb.PostReceivePackRequest) error { if req.GlId == "" { return status.Errorf(codes.InvalidArgument, "PostReceivePack: empty GlId") } diff --git a/internal/service/smarthttp/receive_pack_test.go b/internal/service/smarthttp/receive_pack_test.go index 91b8799ac..3da59252c 100644 --- a/internal/service/smarthttp/receive_pack_test.go +++ b/internal/service/smarthttp/receive_pack_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/streamio" "github.com/stretchr/testify/require" @@ -38,7 +38,7 @@ func TestSuccessfulReceivePackRequest(t *testing.T) { require.NoError(t, err) push := newTestPush(t, nil) - firstRequest := &pb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123"} + firstRequest := &gitalypb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123"} response := doPush(t, stream, firstRequest, push.body) expectedResponse := "0030\x01000eunpack ok\n0019ok refs/heads/master\n00000000" @@ -65,7 +65,7 @@ func TestSuccessfulReceivePackRequestWithGitOpts(t *testing.T) { require.NoError(t, err) push := newTestPush(t, nil) - firstRequest := &pb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123", GitConfigOptions: []string{"receive.MaxInputSize=10000"}} + firstRequest := &gitalypb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123", GitConfigOptions: []string{"receive.MaxInputSize=10000"}} response := doPush(t, stream, firstRequest, push.body) expectedResponse := "0030\x01000eunpack ok\n0019ok refs/heads/master\n00000000" @@ -97,18 +97,18 @@ func TestFailedReceivePackRequestWithGitOpts(t *testing.T) { require.NoError(t, err) push := newTestPush(t, nil) - firstRequest := &pb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123", GitConfigOptions: []string{"receive.MaxInputSize=1"}} + firstRequest := &gitalypb.PostReceivePackRequest{Repository: repo, GlId: "user-123", GlRepository: "project-123", GitConfigOptions: []string{"receive.MaxInputSize=1"}} response := doPush(t, stream, firstRequest, push.body) expectedResponse := "002e\x02fatal: pack exceeds maximum allowed size\n0059\x010028unpack unpack-objects abnormal exit\n0028ng refs/heads/master unpacker error\n00000000" require.Equal(t, expectedResponse, string(response), "Expected response to be %q, got %q", expectedResponse, response) } -func doPush(t *testing.T, stream pb.SmartHTTPService_PostReceivePackClient, firstRequest *pb.PostReceivePackRequest, body io.Reader) []byte { +func doPush(t *testing.T, stream gitalypb.SmartHTTPService_PostReceivePackClient, firstRequest *gitalypb.PostReceivePackRequest, body io.Reader) []byte { require.NoError(t, stream.Send(firstRequest)) sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.PostReceivePackRequest{Data: p}) + return stream.Send(&gitalypb.PostReceivePackRequest{Data: p}) }) _, err := io.Copy(sw, body) require.NoError(t, err) @@ -193,11 +193,11 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) { client, conn := newSmartHTTPClient(t, serverSocketPath) defer conn.Close() - rpcRequests := []pb.PostReceivePackRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}, GlId: "user-123"}, // Repository doesn't exist + rpcRequests := []gitalypb.PostReceivePackRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}, GlId: "user-123"}, // Repository doesn't exist {Repository: nil, GlId: "user-123"}, // Repository is nil - {Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, GlId: ""}, // Empty GlId - {Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, GlId: "user-123", Data: []byte("Fail")}, // Data exists on first request + {Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, GlId: ""}, // Empty GlId + {Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, GlId: "user-123", Data: []byte("Fail")}, // Data exists on first request } for _, rpcRequest := range rpcRequests { @@ -216,7 +216,7 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) { } } -func drainPostReceivePackResponse(stream pb.SmartHTTP_PostReceivePackClient) error { +func drainPostReceivePackResponse(stream gitalypb.SmartHTTP_PostReceivePackClient) error { var err error for err == nil { _, err = stream.Recv() diff --git a/internal/service/smarthttp/server.go b/internal/service/smarthttp/server.go index 581cb2151..ed7567d75 100644 --- a/internal/service/smarthttp/server.go +++ b/internal/service/smarthttp/server.go @@ -1,10 +1,10 @@ package smarthttp -import pb "gitlab.com/gitlab-org/gitaly-proto/go" +import "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" type server struct{} // NewServer creates a new instance of a grpc SmartHTTPServer -func NewServer() pb.SmartHTTPServiceServer { +func NewServer() gitalypb.SmartHTTPServiceServer { return &server{} } diff --git a/internal/service/smarthttp/testhelper_test.go b/internal/service/smarthttp/testhelper_test.go index 5a8cb3dbf..70f0dd08d 100644 --- a/internal/service/smarthttp/testhelper_test.go +++ b/internal/service/smarthttp/testhelper_test.go @@ -5,10 +5,9 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) @@ -26,7 +25,7 @@ func runSmartHTTPServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterSmartHTTPServiceServer(server, NewServer()) + gitalypb.RegisterSmartHTTPServiceServer(server, NewServer()) reflection.Register(server) go server.Serve(listener) @@ -34,7 +33,7 @@ func runSmartHTTPServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func newSmartHTTPClient(t *testing.T, serverSocketPath string) (pb.SmartHTTPServiceClient, *grpc.ClientConn) { +func newSmartHTTPClient(t *testing.T, serverSocketPath string) (gitalypb.SmartHTTPServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -46,5 +45,5 @@ func newSmartHTTPClient(t *testing.T, serverSocketPath string) (pb.SmartHTTPServ t.Fatal(err) } - return pb.NewSmartHTTPServiceClient(conn), conn + return gitalypb.NewSmartHTTPServiceClient(conn), conn } diff --git a/internal/service/smarthttp/upload_pack.go b/internal/service/smarthttp/upload_pack.go index 9d80b2fa9..35b8253b5 100644 --- a/internal/service/smarthttp/upload_pack.go +++ b/internal/service/smarthttp/upload_pack.go @@ -5,10 +5,10 @@ import ( "os/exec" "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/streamio" "github.com/prometheus/client_golang/prometheus" @@ -29,7 +29,7 @@ func init() { prometheus.MustRegister(deepenCount) } -func (s *server) PostUploadPack(stream pb.SmartHTTPService_PostUploadPackServer) error { +func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackServer) error { grpc_logrus.Extract(stream.Context()).Debug("PostUploadPack") req, err := stream.Recv() // First request contains Repository only @@ -53,7 +53,7 @@ func (s *server) PostUploadPack(stream pb.SmartHTTPService_PostUploadPackServer) }() stdout := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.PostUploadPackResponse{Data: p}) + return stream.Send(&gitalypb.PostUploadPackResponse{Data: p}) }) repoPath, err := helper.GetRepoPath(req.Repository) if err != nil { @@ -89,7 +89,7 @@ func (s *server) PostUploadPack(stream pb.SmartHTTPService_PostUploadPackServer) return nil } -func validateUploadPackRequest(req *pb.PostUploadPackRequest) error { +func validateUploadPackRequest(req *gitalypb.PostUploadPackRequest) error { if req.Data != nil { return status.Errorf(codes.InvalidArgument, "PostUploadPack: non-empty Data") } diff --git a/internal/service/smarthttp/upload_pack_test.go b/internal/service/smarthttp/upload_pack_test.go index 502c231d6..27a4274d6 100644 --- a/internal/service/smarthttp/upload_pack_test.go +++ b/internal/service/smarthttp/upload_pack_test.go @@ -10,11 +10,11 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git/pktline" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/streamio" "github.com/stretchr/testify/assert" @@ -70,8 +70,8 @@ func TestSuccessfulUploadPackRequest(t *testing.T) { pktline.WriteString(requestBuffer, fmt.Sprintf("have %s\n", oldHead)) pktline.WriteFlush(requestBuffer) - req := &pb.PostUploadPackRequest{ - Repository: &pb.Repository{ + req := &gitalypb.PostUploadPackRequest{ + Repository: &gitalypb.Repository{ StorageName: "default", RelativePath: path.Join(remoteRepoRelativePath, ".git"), }, @@ -125,8 +125,8 @@ func TestUploadPackRequestWithGitConfigOptions(t *testing.T) { pktline.WriteString(tee, fmt.Sprintf("have %s\n", have)) pktline.WriteFlush(tee) - rpcRequest := &pb.PostUploadPackRequest{ - Repository: &pb.Repository{ + rpcRequest := &gitalypb.PostUploadPackRequest{ + Repository: &gitalypb.Repository{ StorageName: "default", RelativePath: ourRepoRelativePath, }, @@ -161,7 +161,7 @@ func TestSuccessfulUploadPackDeepenRequest(t *testing.T) { pktline.WriteString(requestBody, "deepen 1") pktline.WriteFlush(requestBody) - rpcRequest := &pb.PostUploadPackRequest{Repository: testRepo} + rpcRequest := &gitalypb.PostUploadPackRequest{Repository: testRepo} response, err := makePostUploadPackRequest(t, serverSocketPath, rpcRequest, requestBody) // This assertion is the main reason this test exists. @@ -173,10 +173,10 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) { server, serverSocketPath := runSmartHTTPServer(t) defer server.Stop() - rpcRequests := []pb.PostUploadPackRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist + rpcRequests := []gitalypb.PostUploadPackRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist {Repository: nil}, // Repository is nil - {Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, Data: []byte("Fail")}, // Data exists on first request + {Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, Data: []byte("Fail")}, // Data exists on first request } for _, rpcRequest := range rpcRequests { @@ -187,7 +187,7 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) { } } -func makePostUploadPackRequest(t *testing.T, serverSocketPath string, in *pb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { +func makePostUploadPackRequest(t *testing.T, serverSocketPath string, in *gitalypb.PostUploadPackRequest, body io.Reader) (*bytes.Buffer, error) { client, conn := newSmartHTTPClient(t, serverSocketPath) defer conn.Close() ctx, cancel := context.WithCancel(context.Background()) @@ -199,7 +199,7 @@ func makePostUploadPackRequest(t *testing.T, serverSocketPath string, in *pb.Pos if body != nil { sw := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.PostUploadPackRequest{Data: p}) + return stream.Send(&gitalypb.PostUploadPackRequest{Data: p}) }) _, err = io.Copy(sw, body) diff --git a/internal/service/ssh/receive_pack.go b/internal/service/ssh/receive_pack.go index e66ec4e74..e5792f8a1 100644 --- a/internal/service/ssh/receive_pack.go +++ b/internal/service/ssh/receive_pack.go @@ -6,17 +6,17 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) SSHReceivePack(stream pb.SSHService_SSHReceivePackServer) error { +func (s *server) SSHReceivePack(stream gitalypb.SSHService_SSHReceivePackServer) error { req, err := stream.Recv() // First request contains only Repository, GlId, and GlUsername if err != nil { return err @@ -38,10 +38,10 @@ func (s *server) SSHReceivePack(stream pb.SSHService_SSHReceivePackServer) error return request.GetStdin(), err }) stdout := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHReceivePackResponse{Stdout: p}) + return stream.Send(&gitalypb.SSHReceivePackResponse{Stdout: p}) }) stderr := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHReceivePackResponse{Stderr: p}) + return stream.Send(&gitalypb.SSHReceivePackResponse{Stderr: p}) }) env := []string{ fmt.Sprintf("GL_ID=%s", req.GlId), @@ -69,7 +69,7 @@ func (s *server) SSHReceivePack(stream pb.SSHService_SSHReceivePackServer) error if status, ok := command.ExitStatus(err); ok { return helper.DecorateError( codes.Internal, - stream.Send(&pb.SSHReceivePackResponse{ExitStatus: &pb.ExitStatus{Value: int32(status)}}), + stream.Send(&gitalypb.SSHReceivePackResponse{ExitStatus: &gitalypb.ExitStatus{Value: int32(status)}}), ) } return status.Errorf(codes.Unavailable, "SSHReceivePack: %v", err) @@ -78,7 +78,7 @@ func (s *server) SSHReceivePack(stream pb.SSHService_SSHReceivePackServer) error return nil } -func validateFirstReceivePackRequest(req *pb.SSHReceivePackRequest) error { +func validateFirstReceivePackRequest(req *gitalypb.SSHReceivePackRequest) error { if req.GlId == "" { return status.Errorf(codes.InvalidArgument, "SSHReceivePack: empty GlId") } diff --git a/internal/service/ssh/receive_pack_test.go b/internal/service/ssh/receive_pack_test.go index c3e1d24ee..74bf9ebb7 100644 --- a/internal/service/ssh/receive_pack_test.go +++ b/internal/service/ssh/receive_pack_test.go @@ -14,11 +14,10 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" ) @@ -32,27 +31,27 @@ func TestFailedReceivePackRequestDueToValidationError(t *testing.T) { tests := []struct { Desc string - Req *pb.SSHReceivePackRequest + Req *gitalypb.SSHReceivePackRequest Code codes.Code }{ { Desc: "Repository.RelativePath is empty", - Req: &pb.SSHReceivePackRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: ""}, GlId: "user-123"}, + Req: &gitalypb.SSHReceivePackRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: ""}, GlId: "user-123"}, Code: codes.InvalidArgument, }, { Desc: "Repository is nil", - Req: &pb.SSHReceivePackRequest{Repository: nil, GlId: "user-123"}, + Req: &gitalypb.SSHReceivePackRequest{Repository: nil, GlId: "user-123"}, Code: codes.InvalidArgument, }, { Desc: "Empty GlId", - Req: &pb.SSHReceivePackRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: testRepo.GetRelativePath()}, GlId: ""}, + Req: &gitalypb.SSHReceivePackRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: testRepo.GetRelativePath()}, GlId: ""}, Code: codes.InvalidArgument, }, { Desc: "Data exists on first request", - Req: &pb.SSHReceivePackRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: testRepo.GetRelativePath()}, GlId: "user-123", Stdin: []byte("Fail")}, + Req: &gitalypb.SSHReceivePackRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: testRepo.GetRelativePath()}, GlId: "user-123", Stdin: []byte("Fail")}, Code: codes.InvalidArgument, }, } @@ -146,9 +145,9 @@ func testCloneAndPush(t *testing.T, serverSocketPath string, params pushParams) makeCommit(t, localRepoPath) - pbTempRepo := &pb.Repository{StorageName: params.storageName, RelativePath: tempRepo} + pbTempRepo := &gitalypb.Repository{StorageName: params.storageName, RelativePath: tempRepo} pbMarshaler := &jsonpb.Marshaler{} - payload, err := pbMarshaler.MarshalToString(&pb.SSHReceivePackRequest{ + payload, err := pbMarshaler.MarshalToString(&gitalypb.SSHReceivePackRequest{ Repository: pbTempRepo, GlRepository: pbTempRepo.GetRelativePath(), GlId: params.glID, @@ -205,7 +204,7 @@ func makeCommit(t *testing.T, localRepoPath string) ([]byte, []byte, bool) { return oldHead, newHead, t.Failed() } -func drainPostReceivePackResponse(stream pb.SSH_SSHReceivePackClient) error { +func drainPostReceivePackResponse(stream gitalypb.SSH_SSHReceivePackClient) error { var err error for err == nil { _, err = stream.Recv() diff --git a/internal/service/ssh/server.go b/internal/service/ssh/server.go index c423228a7..4c75c0d8c 100644 --- a/internal/service/ssh/server.go +++ b/internal/service/ssh/server.go @@ -1,10 +1,10 @@ package ssh -import pb "gitlab.com/gitlab-org/gitaly-proto/go" +import "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" type server struct{} // NewServer creates a new instance of a grpc SSHServer -func NewServer() pb.SSHServiceServer { +func NewServer() gitalypb.SSHServiceServer { return &server{} } diff --git a/internal/service/ssh/testhelper_test.go b/internal/service/ssh/testhelper_test.go index dcb2547ea..94d7f489b 100644 --- a/internal/service/ssh/testhelper_test.go +++ b/internal/service/ssh/testhelper_test.go @@ -9,8 +9,7 @@ import ( log "github.com/sirupsen/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "google.golang.org/grpc" "google.golang.org/grpc/reflection" @@ -22,7 +21,7 @@ const ( ) var ( - testRepo *pb.Repository + testRepo *gitalypb.Repository gitalySSHPath string cwd string ) @@ -69,7 +68,7 @@ func runSSHServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterSSHServiceServer(server, NewServer()) + gitalypb.RegisterSSHServiceServer(server, NewServer()) reflection.Register(server) go server.Serve(listener) @@ -77,7 +76,7 @@ func runSSHServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func newSSHClient(t *testing.T, serverSocketPath string) (pb.SSHServiceClient, *grpc.ClientConn) { +func newSSHClient(t *testing.T, serverSocketPath string) (gitalypb.SSHServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -89,5 +88,5 @@ func newSSHClient(t *testing.T, serverSocketPath string) (pb.SSHServiceClient, * t.Fatal(err) } - return pb.NewSSHServiceClient(conn), conn + return gitalypb.NewSSHServiceClient(conn), conn } diff --git a/internal/service/ssh/upload_archive.go b/internal/service/ssh/upload_archive.go index 480cde388..ee407ce48 100644 --- a/internal/service/ssh/upload_archive.go +++ b/internal/service/ssh/upload_archive.go @@ -4,7 +4,7 @@ import ( "os/exec" "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) SSHUploadArchive(stream pb.SSHService_SSHUploadArchiveServer) error { +func (s *server) SSHUploadArchive(stream gitalypb.SSHService_SSHUploadArchiveServer) error { grpc_logrus.Extract(stream.Context()).Debug("SSHUploadArchive") req, err := stream.Recv() // First request contains Repository only @@ -32,10 +32,10 @@ func (s *server) SSHUploadArchive(stream pb.SSHService_SSHUploadArchiveServer) e return request.GetStdin(), err }) stdout := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHUploadArchiveResponse{Stdout: p}) + return stream.Send(&gitalypb.SSHUploadArchiveResponse{Stdout: p}) }) stderr := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHUploadArchiveResponse{Stderr: p}) + return stream.Send(&gitalypb.SSHUploadArchiveResponse{Stderr: p}) }) osCommand := exec.Command(command.GitPath(), "upload-archive", repoPath) @@ -50,7 +50,7 @@ func (s *server) SSHUploadArchive(stream pb.SSHService_SSHUploadArchiveServer) e if status, ok := command.ExitStatus(err); ok { return helper.DecorateError( codes.Internal, - stream.Send(&pb.SSHUploadArchiveResponse{ExitStatus: &pb.ExitStatus{Value: int32(status)}}), + stream.Send(&gitalypb.SSHUploadArchiveResponse{ExitStatus: &gitalypb.ExitStatus{Value: int32(status)}}), ) } return status.Errorf(codes.Unavailable, "SSHUploadArchive: %v", err) @@ -58,11 +58,11 @@ func (s *server) SSHUploadArchive(stream pb.SSHService_SSHUploadArchiveServer) e return helper.DecorateError( codes.Internal, - stream.Send(&pb.SSHUploadArchiveResponse{ExitStatus: &pb.ExitStatus{Value: 0}}), + stream.Send(&gitalypb.SSHUploadArchiveResponse{ExitStatus: &gitalypb.ExitStatus{Value: 0}}), ) } -func validateFirstUploadArchiveRequest(req *pb.SSHUploadArchiveRequest) error { +func validateFirstUploadArchiveRequest(req *gitalypb.SSHUploadArchiveRequest) error { if req.Stdin != nil { return status.Errorf(codes.InvalidArgument, "SSHUploadArchive: non-empty stdin") } diff --git a/internal/service/ssh/upload_archive_test.go b/internal/service/ssh/upload_archive_test.go index 682808243..d8680d461 100644 --- a/internal/service/ssh/upload_archive_test.go +++ b/internal/service/ssh/upload_archive_test.go @@ -9,10 +9,9 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" ) @@ -26,22 +25,22 @@ func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) { tests := []struct { Desc string - Req *pb.SSHUploadArchiveRequest + Req *gitalypb.SSHUploadArchiveRequest Code codes.Code }{ { Desc: "Repository.RelativePath is empty", - Req: &pb.SSHUploadArchiveRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: ""}}, + Req: &gitalypb.SSHUploadArchiveRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: ""}}, Code: codes.InvalidArgument, }, { Desc: "Repository is nil", - Req: &pb.SSHUploadArchiveRequest{Repository: nil}, + Req: &gitalypb.SSHUploadArchiveRequest{Repository: nil}, Code: codes.InvalidArgument, }, { Desc: "Data exists on first request", - Req: &pb.SSHUploadArchiveRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, Stdin: []byte("Fail")}, + Req: &gitalypb.SSHUploadArchiveRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, Stdin: []byte("Fail")}, Code: codes.InvalidArgument, }, } @@ -76,8 +75,8 @@ func TestUploadArchiveSuccess(t *testing.T) { require.NoError(t, err) } -func testArchive(t *testing.T, serverSocketPath string, testRepo *pb.Repository, cmd *exec.Cmd) error { - req := &pb.SSHUploadArchiveRequest{Repository: testRepo} +func testArchive(t *testing.T, serverSocketPath string, testRepo *gitalypb.Repository, cmd *exec.Cmd) error { + req := &gitalypb.SSHUploadArchiveRequest{Repository: testRepo} pbMarshaler := &jsonpb.Marshaler{} payload, err := pbMarshaler.MarshalToString(req) @@ -101,7 +100,7 @@ func testArchive(t *testing.T, serverSocketPath string, testRepo *pb.Repository, return nil } -func drainUploadArchiveResponse(stream pb.SSHService_SSHUploadArchiveClient) error { +func drainUploadArchiveResponse(stream gitalypb.SSHService_SSHUploadArchiveClient) error { var err error for err == nil { _, err = stream.Recv() diff --git a/internal/service/ssh/upload_pack.go b/internal/service/ssh/upload_pack.go index b87d70e34..7867b0a3c 100644 --- a/internal/service/ssh/upload_pack.go +++ b/internal/service/ssh/upload_pack.go @@ -4,7 +4,7 @@ import ( "os/exec" "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/streamio" @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) SSHUploadPack(stream pb.SSHService_SSHUploadPackServer) error { +func (s *server) SSHUploadPack(stream gitalypb.SSHService_SSHUploadPackServer) error { grpc_logrus.Extract(stream.Context()).Debug("SSHUploadPack") req, err := stream.Recv() // First request contains Repository only @@ -28,10 +28,10 @@ func (s *server) SSHUploadPack(stream pb.SSHService_SSHUploadPackServer) error { return request.GetStdin(), err }) stdout := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHUploadPackResponse{Stdout: p}) + return stream.Send(&gitalypb.SSHUploadPackResponse{Stdout: p}) }) stderr := streamio.NewWriter(func(p []byte) error { - return stream.Send(&pb.SSHUploadPackResponse{Stderr: p}) + return stream.Send(&gitalypb.SSHUploadPackResponse{Stderr: p}) }) repoPath, err := helper.GetRepoPath(req.Repository) if err != nil { @@ -58,7 +58,7 @@ func (s *server) SSHUploadPack(stream pb.SSHService_SSHUploadPackServer) error { if status, ok := command.ExitStatus(err); ok { return helper.DecorateError( codes.Internal, - stream.Send(&pb.SSHUploadPackResponse{ExitStatus: &pb.ExitStatus{Value: int32(status)}}), + stream.Send(&gitalypb.SSHUploadPackResponse{ExitStatus: &gitalypb.ExitStatus{Value: int32(status)}}), ) } return status.Errorf(codes.Unavailable, "SSHUploadPack: %v", err) @@ -67,7 +67,7 @@ func (s *server) SSHUploadPack(stream pb.SSHService_SSHUploadPackServer) error { return nil } -func validateFirstUploadPackRequest(req *pb.SSHUploadPackRequest) error { +func validateFirstUploadPackRequest(req *gitalypb.SSHUploadPackRequest) error { if req.Stdin != nil { return status.Errorf(codes.InvalidArgument, "SSHUploadPack: non-empty stdin") } diff --git a/internal/service/ssh/upload_pack_test.go b/internal/service/ssh/upload_pack_test.go index 99a40add0..4dbd53d17 100644 --- a/internal/service/ssh/upload_pack_test.go +++ b/internal/service/ssh/upload_pack_test.go @@ -12,10 +12,9 @@ import ( "github.com/golang/protobuf/jsonpb" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" ) @@ -29,22 +28,22 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) { tests := []struct { Desc string - Req *pb.SSHUploadPackRequest + Req *gitalypb.SSHUploadPackRequest Code codes.Code }{ { Desc: "Repository.RelativePath is empty", - Req: &pb.SSHUploadPackRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: ""}}, + Req: &gitalypb.SSHUploadPackRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: ""}}, Code: codes.InvalidArgument, }, { Desc: "Repository is nil", - Req: &pb.SSHUploadPackRequest{Repository: nil}, + Req: &gitalypb.SSHUploadPackRequest{Repository: nil}, Code: codes.InvalidArgument, }, { Desc: "Data exists on first request", - Req: &pb.SSHUploadPackRequest{Repository: &pb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, Stdin: []byte("Fail")}, + Req: &gitalypb.SSHUploadPackRequest{Repository: &gitalypb.Repository{StorageName: "default", RelativePath: "path/to/repo"}, Stdin: []byte("Fail")}, Code: codes.InvalidArgument, }, } @@ -136,8 +135,8 @@ func TestUploadPackCloneFailure(t *testing.T) { func testClone(t *testing.T, serverSocketPath, storageName, relativePath, localRepoPath string, gitConfig string, cmd *exec.Cmd) (string, string, string, string, error) { defer os.RemoveAll(localRepoPath) - pbTempRepo := &pb.Repository{StorageName: storageName, RelativePath: relativePath} - req := &pb.SSHUploadPackRequest{ + pbTempRepo := &gitalypb.Repository{StorageName: storageName, RelativePath: relativePath} + req := &gitalypb.SSHUploadPackRequest{ Repository: pbTempRepo, } if gitConfig != "" { @@ -175,7 +174,7 @@ func testClone(t *testing.T, serverSocketPath, storageName, relativePath, localR return string(localHead), string(remoteHead), string(localTags), string(remoteTags), nil } -func drainPostUploadPackResponse(stream pb.SSH_SSHUploadPackClient) error { +func drainPostUploadPackResponse(stream gitalypb.SSH_SSHUploadPackClient) error { var err error for err == nil { _, err = stream.Recv() diff --git a/internal/service/storage/deleteall.go b/internal/service/storage/deleteall.go index 74951466f..25c53c73d 100644 --- a/internal/service/storage/deleteall.go +++ b/internal/service/storage/deleteall.go @@ -7,7 +7,7 @@ import ( "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/tempdir" "golang.org/x/net/context" @@ -15,7 +15,7 @@ import ( "google.golang.org/grpc/status" ) -func (s *server) DeleteAllRepositories(ctx context.Context, req *pb.DeleteAllRepositoriesRequest) (*pb.DeleteAllRepositoriesResponse, error) { +func (s *server) DeleteAllRepositories(ctx context.Context, req *gitalypb.DeleteAllRepositoriesRequest) (*gitalypb.DeleteAllRepositoriesResponse, error) { storageDir, err := helper.GetStorageByName(req.StorageName) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "storage lookup failed: %v", err) @@ -65,5 +65,5 @@ func (s *server) DeleteAllRepositories(ctx context.Context, req *pb.DeleteAllRep "numDirectories": count, }).Warn("directories moved to trash") - return &pb.DeleteAllRepositoriesResponse{}, nil + return &gitalypb.DeleteAllRepositoriesResponse{}, nil } diff --git a/internal/service/storage/deleteall_test.go b/internal/service/storage/deleteall_test.go index 4d51fbee3..d8b8b3ccb 100644 --- a/internal/service/storage/deleteall_test.go +++ b/internal/service/storage/deleteall_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/tempdir" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -52,7 +52,7 @@ func TestDeleteAllSuccess(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - _, err := client.DeleteAllRepositories(ctx, &pb.DeleteAllRepositoriesRequest{StorageName: testStorage.Name}) + _, err := client.DeleteAllRepositories(ctx, &gitalypb.DeleteAllRepositoriesRequest{StorageName: testStorage.Name}) require.NoError(t, err) dirents = storageDirents(t, testStorage) @@ -81,23 +81,23 @@ func TestDeleteAllFail(t *testing.T) { testCases := []struct { desc string - req *pb.DeleteAllRepositoriesRequest + req *gitalypb.DeleteAllRepositoriesRequest setup func(t *testing.T) code codes.Code }{ { desc: "empty storage name", - req: &pb.DeleteAllRepositoriesRequest{}, + req: &gitalypb.DeleteAllRepositoriesRequest{}, code: codes.InvalidArgument, }, { desc: "unknown storage name", - req: &pb.DeleteAllRepositoriesRequest{StorageName: "does not exist"}, + req: &gitalypb.DeleteAllRepositoriesRequest{StorageName: "does not exist"}, code: codes.InvalidArgument, }, { desc: "cannot create trash dir", - req: &pb.DeleteAllRepositoriesRequest{StorageName: testStorage.Name}, + req: &gitalypb.DeleteAllRepositoriesRequest{StorageName: testStorage.Name}, setup: func(t *testing.T) { dataDir := path.Join(testStorage.Path, tempdir.GitalyDataPrefix) require.NoError(t, os.RemoveAll(dataDir)) diff --git a/internal/service/storage/listdirectories.go b/internal/service/storage/listdirectories.go index 9d29c05e8..43b85fcb5 100644 --- a/internal/service/storage/listdirectories.go +++ b/internal/service/storage/listdirectories.go @@ -5,13 +5,13 @@ import ( "path/filepath" "strings" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) ListDirectories(req *pb.ListDirectoriesRequest, stream pb.StorageService_ListDirectoriesServer) error { +func (s *server) ListDirectories(req *gitalypb.ListDirectoriesRequest, stream gitalypb.StorageService_ListDirectoriesServer) error { storageDir, err := helper.GetStorageByName(req.StorageName) if err != nil { return status.Errorf(codes.InvalidArgument, "storage lookup failed: %v", err) @@ -36,7 +36,7 @@ func (s *server) ListDirectories(req *pb.ListDirectoriesRequest, stream pb.Stora dirs = append(dirs, relPath) if len(dirs) > 100 { - stream.Send(&pb.ListDirectoriesResponse{Paths: dirs}) + stream.Send(&gitalypb.ListDirectoriesResponse{Paths: dirs}) dirs = dirs[:] } @@ -51,7 +51,7 @@ func (s *server) ListDirectories(req *pb.ListDirectoriesRequest, stream pb.Stora }) if len(dirs) > 0 { - stream.Send(&pb.ListDirectoriesResponse{Paths: dirs}) + stream.Send(&gitalypb.ListDirectoriesResponse{Paths: dirs}) } return err diff --git a/internal/service/storage/listdirectories_test.go b/internal/service/storage/listdirectories_test.go index b98495dbf..4e827e988 100644 --- a/internal/service/storage/listdirectories_test.go +++ b/internal/service/storage/listdirectories_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -65,7 +65,7 @@ func TestListDirectories(t *testing.T) { } for _, tc := range testCases { - stream, err := client.ListDirectories(ctx, &pb.ListDirectoriesRequest{StorageName: "default", Depth: tc.depth}) + stream, err := client.ListDirectories(ctx, &gitalypb.ListDirectoriesRequest{StorageName: "default", Depth: tc.depth}) var dirs []string for { diff --git a/internal/service/storage/server.go b/internal/service/storage/server.go index 76d051a6a..58437dee0 100644 --- a/internal/service/storage/server.go +++ b/internal/service/storage/server.go @@ -1,12 +1,10 @@ package storage -import ( - pb "gitlab.com/gitlab-org/gitaly-proto/go" -) +import "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" type server struct{} // NewServer creates a new instance of a gRPC storage server -func NewServer() pb.StorageServiceServer { +func NewServer() gitalypb.StorageServiceServer { return &server{} } diff --git a/internal/service/storage/testhelper_test.go b/internal/service/storage/testhelper_test.go index 3f245e0dd..3dc5607b9 100644 --- a/internal/service/storage/testhelper_test.go +++ b/internal/service/storage/testhelper_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -50,7 +50,7 @@ func runStorageServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterStorageServiceServer(server, NewServer()) + gitalypb.RegisterStorageServiceServer(server, NewServer()) reflection.Register(server) go server.Serve(listener) @@ -58,7 +58,7 @@ func runStorageServer(t *testing.T) (*grpc.Server, string) { return server, serverSocketPath } -func newStorageClient(t *testing.T, serverSocketPath string) (pb.StorageServiceClient, *grpc.ClientConn) { +func newStorageClient(t *testing.T, serverSocketPath string) (gitalypb.StorageServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -70,5 +70,5 @@ func newStorageClient(t *testing.T, serverSocketPath string) (pb.StorageServiceC t.Fatal(err) } - return pb.NewStorageServiceClient(conn), conn + return gitalypb.NewStorageServiceClient(conn), conn } diff --git a/internal/service/wiki/delete_page.go b/internal/service/wiki/delete_page.go index 60f7ef72d..aa4559a75 100644 --- a/internal/service/wiki/delete_page.go +++ b/internal/service/wiki/delete_page.go @@ -3,16 +3,15 @@ package wiki import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiDeletePage(ctx context.Context, request *pb.WikiDeletePageRequest) (*pb.WikiDeletePageResponse, error) { +func (s *server) WikiDeletePage(ctx context.Context, request *gitalypb.WikiDeletePageRequest) (*gitalypb.WikiDeletePageResponse, error) { if err := validateWikiDeletePageRequest(request); err != nil { return nil, status.Errorf(codes.InvalidArgument, "WikiDeletePage: %v", err) } @@ -30,7 +29,7 @@ func (s *server) WikiDeletePage(ctx context.Context, request *pb.WikiDeletePageR return client.WikiDeletePage(clientCtx, request) } -func validateWikiDeletePageRequest(request *pb.WikiDeletePageRequest) error { +func validateWikiDeletePageRequest(request *gitalypb.WikiDeletePageRequest) error { if len(request.GetPagePath()) == 0 { return fmt.Errorf("empty PagePath") } diff --git a/internal/service/wiki/delete_page_test.go b/internal/service/wiki/delete_page_test.go index b232907e7..34b7cc276 100644 --- a/internal/service/wiki/delete_page_test.go +++ b/internal/service/wiki/delete_page_test.go @@ -3,11 +3,10 @@ package wiki import ( "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -35,14 +34,14 @@ func TestSuccessfulWikiDeletePageRequest(t *testing.T) { testCases := []struct { desc string - req *pb.WikiDeletePageRequest + req *gitalypb.WikiDeletePageRequest }{ { desc: "with user id and username", - req: &pb.WikiDeletePageRequest{ + req: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("a-talé-of-two-wikis"), - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: authorName, Email: authorEmail, Message: message, @@ -53,10 +52,10 @@ func TestSuccessfulWikiDeletePageRequest(t *testing.T) { }, { desc: "without user id and username", // deprecate in GitLab 11.0 https://gitlab.com/gitlab-org/gitaly/issues/1154 - req: &pb.WikiDeletePageRequest{ + req: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("a-talé-of-two-wikis"), - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: authorName, Email: authorEmail, Message: message, @@ -93,7 +92,7 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { client, conn := newWikiClient(t, serverSocketPath) defer conn.Close() - commitDetails := &pb.WikiCommitDetails{ + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Delete a wiki page"), @@ -103,12 +102,12 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.WikiDeletePageRequest + request *gitalypb.WikiDeletePageRequest code codes.Code }{ { desc: "non existent page path", - request: &pb.WikiDeletePageRequest{ + request: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("does-not-exist"), CommitDetails: commitDetails, @@ -117,7 +116,7 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { }, { desc: "empty page path", - request: &pb.WikiDeletePageRequest{ + request: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, CommitDetails: commitDetails, }, @@ -125,7 +124,7 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { }, { desc: "empty commit details", - request: &pb.WikiDeletePageRequest{ + request: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("does-not-matter"), }, @@ -133,10 +132,10 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' name", - request: &pb.WikiDeletePageRequest{ + request: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("does-not-matter"), - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Email: []byte("a@b.com"), Message: []byte("A message"), UserId: int32(1), @@ -147,10 +146,10 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' email", - request: &pb.WikiDeletePageRequest{ + request: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("does-not-matter"), - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: []byte("A name"), Message: []byte("A message"), UserId: int32(1), @@ -161,10 +160,10 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' message", - request: &pb.WikiDeletePageRequest{ + request: &gitalypb.WikiDeletePageRequest{ Repository: wikiRepo, PagePath: []byte("does-not-matter"), - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: []byte("A name"), Email: []byte("a@b.com"), UserId: int32(1), diff --git a/internal/service/wiki/find_file.go b/internal/service/wiki/find_file.go index 9450e4225..29f339944 100644 --- a/internal/service/wiki/find_file.go +++ b/internal/service/wiki/find_file.go @@ -1,15 +1,14 @@ package wiki import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiFindFile(request *pb.WikiFindFileRequest, stream pb.WikiService_WikiFindFileServer) error { +func (s *server) WikiFindFile(request *gitalypb.WikiFindFileRequest, stream gitalypb.WikiService_WikiFindFileServer) error { ctx := stream.Context() if len(request.GetName()) == 0 { diff --git a/internal/service/wiki/find_file_test.go b/internal/service/wiki/find_file_test.go index c23bc109d..336a69583 100644 --- a/internal/service/wiki/find_file_test.go +++ b/internal/service/wiki/find_file_test.go @@ -8,10 +8,9 @@ import ( "path" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -34,7 +33,7 @@ func TestSuccessfulWikiFindFileRequest(t *testing.T) { testhelper.MustRunCommand(t, nil, "git", "clone", wikiRepoPath, sandboxWikiPath) defer os.RemoveAll(sandboxWikiPath) - sandboxWiki := &pb.Repository{ + sandboxWiki := &gitalypb.Repository{ StorageName: "default", RelativePath: "find-file-sandbox/.git", } @@ -60,7 +59,7 @@ func TestSuccessfulWikiFindFileRequest(t *testing.T) { newHeadID := testhelper.MustRunCommand(t, nil, "git", "-C", sandboxWikiPath, "show", "--format=format:%H", "--no-patch", "HEAD") - response := &pb.WikiFindFileResponse{ + response := &gitalypb.WikiFindFileResponse{ Name: []byte("cloúds.png"), MimeType: "image/png", Path: []byte("cloúds.png"), @@ -68,12 +67,12 @@ func TestSuccessfulWikiFindFileRequest(t *testing.T) { testCases := []struct { desc string - request *pb.WikiFindFileRequest - response *pb.WikiFindFileResponse + request *gitalypb.WikiFindFileRequest + response *gitalypb.WikiFindFileResponse }{ { desc: "name only", - request: &pb.WikiFindFileRequest{ + request: &gitalypb.WikiFindFileRequest{ Repository: sandboxWiki, Name: []byte("cloúds.png"), }, @@ -81,7 +80,7 @@ func TestSuccessfulWikiFindFileRequest(t *testing.T) { }, { desc: "name + revision that includes the file", - request: &pb.WikiFindFileRequest{ + request: &gitalypb.WikiFindFileRequest{ Repository: sandboxWiki, Name: []byte("cloúds.png"), Revision: newHeadID, @@ -90,20 +89,20 @@ func TestSuccessfulWikiFindFileRequest(t *testing.T) { }, { desc: "name + revision that does not include the file", - request: &pb.WikiFindFileRequest{ + request: &gitalypb.WikiFindFileRequest{ Repository: sandboxWiki, Name: []byte("cloúds.png"), Revision: oldHeadID, }, - response: &pb.WikiFindFileResponse{}, + response: &gitalypb.WikiFindFileResponse{}, }, { desc: "non-existent name", - request: &pb.WikiFindFileRequest{ + request: &gitalypb.WikiFindFileRequest{ Repository: sandboxWiki, Name: []byte("moar-clouds.png"), }, - response: &pb.WikiFindFileResponse{}, + response: &gitalypb.WikiFindFileResponse{}, }, } @@ -168,7 +167,7 @@ func TestFailedWikiFindFileDueToValidation(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.WikiFindFileRequest{ + request := &gitalypb.WikiFindFileRequest{ Repository: wikiRepo, Name: []byte(testCase.name), Revision: []byte(testCase.revision), @@ -183,7 +182,7 @@ func TestFailedWikiFindFileDueToValidation(t *testing.T) { } } -func drainWikiFindFileResponse(c pb.WikiService_WikiFindFileClient) error { +func drainWikiFindFileResponse(c gitalypb.WikiService_WikiFindFileClient) error { for { _, err := c.Recv() if err != nil { @@ -192,7 +191,7 @@ func drainWikiFindFileResponse(c pb.WikiService_WikiFindFileClient) error { } } -func readFullResponseFromWikiFindFileClient(t *testing.T, c pb.WikiService_WikiFindFileClient) (fullResponse *pb.WikiFindFileResponse) { +func readFullResponseFromWikiFindFileClient(t *testing.T, c gitalypb.WikiService_WikiFindFileClient) (fullResponse *gitalypb.WikiFindFileResponse) { for { resp, err := c.Recv() if err == io.EOF { diff --git a/internal/service/wiki/find_page.go b/internal/service/wiki/find_page.go index ae3191b16..dd8518039 100644 --- a/internal/service/wiki/find_page.go +++ b/internal/service/wiki/find_page.go @@ -1,15 +1,14 @@ package wiki import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiFindPage(request *pb.WikiFindPageRequest, stream pb.WikiService_WikiFindPageServer) error { +func (s *server) WikiFindPage(request *gitalypb.WikiFindPageRequest, stream gitalypb.WikiService_WikiFindPageServer) error { ctx := stream.Context() if len(request.GetTitle()) == 0 { diff --git a/internal/service/wiki/find_page_test.go b/internal/service/wiki/find_page_test.go index 955961af3..254465f41 100644 --- a/internal/service/wiki/find_page_test.go +++ b/internal/service/wiki/find_page_test.go @@ -4,10 +4,9 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -34,18 +33,18 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) { testCases := []struct { desc string - request *pb.WikiFindPageRequest - expectedPage *pb.WikiPage + request *gitalypb.WikiFindPageRequest + expectedPage *gitalypb.WikiPage expectedContent []byte }{ { desc: "title only", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(page1Name), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: latestCommit, Format: "markdown", }, @@ -60,13 +59,13 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) { }, { desc: "title + revision that includes the page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(page1Name), Revision: []byte(page1Commit.Id), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: page1Commit, Format: "markdown", }, @@ -81,7 +80,7 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) { }, { desc: "title + revision that does not include the page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(page2Name), Revision: []byte(page1Commit.Id), @@ -90,13 +89,13 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) { }, { desc: "title + directory that includes the page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte("Step 133-b"), Directory: []byte("Instálling"), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: latestCommit, Format: "markdown", }, @@ -111,7 +110,7 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) { }, { desc: "title + directory that does not include the page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte("Step 133-b"), Directory: []byte("Installation"), @@ -120,12 +119,12 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) { }, { desc: "title for invalidly-encoded page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte("Encoding is fun"), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: latestCommit, Format: "markdown", }, @@ -188,18 +187,18 @@ func TestSuccessfulWikiFindPageSameTitleDifferentPathRequest(t *testing.T) { testCases := []struct { desc string - request *pb.WikiFindPageRequest - expectedPage *pb.WikiPage + request *gitalypb.WikiFindPageRequest + expectedPage *gitalypb.WikiPage content []byte }{ { desc: "finding page in root directory by title only", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(page1Name), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: page2Commit, Format: "markdown", }, @@ -214,13 +213,13 @@ func TestSuccessfulWikiFindPageSameTitleDifferentPathRequest(t *testing.T) { }, { desc: "finding page in root directory by title + directory that includes the page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(page1Name), Directory: []byte(""), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: page2Commit, Format: "markdown", }, @@ -235,13 +234,13 @@ func TestSuccessfulWikiFindPageSameTitleDifferentPathRequest(t *testing.T) { }, { desc: "finding page inside a directory by title + directory that includes the page", - request: &pb.WikiFindPageRequest{ + request: &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(page2Name), Directory: []byte("foo"), }, - expectedPage: &pb.WikiPage{ - Version: &pb.WikiPageVersion{ + expectedPage: &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{ Commit: page2Commit, Format: "markdown", }, @@ -309,7 +308,7 @@ func TestFailedWikiFindPageDueToValidation(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.WikiFindPageRequest{ + request := &gitalypb.WikiFindPageRequest{ Repository: wikiRepo, Title: []byte(testCase.title), } @@ -323,7 +322,7 @@ func TestFailedWikiFindPageDueToValidation(t *testing.T) { } } -func drainWikiFindPageResponse(c pb.WikiService_WikiFindPageClient) error { +func drainWikiFindPageResponse(c gitalypb.WikiService_WikiFindPageClient) error { for { _, err := c.Recv() if err != nil { @@ -332,7 +331,7 @@ func drainWikiFindPageResponse(c pb.WikiService_WikiFindPageClient) error { } } -func readFullWikiPageFromWikiFindPageClient(t *testing.T, c pb.WikiService_WikiFindPageClient) (wikiPage *pb.WikiPage) { +func readFullWikiPageFromWikiFindPageClient(t *testing.T, c gitalypb.WikiService_WikiFindPageClient) (wikiPage *gitalypb.WikiPage) { for { resp, err := c.Recv() if err == io.EOF { diff --git a/internal/service/wiki/formatted_data.go b/internal/service/wiki/formatted_data.go index d58628ac8..03677949d 100644 --- a/internal/service/wiki/formatted_data.go +++ b/internal/service/wiki/formatted_data.go @@ -1,15 +1,14 @@ package wiki import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiGetFormattedData(request *pb.WikiGetFormattedDataRequest, stream pb.WikiService_WikiGetFormattedDataServer) error { +func (s *server) WikiGetFormattedData(request *gitalypb.WikiGetFormattedDataRequest, stream gitalypb.WikiService_WikiGetFormattedDataServer) error { ctx := stream.Context() if len(request.GetTitle()) == 0 { diff --git a/internal/service/wiki/formatted_data_test.go b/internal/service/wiki/formatted_data_test.go index 8bc45453a..587220bdf 100644 --- a/internal/service/wiki/formatted_data_test.go +++ b/internal/service/wiki/formatted_data_test.go @@ -5,10 +5,9 @@ import ( "io" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -35,18 +34,18 @@ func TestSuccessfulWikiGetFormattedDataRequest(t *testing.T) { testCases := []struct { desc string - request *pb.WikiGetFormattedDataRequest + request *gitalypb.WikiGetFormattedDataRequest }{ { desc: "title only", - request: &pb.WikiGetFormattedDataRequest{ + request: &gitalypb.WikiGetFormattedDataRequest{ Repository: wikiRepo, Title: []byte(page1Name), }, }, { desc: "title + revision that includes the page", - request: &pb.WikiGetFormattedDataRequest{ + request: &gitalypb.WikiGetFormattedDataRequest{ Repository: wikiRepo, Title: []byte(page1Name), Revision: []byte(page1Commit.Id), @@ -54,7 +53,7 @@ func TestSuccessfulWikiGetFormattedDataRequest(t *testing.T) { }, { desc: "title + directory that includes the page", - request: &pb.WikiGetFormattedDataRequest{ + request: &gitalypb.WikiGetFormattedDataRequest{ Repository: wikiRepo, Title: []byte("Step 133-b"), Directory: []byte("Instálling"), @@ -108,7 +107,7 @@ func TestFailedWikiGetFormattedDataDueToValidation(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - request := &pb.WikiGetFormattedDataRequest{ + request := &gitalypb.WikiGetFormattedDataRequest{ Repository: wikiRepo, Title: []byte(testCase.title), } @@ -122,7 +121,7 @@ func TestFailedWikiGetFormattedDataDueToValidation(t *testing.T) { } } -func drainWikiGetFormattedDataResponse(c pb.WikiService_WikiGetFormattedDataClient) error { +func drainWikiGetFormattedDataResponse(c gitalypb.WikiService_WikiGetFormattedDataClient) error { for { _, err := c.Recv() if err != nil { @@ -131,7 +130,7 @@ func drainWikiGetFormattedDataResponse(c pb.WikiService_WikiGetFormattedDataClie } } -func readFullDataFromWikiGetFormattedDataClient(t *testing.T, c pb.WikiService_WikiGetFormattedDataClient) (data []byte) { +func readFullDataFromWikiGetFormattedDataClient(t *testing.T, c gitalypb.WikiService_WikiGetFormattedDataClient) (data []byte) { for { resp, err := c.Recv() if err == io.EOF { diff --git a/internal/service/wiki/get_all_pages.go b/internal/service/wiki/get_all_pages.go index 5aa430d20..555606585 100644 --- a/internal/service/wiki/get_all_pages.go +++ b/internal/service/wiki/get_all_pages.go @@ -1,12 +1,11 @@ package wiki import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) -func (s *server) WikiGetAllPages(request *pb.WikiGetAllPagesRequest, stream pb.WikiService_WikiGetAllPagesServer) error { +func (s *server) WikiGetAllPages(request *gitalypb.WikiGetAllPagesRequest, stream gitalypb.WikiService_WikiGetAllPagesServer) error { ctx := stream.Context() client, err := s.WikiServiceClient(ctx) diff --git a/internal/service/wiki/get_all_pages_test.go b/internal/service/wiki/get_all_pages_test.go index 6d7f270df..9aaced04e 100644 --- a/internal/service/wiki/get_all_pages_test.go +++ b/internal/service/wiki/get_all_pages_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -29,8 +29,8 @@ func TestSuccessfulWikiGetAllPagesRequest(t *testing.T) { page2Name := "Page 2" createTestWikiPage(t, client, wikiRepo, createWikiPageOpts{title: page1Name}) page2Commit := createTestWikiPage(t, client, wikiRepo, createWikiPageOpts{title: page2Name}) - expectedPage1 := &pb.WikiPage{ - Version: &pb.WikiPageVersion{Commit: page2Commit, Format: "markdown"}, + expectedPage1 := &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{Commit: page2Commit, Format: "markdown"}, Title: []byte(page1Name), Format: "markdown", UrlPath: "Page-1", @@ -39,8 +39,8 @@ func TestSuccessfulWikiGetAllPagesRequest(t *testing.T) { RawData: mockPageContent, Historical: false, } - expectedPage2 := &pb.WikiPage{ - Version: &pb.WikiPageVersion{Commit: page2Commit, Format: "markdown"}, + expectedPage2 := &gitalypb.WikiPage{ + Version: &gitalypb.WikiPageVersion{Commit: page2Commit, Format: "markdown"}, Title: []byte(page2Name), Format: "markdown", UrlPath: "Page-2", @@ -72,11 +72,11 @@ func TestSuccessfulWikiGetAllPagesRequest(t *testing.T) { }, } - expectedPages := []*pb.WikiPage{expectedPage1, expectedPage2} + expectedPages := []*gitalypb.WikiPage{expectedPage1, expectedPage2} for _, tc := range testcases { t.Run(tc.desc, func(t *testing.T) { - rpcRequest := pb.WikiGetAllPagesRequest{Repository: wikiRepo, Limit: tc.limit} + rpcRequest := gitalypb.WikiGetAllPagesRequest{Repository: wikiRepo, Limit: tc.limit} c, err := client.WikiGetAllPages(ctx, &rpcRequest) require.NoError(t, err) @@ -99,8 +99,8 @@ func TestFailedWikiGetAllPagesDueToValidation(t *testing.T) { client, conn := newWikiClient(t, serverSocketPath) defer conn.Close() - rpcRequests := []pb.WikiGetAllPagesRequest{ - {Repository: &pb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist + rpcRequests := []gitalypb.WikiGetAllPagesRequest{ + {Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist {Repository: nil}, // Repository is nil } @@ -116,9 +116,9 @@ func TestFailedWikiGetAllPagesDueToValidation(t *testing.T) { } } -func readWikiPagesFromWikiGetAllPagesClient(t *testing.T, c pb.WikiService_WikiGetAllPagesClient) []*pb.WikiPage { - var wikiPage *pb.WikiPage - var wikiPages []*pb.WikiPage +func readWikiPagesFromWikiGetAllPagesClient(t *testing.T, c gitalypb.WikiService_WikiGetAllPagesClient) []*gitalypb.WikiPage { + var wikiPage *gitalypb.WikiPage + var wikiPages []*gitalypb.WikiPage for { resp, err := c.Recv() @@ -141,7 +141,7 @@ func readWikiPagesFromWikiGetAllPagesClient(t *testing.T, c pb.WikiService_WikiG return wikiPages } -func drainWikiGetAllPagesResponse(c pb.WikiService_WikiGetAllPagesClient) error { +func drainWikiGetAllPagesResponse(c gitalypb.WikiService_WikiGetAllPagesClient) error { for { _, err := c.Recv() if err == io.EOF { diff --git a/internal/service/wiki/get_page_versions.go b/internal/service/wiki/get_page_versions.go index 715c279cb..d0bf36860 100644 --- a/internal/service/wiki/get_page_versions.go +++ b/internal/service/wiki/get_page_versions.go @@ -1,15 +1,14 @@ package wiki import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiGetPageVersions(request *pb.WikiGetPageVersionsRequest, stream pb.WikiService_WikiGetPageVersionsServer) error { +func (s *server) WikiGetPageVersions(request *gitalypb.WikiGetPageVersionsRequest, stream gitalypb.WikiService_WikiGetPageVersionsServer) error { ctx := stream.Context() if len(request.GetPagePath()) == 0 { diff --git a/internal/service/wiki/get_page_versions_test.go b/internal/service/wiki/get_page_versions_test.go index 78888e869..fa3ce9084 100644 --- a/internal/service/wiki/get_page_versions_test.go +++ b/internal/service/wiki/get_page_versions_test.go @@ -6,10 +6,9 @@ import ( "strings" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -34,19 +33,19 @@ func TestWikiGetPageVersionsRequest(t *testing.T) { updateWikiPage(t, client, wikiRepo, pageTitle, []byte("New content")) v2cid := testhelper.MustRunCommand(t, nil, "git", "-C", wikiRepoPath, "log", "-1", "--format=%H") - gitAuthor := &pb.CommitAuthor{ + gitAuthor := &gitalypb.CommitAuthor{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), } testCases := []struct { desc string - request *pb.WikiGetPageVersionsRequest - versions []*pb.WikiPageVersion + request *gitalypb.WikiGetPageVersionsRequest + versions []*gitalypb.WikiPageVersion }{ { desc: "No page found", - request: &pb.WikiGetPageVersionsRequest{ + request: &gitalypb.WikiGetPageVersionsRequest{ Repository: wikiRepo, PagePath: []byte("not-found"), }, @@ -54,13 +53,13 @@ func TestWikiGetPageVersionsRequest(t *testing.T) { }, { desc: "2 version found", - request: &pb.WikiGetPageVersionsRequest{ + request: &gitalypb.WikiGetPageVersionsRequest{ Repository: wikiRepo, PagePath: []byte(pageTitle), }, - versions: []*pb.WikiPageVersion{ + versions: []*gitalypb.WikiPageVersion{ { - Commit: &pb.GitCommit{ + Commit: &gitalypb.GitCommit{ Id: strings.TrimRight(string(v2cid), "\n"), Body: []byte("Update WikiGétPageVersions"), Subject: []byte("Update WikiGétPageVersions"), @@ -72,7 +71,7 @@ func TestWikiGetPageVersionsRequest(t *testing.T) { Format: "markdown", }, { - Commit: &pb.GitCommit{ + Commit: &gitalypb.GitCommit{ Id: strings.TrimRight(string(v1cid), "\n"), Body: []byte("Add WikiGétPageVersions"), Subject: []byte("Add WikiGétPageVersions"), @@ -160,7 +159,7 @@ func TestWikiGetPageVersionsPaginationParams(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - stream, err := client.WikiGetPageVersions(ctx, &pb.WikiGetPageVersionsRequest{ + stream, err := client.WikiGetPageVersions(ctx, &gitalypb.WikiGetPageVersionsRequest{ Repository: wikiRepo, PagePath: []byte(pageTitle), PerPage: tc.perPage, @@ -184,7 +183,7 @@ func TestWikiGetPageVersionsPaginationParams(t *testing.T) { } } -func assertWikiPageVersionEqual(t *testing.T, expected, actual *pb.WikiPageVersion, msg ...interface{}) bool { +func assertWikiPageVersionEqual(t *testing.T, expected, actual *gitalypb.WikiPageVersion, msg ...interface{}) bool { assert.Equal(t, expected.GetFormat(), actual.GetFormat()) assert.NoError(t, testhelper.GitCommitEqual(expected.GetCommit(), actual.GetCommit())) diff --git a/internal/service/wiki/server.go b/internal/service/wiki/server.go index 24010f183..2b3575457 100644 --- a/internal/service/wiki/server.go +++ b/internal/service/wiki/server.go @@ -1,9 +1,8 @@ package wiki import ( + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" ) type server struct { @@ -11,6 +10,6 @@ type server struct { } // NewServer creates a new instance of a grpc WikiServiceServer -func NewServer(rs *rubyserver.Server) pb.WikiServiceServer { +func NewServer(rs *rubyserver.Server) gitalypb.WikiServiceServer { return &server{rs} } diff --git a/internal/service/wiki/testhelper_test.go b/internal/service/wiki/testhelper_test.go index 49acff46f..29c6410b9 100644 --- a/internal/service/wiki/testhelper_test.go +++ b/internal/service/wiki/testhelper_test.go @@ -9,13 +9,12 @@ import ( "testing" "time" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" "google.golang.org/grpc" @@ -61,7 +60,7 @@ func runWikiServiceServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - pb.RegisterWikiServiceServer(grpcServer, &server{rubyServer}) + gitalypb.RegisterWikiServiceServer(grpcServer, &server{rubyServer}) reflection.Register(grpcServer) go grpcServer.Serve(listener) @@ -69,7 +68,7 @@ func runWikiServiceServer(t *testing.T) (*grpc.Server, string) { return grpcServer, serverSocketPath } -func newWikiClient(t *testing.T, serverSocketPath string) (pb.WikiServiceClient, *grpc.ClientConn) { +func newWikiClient(t *testing.T, serverSocketPath string) (gitalypb.WikiServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -81,10 +80,10 @@ func newWikiClient(t *testing.T, serverSocketPath string) (pb.WikiServiceClient, t.Fatal(err) } - return pb.NewWikiServiceClient(conn), conn + return gitalypb.NewWikiServiceClient(conn), conn } -func writeWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repository, opts createWikiPageOpts) { +func writeWikiPage(t *testing.T, client gitalypb.WikiServiceClient, wikiRepo *gitalypb.Repository, opts createWikiPageOpts) { var content []byte if len(opts.content) == 0 { content = mockPageContent @@ -99,7 +98,7 @@ func writeWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repos format = opts.format } - commitDetails := &pb.WikiCommitDetails{ + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Add " + opts.title), @@ -107,7 +106,7 @@ func writeWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repos UserName: []byte("ahmad"), } - request := &pb.WikiWritePageRequest{ + request := &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte(opts.title), Format: format, @@ -127,8 +126,8 @@ func writeWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repos require.NoError(t, err) } -func updateWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repository, name string, content []byte) { - commitDetails := &pb.WikiCommitDetails{ +func updateWikiPage(t *testing.T, client gitalypb.WikiServiceClient, wikiRepo *gitalypb.Repository, name string, content []byte) { + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Update " + name), @@ -136,7 +135,7 @@ func updateWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repo UserName: []byte("ahmad"), } - request := &pb.WikiUpdatePageRequest{ + request := &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte(name), Title: []byte(name), @@ -156,14 +155,14 @@ func updateWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repo require.NoError(t, err) } -func setupWikiRepo(t *testing.T) (*pb.Repository, string, func()) { +func setupWikiRepo(t *testing.T) (*gitalypb.Repository, string, func()) { relPath := strings.Join([]string{t.Name(), "wiki-test.git"}, "-") storagePath := testhelper.GitlabTestStoragePath() wikiRepoPath := path.Join(storagePath, relPath) testhelper.MustRunCommand(nil, nil, "git", "init", "--bare", wikiRepoPath) - wikiRepo := &pb.Repository{ + wikiRepo := &gitalypb.Repository{ StorageName: "default", RelativePath: relPath, } @@ -188,7 +187,7 @@ func sendBytes(data []byte, chunkSize int, sender func([]byte) error) (int, erro return i, nil } -func createTestWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb.Repository, opts createWikiPageOpts) *pb.GitCommit { +func createTestWikiPage(t *testing.T, client gitalypb.WikiServiceClient, wikiRepo *gitalypb.Repository, opts createWikiPageOpts) *gitalypb.GitCommit { ctx, cancel := testhelper.Context() defer cancel() @@ -203,7 +202,7 @@ func createTestWikiPage(t *testing.T, client pb.WikiServiceClient, wikiRepo *pb. return pageCommit } -func requireWikiPagesEqual(t *testing.T, expectedPage *pb.WikiPage, actualPage *pb.WikiPage) { +func requireWikiPagesEqual(t *testing.T, expectedPage *gitalypb.WikiPage, actualPage *gitalypb.WikiPage) { // require.Equal doesn't display a proper diff when either expected/actual has a field // with large data (RawData in our case), so we compare file attributes and content separately. expectedContent := expectedPage.GetRawData() diff --git a/internal/service/wiki/update_page.go b/internal/service/wiki/update_page.go index 73c17684c..f6db8209e 100644 --- a/internal/service/wiki/update_page.go +++ b/internal/service/wiki/update_page.go @@ -3,15 +3,14 @@ package wiki import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiUpdatePage(stream pb.WikiService_WikiUpdatePageServer) error { +func (s *server) WikiUpdatePage(stream gitalypb.WikiService_WikiUpdatePageServer) error { firstRequest, err := stream.Recv() if err != nil { return err @@ -62,7 +61,7 @@ func (s *server) WikiUpdatePage(stream pb.WikiService_WikiUpdatePageServer) erro return stream.SendAndClose(response) } -func validateWikiUpdatePageRequest(request *pb.WikiUpdatePageRequest) error { +func validateWikiUpdatePageRequest(request *gitalypb.WikiUpdatePageRequest) error { if len(request.GetPagePath()) == 0 { return fmt.Errorf("empty Page Path") } diff --git a/internal/service/wiki/update_page_test.go b/internal/service/wiki/update_page_test.go index 9e8b2303c..2c14bc6ab 100644 --- a/internal/service/wiki/update_page_test.go +++ b/internal/service/wiki/update_page_test.go @@ -4,11 +4,10 @@ import ( "bytes" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -36,17 +35,17 @@ func TestSuccessfulWikiUpdatePageRequest(t *testing.T) { testCases := []struct { desc string - req *pb.WikiUpdatePageRequest + req *gitalypb.WikiUpdatePageRequest content []byte }{ { desc: "with user id and username", - req: &pb.WikiUpdatePageRequest{ + req: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Instálling Gitaly"), Title: []byte("Instálling Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: authorName, Email: authorEmail, Message: message, @@ -58,12 +57,12 @@ func TestSuccessfulWikiUpdatePageRequest(t *testing.T) { }, { desc: "without user id and username", // deprecate in gitlab 11.0 https://gitlab.com/gitlab-org/gitaly/issues/1154 - req: &pb.WikiUpdatePageRequest{ + req: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Instálling Gitaly"), Title: []byte("Instálling Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: authorName, Email: authorEmail, Message: message, @@ -87,7 +86,7 @@ func TestSuccessfulWikiUpdatePageRequest(t *testing.T) { } // Use a new response so we don't send other fields (Repository, ...) over and over - request = &pb.WikiUpdatePageRequest{} + request = &gitalypb.WikiUpdatePageRequest{} return nil }) @@ -124,7 +123,7 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { writeWikiPage(t, client, wikiRepo, createWikiPageOpts{title: "Installing Gitaly", content: []byte("foobar")}) - commitDetails := &pb.WikiCommitDetails{ + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Add installation instructions"), @@ -134,12 +133,12 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.WikiUpdatePageRequest + request *gitalypb.WikiUpdatePageRequest code codes.Code }{ { desc: "empty page_path", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, Title: []byte("Installing Gitaly"), Format: "markdown", @@ -150,7 +149,7 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { }, { desc: "empty title", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Installing Gitaly"), Format: "markdown", @@ -161,7 +160,7 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { }, { desc: "empty format", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Installing Gitaly.md"), Title: []byte("Installing Gitaly"), @@ -172,7 +171,7 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { }, { desc: "empty commit details", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Installing Gitaly.md"), Title: []byte("Installing Gitaly"), @@ -183,12 +182,12 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' name", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Installing Gitaly.md"), Title: []byte("Installing Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Email: []byte("a@b.com"), Message: []byte("A message"), UserId: int32(1), @@ -200,12 +199,12 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' email", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Installing Gitaly.md"), Title: []byte("Installing Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: []byte("A name"), Message: []byte("A message"), UserId: int32(1), @@ -217,12 +216,12 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' message", - request: &pb.WikiUpdatePageRequest{ + request: &gitalypb.WikiUpdatePageRequest{ Repository: wikiRepo, PagePath: []byte("//Installing Gitaly.md"), Title: []byte("Installing Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: []byte("A name"), Email: []byte("a@b.com"), UserId: int32(1), diff --git a/internal/service/wiki/util.go b/internal/service/wiki/util.go index 6ab3ee446..cc6f33fbb 100644 --- a/internal/service/wiki/util.go +++ b/internal/service/wiki/util.go @@ -3,11 +3,11 @@ package wiki import ( "fmt" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" ) type requestWithCommitDetails interface { - GetCommitDetails() *pb.WikiCommitDetails + GetCommitDetails() *gitalypb.WikiCommitDetails } func validateRequestCommitDetails(request requestWithCommitDetails) error { diff --git a/internal/service/wiki/write_page.go b/internal/service/wiki/write_page.go index ec23baf45..ee2f38a9d 100644 --- a/internal/service/wiki/write_page.go +++ b/internal/service/wiki/write_page.go @@ -3,15 +3,14 @@ package wiki import ( "fmt" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -func (s *server) WikiWritePage(stream pb.WikiService_WikiWritePageServer) error { +func (s *server) WikiWritePage(stream gitalypb.WikiService_WikiWritePageServer) error { firstRequest, err := stream.Recv() if err != nil { return err @@ -62,7 +61,7 @@ func (s *server) WikiWritePage(stream pb.WikiService_WikiWritePageServer) error return stream.SendAndClose(response) } -func validateWikiWritePageRequest(request *pb.WikiWritePageRequest) error { +func validateWikiWritePageRequest(request *gitalypb.WikiWritePageRequest) error { if len(request.GetName()) == 0 { return fmt.Errorf("empty Name") } diff --git a/internal/service/wiki/write_page_test.go b/internal/service/wiki/write_page_test.go index 729a71c46..a63711397 100644 --- a/internal/service/wiki/write_page_test.go +++ b/internal/service/wiki/write_page_test.go @@ -4,11 +4,10 @@ import ( "bytes" "testing" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" ) @@ -34,17 +33,17 @@ func TestSuccessfulWikiWritePageRequest(t *testing.T) { testCases := []struct { desc string - req *pb.WikiWritePageRequest + req *gitalypb.WikiWritePageRequest gollumPath string content []byte }{ { desc: "with user id and username", - req: &pb.WikiWritePageRequest{ + req: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Instálling Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: authorName, Email: authorEmail, Message: message, @@ -57,11 +56,11 @@ func TestSuccessfulWikiWritePageRequest(t *testing.T) { }, { desc: "without user id and username", // deprecate in gitlab 11.0 https://gitlab.com/gitlab-org/gitaly/issues/1154 - req: &pb.WikiWritePageRequest{ + req: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Instálling Gitaly 2"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: authorName, Email: authorEmail, Message: message, @@ -88,7 +87,7 @@ func TestSuccessfulWikiWritePageRequest(t *testing.T) { } // Use a new response so we don't send other fields (Repository, ...) over and over - request = &pb.WikiWritePageRequest{} + request = &gitalypb.WikiWritePageRequest{} return nil }) @@ -127,7 +126,7 @@ func TestFailedWikiWritePageDueToDuplicatePage(t *testing.T) { pageName := "Installing Gitaly" content := []byte("Mock wiki page content") - commitDetails := &pb.WikiCommitDetails{ + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Add " + pageName), @@ -137,7 +136,7 @@ func TestFailedWikiWritePageDueToDuplicatePage(t *testing.T) { writeWikiPage(t, client, wikiRepo, createWikiPageOpts{title: pageName, content: content}) - request := &pb.WikiWritePageRequest{ + request := &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte(pageName), Format: "markdown", @@ -156,7 +155,7 @@ func TestFailedWikiWritePageDueToDuplicatePage(t *testing.T) { response, err := stream.CloseAndRecv() require.NoError(t, err) - expectedResponse := &pb.WikiWritePageResponse{DuplicateError: []byte("Cannot write //Installing-Gitaly.md, found //Installing-Gitaly.md.")} + expectedResponse := &gitalypb.WikiWritePageResponse{DuplicateError: []byte("Cannot write //Installing-Gitaly.md, found //Installing-Gitaly.md.")} require.Equal(t, expectedResponse, response, "mismatched response") } @@ -172,7 +171,7 @@ func TestFailedWikiWritePageInPathDueToDuplicatePage(t *testing.T) { pageName := "foo/Installing Gitaly" content := []byte("Mock wiki page content") - commitDetails := &pb.WikiCommitDetails{ + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Add " + pageName), @@ -182,7 +181,7 @@ func TestFailedWikiWritePageInPathDueToDuplicatePage(t *testing.T) { writeWikiPage(t, client, wikiRepo, createWikiPageOpts{title: pageName, content: content}) - request := &pb.WikiWritePageRequest{ + request := &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte(pageName), Format: "markdown", @@ -201,12 +200,12 @@ func TestFailedWikiWritePageInPathDueToDuplicatePage(t *testing.T) { response, err := stream.CloseAndRecv() require.NoError(t, err) - expectedResponse := &pb.WikiWritePageResponse{DuplicateError: []byte("Cannot write foo/Installing-Gitaly.md, found foo/Installing-Gitaly.md.")} + expectedResponse := &gitalypb.WikiWritePageResponse{DuplicateError: []byte("Cannot write foo/Installing-Gitaly.md, found foo/Installing-Gitaly.md.")} require.Equal(t, expectedResponse, response, "mismatched response") } func TestFailedWikiWritePageDueToValidations(t *testing.T) { - wikiRepo := &pb.Repository{} + wikiRepo := &gitalypb.Repository{} server, serverSocketPath := runWikiServiceServer(t) defer server.Stop() @@ -214,7 +213,7 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { client, conn := newWikiClient(t, serverSocketPath) defer conn.Close() - commitDetails := &pb.WikiCommitDetails{ + commitDetails := &gitalypb.WikiCommitDetails{ Name: []byte("Ahmad Sherif"), Email: []byte("ahmad@gitlab.com"), Message: []byte("Add installation instructions"), @@ -224,12 +223,12 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { testCases := []struct { desc string - request *pb.WikiWritePageRequest + request *gitalypb.WikiWritePageRequest code codes.Code }{ { desc: "empty name", - request: &pb.WikiWritePageRequest{ + request: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Format: "markdown", CommitDetails: commitDetails, @@ -239,7 +238,7 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { }, { desc: "empty format", - request: &pb.WikiWritePageRequest{ + request: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Installing Gitaly"), CommitDetails: commitDetails, @@ -249,7 +248,7 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { }, { desc: "empty commit details", - request: &pb.WikiWritePageRequest{ + request: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Installing Gitaly"), Format: "markdown", @@ -259,11 +258,11 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' name", - request: &pb.WikiWritePageRequest{ + request: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Installing Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Email: []byte("a@b.com"), Message: []byte("A message"), UserId: int32(1), @@ -275,11 +274,11 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' email", - request: &pb.WikiWritePageRequest{ + request: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Installing Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: []byte("A name"), Message: []byte("A message"), UserId: int32(1), @@ -291,11 +290,11 @@ func TestFailedWikiWritePageDueToValidations(t *testing.T) { }, { desc: "empty commit details' message", - request: &pb.WikiWritePageRequest{ + request: &gitalypb.WikiWritePageRequest{ Repository: wikiRepo, Name: []byte("Installing Gitaly"), Format: "markdown", - CommitDetails: &pb.WikiCommitDetails{ + CommitDetails: &gitalypb.WikiCommitDetails{ Name: []byte("A name"), Email: []byte("a@b.com"), UserId: int32(1), diff --git a/internal/tempdir/tempdir.go b/internal/tempdir/tempdir.go index 18b4e7bb9..365c93d40 100644 --- a/internal/tempdir/tempdir.go +++ b/internal/tempdir/tempdir.go @@ -9,7 +9,7 @@ import ( "strings" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/helper/housekeeping" @@ -45,7 +45,7 @@ func ForDeleteAllRepositories(storageName string) (string, error) { // New returns the path of a new temporary directory for use with the // repository. The directory is removed with os.RemoveAll when ctx // expires. -func New(ctx context.Context, repo *pb.Repository) (string, error) { +func New(ctx context.Context, repo *gitalypb.Repository) (string, error) { _, path, err := NewAsRepository(ctx, repo) if err != nil { return "", err @@ -54,13 +54,13 @@ func New(ctx context.Context, repo *pb.Repository) (string, error) { return path, nil } -// NewAsRepository is the same as New, but it returns a *pb.Repository for the +// NewAsRepository is the same as New, but it returns a *gitalypb.Repository for the // created directory as well as the bare path as a string -func NewAsRepository(ctx context.Context, repo *pb.Repository) (*pb.Repository, string, error) { +func NewAsRepository(ctx context.Context, repo *gitalypb.Repository) (*gitalypb.Repository, string, error) { return newAsRepository(ctx, repo.StorageName, "repo") } -func newAsRepository(ctx context.Context, storageName string, prefix string) (*pb.Repository, string, error) { +func newAsRepository(ctx context.Context, storageName string, prefix string) (*gitalypb.Repository, string, error) { storageDir, err := helper.GetStorageByName(storageName) if err != nil { return nil, "", err @@ -81,7 +81,7 @@ func newAsRepository(ctx context.Context, storageName string, prefix string) (*p os.RemoveAll(tempDir) }() - newAsRepo := &pb.Repository{StorageName: storageName} + newAsRepo := &gitalypb.Repository{StorageName: storageName} newAsRepo.RelativePath, err = filepath.Rel(storageDir, tempDir) return newAsRepo, tempDir, err } diff --git a/internal/tempdir/tempdir_test.go b/internal/tempdir/tempdir_test.go index 4f1311151..72efae7ad 100644 --- a/internal/tempdir/tempdir_test.go +++ b/internal/tempdir/tempdir_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -49,7 +49,7 @@ func TestNewAsRepositorySuccess(t *testing.T) { func TestNewAsRepositoryFailStorageUnknown(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - _, err := New(ctx, &pb.Repository{StorageName: "does-not-exist", RelativePath: "foobar.git"}) + _, err := New(ctx, &gitalypb.Repository{StorageName: "does-not-exist", RelativePath: "foobar.git"}) require.Error(t, err) } diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index 17be64667..5779e54db 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -23,7 +23,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" - pb "gitlab.com/gitlab-org/gitaly-proto/go" + "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/storage" @@ -97,7 +97,7 @@ func GitalyServersMetadata(t *testing.T, serverSocketPath string) metadata.MD { return metadata.Pairs("gitaly-servers", base64.StdEncoding.EncodeToString(gitalyServersJSON)) } -func testRepoValid(repo *pb.Repository) bool { +func testRepoValid(repo *gitalypb.Repository) bool { storagePath, _ := config.StoragePath(repo.GetStorageName()) if _, err := os.Stat(path.Join(storagePath, repo.RelativePath, "objects")); err != nil { return false @@ -110,8 +110,8 @@ func testRepoValid(repo *pb.Repository) bool { // Tests should be calling this function instead of cloning the repo themselves. // Tests that involve modifications to the repo should copy/clone the repo // via the `Repository` returned from this function. -func TestRepository() *pb.Repository { - repo := &pb.Repository{ +func TestRepository() *gitalypb.Repository { + repo := &gitalypb.Repository{ StorageName: "default", RelativePath: TestRelativePath, GlRepository: "project-1", @@ -163,7 +163,7 @@ func MustRunCommand(t *testing.T, stdin io.Reader, name string, args ...string) // authorSortofEqual tests if two `CommitAuthor`s have the same name and email. // useful when creating commits in the tests. -func authorSortofEqual(a, b *pb.CommitAuthor) bool { +func authorSortofEqual(a, b *gitalypb.CommitAuthor) bool { if (a == nil) != (b == nil) { return false } @@ -172,13 +172,13 @@ func authorSortofEqual(a, b *pb.CommitAuthor) bool { } // AuthorsEqual tests if two `CommitAuthor`s are equal -func AuthorsEqual(a *pb.CommitAuthor, b *pb.CommitAuthor) bool { +func AuthorsEqual(a *gitalypb.CommitAuthor, b *gitalypb.CommitAuthor) bool { return authorSortofEqual(a, b) && a.GetDate().Seconds == b.GetDate().Seconds } // GitCommitEqual tests if two `GitCommit`s are equal -func GitCommitEqual(a, b *pb.GitCommit) error { +func GitCommitEqual(a, b *gitalypb.GitCommit) error { if !authorSortofEqual(a.GetAuthor(), b.GetAuthor()) { return fmt.Errorf("Author does not match: %v != %v", a.GetAuthor(), b.GetAuthor()) } @@ -209,14 +209,14 @@ func GitCommitEqual(a, b *pb.GitCommit) error { } // FindLocalBranchCommitAuthorsEqual tests if two `FindLocalBranchCommitAuthor`s are equal -func FindLocalBranchCommitAuthorsEqual(a *pb.FindLocalBranchCommitAuthor, b *pb.FindLocalBranchCommitAuthor) bool { +func FindLocalBranchCommitAuthorsEqual(a *gitalypb.FindLocalBranchCommitAuthor, b *gitalypb.FindLocalBranchCommitAuthor) bool { return bytes.Equal(a.Name, b.Name) && bytes.Equal(a.Email, b.Email) && a.Date.Seconds == b.Date.Seconds } // FindLocalBranchResponsesEqual tests if two `FindLocalBranchResponse`s are equal -func FindLocalBranchResponsesEqual(a *pb.FindLocalBranchResponse, b *pb.FindLocalBranchResponse) bool { +func FindLocalBranchResponsesEqual(a *gitalypb.FindLocalBranchResponse, b *gitalypb.FindLocalBranchResponse) bool { return a.CommitId == b.CommitId && bytes.Equal(a.CommitSubject, b.CommitSubject) && FindLocalBranchCommitAuthorsEqual(a.CommitAuthor, b.CommitAuthor) && @@ -324,29 +324,29 @@ func Context() (context.Context, func()) { return context.WithCancel(context.Background()) } -func createRepo(t *testing.T, storagePath string) (repo *pb.Repository, repoPath, relativePath string) { +func createRepo(t *testing.T, storagePath string) (repo *gitalypb.Repository, repoPath, relativePath string) { normalizedPrefix := strings.Replace(t.Name(), "/", "-", -1) //TempDir doesn't like a prefix containing slashes repoPath, err := ioutil.TempDir(storagePath, normalizedPrefix) require.NoError(t, err) relativePath, err = filepath.Rel(storagePath, repoPath) require.NoError(t, err) - repo = &pb.Repository{StorageName: "default", RelativePath: relativePath} + repo = &gitalypb.Repository{StorageName: "default", RelativePath: relativePath} return repo, repoPath, relativePath } // InitBareRepo creates a new bare repository -func InitBareRepo(t *testing.T) (*pb.Repository, string, func()) { +func InitBareRepo(t *testing.T) (*gitalypb.Repository, string, func()) { return initRepo(t, true) } // InitRepoWithWorktree creates a new repository with a worktree -func InitRepoWithWorktree(t *testing.T) (*pb.Repository, string, func()) { +func InitRepoWithWorktree(t *testing.T) (*gitalypb.Repository, string, func()) { return initRepo(t, false) } -func initRepo(t *testing.T, bare bool) (*pb.Repository, string, func()) { +func initRepo(t *testing.T, bare bool) (*gitalypb.Repository, string, func()) { repo, repoPath, _ := createRepo(t, GitlabTestStoragePath()) args := []string{"init"} if bare { @@ -363,17 +363,17 @@ func initRepo(t *testing.T, bare bool) (*pb.Repository, string, func()) { } // NewTestRepo creates a bare copy of the test repository. -func NewTestRepo(t *testing.T) (repo *pb.Repository, repoPath string, cleanup func()) { +func NewTestRepo(t *testing.T) (repo *gitalypb.Repository, repoPath string, cleanup func()) { return cloneTestRepo(t, true) } // NewTestRepoWithWorktree creates a copy of the test repository with a // worktree. This is allows you to run normal 'non-bare' Git commands. -func NewTestRepoWithWorktree(t *testing.T) (repo *pb.Repository, repoPath string, cleanup func()) { +func NewTestRepoWithWorktree(t *testing.T) (repo *gitalypb.Repository, repoPath string, cleanup func()) { return cloneTestRepo(t, false) } -func cloneTestRepo(t *testing.T, bare bool) (repo *pb.Repository, repoPath string, cleanup func()) { +func cloneTestRepo(t *testing.T, bare bool) (repo *gitalypb.Repository, repoPath string, cleanup func()) { storagePath := GitlabTestStoragePath() repo, repoPath, relativePath := createRepo(t, storagePath) testRepo := TestRepository() diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/blob.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/blob.pb.go index 3aac60a59..ccfe493e9 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/blob.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/blob.pb.go @@ -2,7 +2,7 @@ // source: blob.proto /* -Package gitaly is a generated protocol buffer package. +Package gitalypb is a generated protocol buffer package. It is generated from these files: blob.proto @@ -299,7 +299,7 @@ It has these top-level messages: WikiGetFormattedDataRequest WikiGetFormattedDataResponse */ -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/commit.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/commit.pb.go index c12fd90f5..d77c150b3 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/commit.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/commit.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: commit.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/conflicts.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/conflicts.pb.go index 8fc147001..650971cc9 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/conflicts.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/conflicts.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: conflicts.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/deprecated-services.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/deprecated-services.pb.go index 7253e928f..411d34f10 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/deprecated-services.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/deprecated-services.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: deprecated-services.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/diff.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/diff.pb.go index 2ae92f49d..ddd573473 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/diff.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/diff.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: diff.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/namespace.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/namespace.pb.go index bc9c57561..3976a4ce9 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/namespace.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/namespace.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: namespace.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/notifications.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/notifications.pb.go index de7eac2e4..56918cd44 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/notifications.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/notifications.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: notifications.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/operations.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/operations.pb.go index 712129698..314d0191a 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/operations.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/operations.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: operations.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/ref.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/ref.pb.go index 913bfaafc..3b5182b06 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/ref.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/ref.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: ref.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/remote.pb.go index 2fb85dfe1..79183690a 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/remote.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/remote.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: remote.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/repository-service.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/repository-service.pb.go index ee11b3044..1898547be 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/repository-service.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/repository-service.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: repository-service.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/server.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/server.pb.go index cd85fc43e..1c488b564 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/server.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/server.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: server.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/shared.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/shared.pb.go index 5cb103119..654be4f93 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/shared.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/shared.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: shared.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" @@ -320,41 +320,41 @@ func init() { func init() { proto.RegisterFile("shared.proto", fileDescriptor12) } var fileDescriptor12 = []byte{ - // 568 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x5f, 0x6f, 0xd3, 0x3e, - 0x14, 0x55, 0xd2, 0xb4, 0x5b, 0x6f, 0xb3, 0x9f, 0x7e, 0x98, 0x3d, 0x44, 0x43, 0xd3, 0x4a, 0x78, - 0xd9, 0x03, 0xca, 0x50, 0x91, 0x78, 0x1f, 0x7f, 0x34, 0x8d, 0x07, 0x40, 0xde, 0xf6, 0x1c, 0xb9, - 0xcd, 0x9d, 0x6b, 0xe4, 0x34, 0x95, 0x7d, 0x33, 0xb1, 0x3d, 0xf1, 0x01, 0xf9, 0x1e, 0x7c, 0x0d, - 0x64, 0x3b, 0xe9, 0x06, 0x14, 0xc4, 0x9b, 0xef, 0xf1, 0xf1, 0xf5, 0x3d, 0x3e, 0xc7, 0x90, 0xda, - 0xa5, 0x30, 0x58, 0x15, 0x6b, 0xd3, 0x50, 0xc3, 0x46, 0x52, 0x91, 0xd0, 0xb7, 0x07, 0x47, 0xb2, - 0x69, 0xa4, 0xc6, 0x13, 0x8f, 0xce, 0xdb, 0xeb, 0x13, 0x52, 0x35, 0x5a, 0x12, 0xf5, 0x3a, 0x10, - 0xf3, 0xaf, 0x31, 0x00, 0xc7, 0x75, 0x63, 0x15, 0x35, 0xe6, 0x96, 0x3d, 0x85, 0xd4, 0x52, 0x63, - 0x84, 0xc4, 0x72, 0x25, 0x6a, 0xcc, 0xe2, 0x69, 0x74, 0x3c, 0xe6, 0x93, 0x0e, 0xfb, 0x20, 0x6a, - 0x64, 0xcf, 0x60, 0xcf, 0xa0, 0x16, 0xa4, 0x6e, 0xb0, 0x5c, 0x0b, 0x5a, 0x66, 0x03, 0xcf, 0x49, - 0x7b, 0xf0, 0x93, 0xa0, 0x25, 0x7b, 0x01, 0xfb, 0x52, 0x51, 0xd9, 0xcc, 0x3f, 0xe3, 0x82, 0xca, - 0x4a, 0x19, 0x5c, 0xb8, 0xfe, 0x59, 0xe2, 0xb9, 0x4c, 0x2a, 0xfa, 0xe8, 0xb7, 0xde, 0xf6, 0x3b, - 0xec, 0x0c, 0xa6, 0xee, 0x84, 0xd0, 0x84, 0x66, 0x25, 0x08, 0x7f, 0x3d, 0xab, 0xd0, 0x66, 0xc3, - 0xe9, 0xe0, 0x78, 0xcc, 0x0f, 0xa5, 0xa2, 0xd3, 0x9e, 0xf6, 0x73, 0x1b, 0x85, 0xd6, 0xcd, 0x27, - 0x75, 0x69, 0x36, 0x9a, 0xb2, 0x51, 0x98, 0x4f, 0xea, 0x7b, 0x9d, 0xef, 0x93, 0xdd, 0xe8, 0xff, - 0x98, 0x27, 0x6e, 0xfe, 0xfc, 0x7b, 0x04, 0xe3, 0x33, 0x45, 0x6f, 0x9a, 0xba, 0x56, 0xc4, 0xfe, - 0x83, 0x58, 0x55, 0x59, 0xe4, 0xcf, 0xc4, 0xaa, 0x62, 0x19, 0xec, 0xd8, 0xd6, 0x5f, 0xe2, 0x1f, - 0x23, 0xe5, 0x7d, 0xc9, 0x18, 0x24, 0xf3, 0xa6, 0xba, 0xf5, 0xfa, 0x53, 0xee, 0xd7, 0xec, 0x39, - 0x8c, 0x44, 0x4b, 0xcb, 0xc6, 0x78, 0xa5, 0x93, 0xd9, 0x7e, 0x11, 0x8c, 0x28, 0x42, 0xf7, 0x53, - 0xbf, 0xc7, 0x3b, 0x0e, 0x9b, 0xc1, 0x78, 0xe1, 0x71, 0x42, 0x93, 0x0d, 0xff, 0x72, 0xe0, 0x9e, - 0xc6, 0x0e, 0x01, 0xd6, 0xc2, 0xe0, 0x8a, 0x4a, 0x55, 0xd9, 0x6c, 0xe4, 0x5f, 0x64, 0x1c, 0x90, - 0xf3, 0xca, 0xb2, 0x27, 0x30, 0x76, 0x83, 0x94, 0x56, 0xdd, 0x61, 0xb6, 0x33, 0x8d, 0x8e, 0x07, - 0x7c, 0xd7, 0x01, 0x17, 0xea, 0x0e, 0xf3, 0x25, 0xa4, 0x0f, 0xdb, 0x3a, 0x05, 0xde, 0xe5, 0x28, - 0x28, 0x70, 0x6b, 0xb6, 0x0f, 0x43, 0xac, 0x85, 0xd2, 0x9d, 0xda, 0x50, 0xb0, 0x02, 0x92, 0x4a, - 0x10, 0x7a, 0xad, 0x93, 0xd9, 0x41, 0x11, 0x62, 0x55, 0xf4, 0xb1, 0x2a, 0x2e, 0xfb, 0x58, 0x71, - 0xcf, 0xcb, 0x73, 0x80, 0x77, 0x5f, 0x14, 0x5d, 0x90, 0xa0, 0xd6, 0xba, 0x9e, 0x37, 0x42, 0xb7, - 0xe1, 0xa2, 0x21, 0x0f, 0x45, 0x7e, 0x09, 0xa3, 0xd7, 0x46, 0xac, 0x16, 0xcb, 0xad, 0x73, 0xbc, - 0x82, 0x3d, 0x12, 0x46, 0x22, 0x95, 0x41, 0xbb, 0x9f, 0x67, 0x32, 0x7b, 0xd4, 0xbf, 0xcf, 0xc6, - 0x31, 0x9e, 0x06, 0x5e, 0xa8, 0xf2, 0x6f, 0x11, 0x0c, 0x2e, 0x85, 0xdc, 0xda, 0x33, 0x78, 0x1b, - 0x6f, 0xbc, 0xfd, 0xed, 0x8e, 0xc1, 0x3f, 0xdd, 0xe1, 0x32, 0x51, 0xa3, 0xb5, 0x42, 0xa2, 0xb7, - 0x39, 0xe5, 0x7d, 0xe9, 0xfe, 0x4f, 0xb7, 0x0c, 0x0e, 0x0c, 0xbd, 0x03, 0x93, 0x0e, 0x73, 0x26, - 0xb8, 0x88, 0x90, 0x90, 0x12, 0x8d, 0x0f, 0xe6, 0x1f, 0x23, 0x12, 0x38, 0xf9, 0x35, 0x24, 0x57, - 0x16, 0x0d, 0x7b, 0x0c, 0x43, 0xa9, 0xcb, 0x4d, 0x32, 0x13, 0xa9, 0xcf, 0xab, 0x8d, 0xc6, 0x78, - 0x9b, 0x7f, 0x83, 0x87, 0xfe, 0x1d, 0xc1, 0x44, 0xea, 0xb2, 0xb5, 0xee, 0xd3, 0xd4, 0xd8, 0x7d, - 0x43, 0x90, 0xfa, 0xaa, 0x43, 0xe6, 0x23, 0x6f, 0xe5, 0xcb, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xf1, 0xe6, 0xc7, 0x44, 0x47, 0x04, 0x00, 0x00, + // 576 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x6f, 0xd4, 0x3c, + 0x10, 0x55, 0xb2, 0xd9, 0x6d, 0x77, 0x36, 0xfd, 0xf4, 0x61, 0x7a, 0x88, 0x8a, 0xaa, 0x2e, 0xe1, + 0xd2, 0x03, 0x4a, 0xd1, 0x22, 0x71, 0x6f, 0x01, 0x55, 0xe5, 0x00, 0xc8, 0x6d, 0x2f, 0x5c, 0x22, + 0xef, 0x66, 0xea, 0x35, 0x72, 0x36, 0x2b, 0x7b, 0x52, 0xd1, 0x9e, 0xf8, 0x81, 0xfc, 0x0f, 0xfe, + 0x06, 0xb2, 0x9d, 0x6c, 0x0b, 0x14, 0xc4, 0xcd, 0xf3, 0xfc, 0x3c, 0x9e, 0xe7, 0xf7, 0x0c, 0xa9, + 0x5d, 0x0a, 0x83, 0x55, 0xb1, 0x36, 0x0d, 0x35, 0x6c, 0x24, 0x15, 0x09, 0x7d, 0xb3, 0x77, 0x20, + 0x9b, 0x46, 0x6a, 0x3c, 0xf2, 0xe8, 0xbc, 0xbd, 0x3a, 0x22, 0x55, 0xa3, 0x25, 0x51, 0xaf, 0x03, + 0x31, 0xff, 0x1a, 0x03, 0x70, 0x5c, 0x37, 0x56, 0x51, 0x63, 0x6e, 0xd8, 0x53, 0x48, 0x2d, 0x35, + 0x46, 0x48, 0x2c, 0x57, 0xa2, 0xc6, 0x2c, 0x9e, 0x46, 0x87, 0x63, 0x3e, 0xe9, 0xb0, 0xf7, 0xa2, + 0x46, 0xf6, 0x0c, 0x76, 0x0c, 0x6a, 0x41, 0xea, 0x1a, 0xcb, 0xb5, 0xa0, 0x65, 0x36, 0xf0, 0x9c, + 0xb4, 0x07, 0x3f, 0x0a, 0x5a, 0xb2, 0x17, 0xb0, 0x2b, 0x15, 0x95, 0xcd, 0xfc, 0x33, 0x2e, 0xa8, + 0xac, 0x94, 0xc1, 0x85, 0xeb, 0x9f, 0x25, 0x9e, 0xcb, 0xa4, 0xa2, 0x0f, 0x7e, 0xeb, 0x4d, 0xbf, + 0xc3, 0x4e, 0x61, 0xea, 0x4e, 0x08, 0x4d, 0x68, 0x56, 0x82, 0xf0, 0xd7, 0xb3, 0x0a, 0x6d, 0x36, + 0x9c, 0x0e, 0x0e, 0xc7, 0x7c, 0x5f, 0x2a, 0x3a, 0xee, 0x69, 0x3f, 0xb7, 0x51, 0x68, 0xdd, 0x7c, + 0x52, 0x97, 0x66, 0xa3, 0x29, 0x1b, 0x85, 0xf9, 0xa4, 0xbe, 0xd3, 0xf9, 0x2e, 0xd9, 0x8e, 0xfe, + 0x8f, 0x79, 0xe2, 0xe6, 0xcf, 0xbf, 0x47, 0x30, 0x3e, 0x55, 0xf4, 0xba, 0xa9, 0x6b, 0x45, 0xec, + 0x3f, 0x88, 0x55, 0x95, 0x45, 0xfe, 0x4c, 0xac, 0x2a, 0x96, 0xc1, 0x96, 0x6d, 0xfd, 0x25, 0xfe, + 0x31, 0x52, 0xde, 0x97, 0x8c, 0x41, 0x32, 0x6f, 0xaa, 0x1b, 0xaf, 0x3f, 0xe5, 0x7e, 0xcd, 0x9e, + 0xc3, 0x48, 0xb4, 0xb4, 0x6c, 0x8c, 0x57, 0x3a, 0x99, 0xed, 0x16, 0xc1, 0x88, 0x22, 0x74, 0x3f, + 0xf6, 0x7b, 0xbc, 0xe3, 0xb0, 0x19, 0x8c, 0x17, 0x1e, 0x27, 0x34, 0xd9, 0xf0, 0x2f, 0x07, 0xee, + 0x68, 0x6c, 0x1f, 0x60, 0x2d, 0x0c, 0xae, 0xa8, 0x54, 0x95, 0xcd, 0x46, 0xfe, 0x45, 0xc6, 0x01, + 0x39, 0xab, 0x2c, 0x7b, 0x02, 0x63, 0x37, 0x48, 0x69, 0xd5, 0x2d, 0x66, 0x5b, 0xd3, 0xe8, 0x70, + 0xc0, 0xb7, 0x1d, 0x70, 0xae, 0x6e, 0x31, 0x5f, 0x42, 0x7a, 0xbf, 0xad, 0x53, 0xe0, 0x5d, 0x8e, + 0x82, 0x02, 0xb7, 0x66, 0xbb, 0x30, 0xc4, 0x5a, 0x28, 0xdd, 0xa9, 0x0d, 0x05, 0x2b, 0x20, 0xa9, + 0x04, 0xa1, 0xd7, 0x3a, 0x99, 0xed, 0x15, 0x21, 0x56, 0x45, 0x1f, 0xab, 0xe2, 0xa2, 0x8f, 0x15, + 0xf7, 0xbc, 0x3c, 0x07, 0x78, 0xfb, 0x45, 0xd1, 0x39, 0x09, 0x6a, 0xad, 0xeb, 0x79, 0x2d, 0x74, + 0x1b, 0x2e, 0x1a, 0xf2, 0x50, 0xe4, 0x17, 0x30, 0x3a, 0x31, 0x62, 0xb5, 0x58, 0x3e, 0x38, 0xc7, + 0x2b, 0xd8, 0x21, 0x61, 0x24, 0x52, 0x19, 0xb4, 0xfb, 0x79, 0x26, 0xb3, 0x47, 0xfd, 0xfb, 0x6c, + 0x1c, 0xe3, 0x69, 0xe0, 0x85, 0x2a, 0xff, 0x16, 0xc1, 0xe0, 0x42, 0xc8, 0x07, 0x7b, 0x06, 0x6f, + 0xe3, 0x8d, 0xb7, 0xbf, 0xdd, 0x31, 0xf8, 0xa7, 0x3b, 0x5c, 0x26, 0x6a, 0xb4, 0x56, 0x48, 0xf4, + 0x36, 0xa7, 0xbc, 0x2f, 0xdd, 0xff, 0xe9, 0x96, 0xc1, 0x81, 0xa1, 0x77, 0x60, 0xd2, 0x61, 0xce, + 0x04, 0x17, 0x11, 0x12, 0x52, 0xa2, 0xf1, 0xc1, 0xfc, 0x63, 0x44, 0x02, 0x27, 0xbf, 0x82, 0xe4, + 0xd2, 0xa2, 0x61, 0x8f, 0x61, 0x28, 0x75, 0xb9, 0x49, 0x66, 0x22, 0xf5, 0x59, 0xb5, 0xd1, 0x18, + 0x3f, 0xe4, 0xdf, 0xe0, 0xbe, 0x7f, 0x07, 0x30, 0x91, 0xba, 0x6c, 0xad, 0xfb, 0x34, 0x35, 0x76, + 0xdf, 0x10, 0xa4, 0xbe, 0xec, 0x90, 0x13, 0xf8, 0xb4, 0x1d, 0xc6, 0x58, 0xcf, 0xe7, 0x23, 0x6f, + 0xeb, 0xcb, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xed, 0xe0, 0x22, 0x53, 0x04, 0x00, 0x00, } diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/smarthttp.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/smarthttp.pb.go index 11e99e303..819b50e14 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/smarthttp.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/smarthttp.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: smarthttp.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/ssh.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/ssh.pb.go index a4f2fe50e..ae3c952a9 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/ssh.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/ssh.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: ssh.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/storage.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/storage.pb.go index 71af4d1d1..bdaa741cf 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/storage.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/storage.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: storage.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/wiki.pb.go b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/wiki.pb.go index 49304408d..4dbaf5dab 100644 --- a/vendor/gitlab.com/gitlab-org/gitaly-proto/go/wiki.pb.go +++ b/vendor/gitlab.com/gitlab-org/gitaly-proto/go/gitalypb/wiki.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: wiki.proto -package gitaly +package gitalypb import proto "github.com/golang/protobuf/proto" import fmt "fmt" diff --git a/vendor/vendor.json b/vendor/vendor.json index 8b9aeeb1f..763d2f69c 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -201,12 +201,12 @@ "revisionTime": "2017-12-31T12:27:32Z" }, { - "checksumSHA1": "uLhcLmhcc35eZMhJTf5CXhjrRzw=", - "path": "gitlab.com/gitlab-org/gitaly-proto/go", - "revision": "566ea63b045ce9705dbf21b9ca0ed1f1eb989bab", - "revisionTime": "2018-09-12T14:37:39Z", - "version": "v0.118.1", - "versionExact": "v0.118.1" + "checksumSHA1": "KtPXpPuSNYehoMJYatJSK4j94OI=", + "path": "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb", + "revision": "38222414e1f612f789775f75d3228213fcaed7bf", + "revisionTime": "2018-10-04T06:49:09Z", + "version": "v0.119.0", + "versionExact": "v0.119.0" }, { "checksumSHA1": "nqWNlnMmVpt628zzvyo6Yv2CX5Q=", |