diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2020-01-09 22:20:59 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2020-01-09 22:20:59 +0300 |
commit | bf9f52bc5d55f43486000f70f4aeefce809d6771 (patch) | |
tree | 5e5f784e3b2dec563f867e7624924e6d468c66a2 /internal | |
parent | a05e38b4e0bdf3f3482e341c242f7c3fb90ee7b7 (diff) |
Auto-format whitespace between imports
Diffstat (limited to 'internal')
45 files changed, 132 insertions, 100 deletions
diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index 78cba7ac9..15c43fba5 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -13,9 +13,8 @@ import ( "testing" "time" - "gitlab.com/gitlab-org/gitaly/internal/config" - "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/internal/config" ) var testConfigGracefulRestartTimeout = 2 * time.Second diff --git a/internal/cmd/bracefmt/brace.go b/internal/cmd/gitalyfmt/format.go index e6f55d1d4..1c3b2377d 100644 --- a/internal/cmd/bracefmt/brace.go +++ b/internal/cmd/gitalyfmt/format.go @@ -2,8 +2,10 @@ package main import ( "bytes" + "errors" "go/scanner" "go/token" + "regexp" ) type editCommand int @@ -19,20 +21,26 @@ type edit struct { cmd editCommand } -func braceFmt(src []byte) []byte { +var ( + nonStdlibImportRegex = regexp.MustCompile(`^[^/]+\..*/`) +) + +func format(src []byte) ([]byte, error) { var s scanner.Scanner fset := token.NewFileSet() file := fset.AddFile("", fset.Base(), len(src)) s.Init(file, src, nil, scanner.ScanComments) var ( - edits []edit - lastNonEmptyLine, lastLBraceLine int - lastOuterRBraceLine = -1 + edits []edit + lastNonEmptyLine, lastLBraceLine int + lastOuterRBraceLine = -1 + importLine, lastNonStdlibImportLine int + inImports bool ) for { - pos, tok, _ := s.Scan() + pos, tok, lit := s.Scan() if tok == token.EOF { break } @@ -42,6 +50,26 @@ func braceFmt(src []byte) []byte { var nextEdit edit switch tok { + case token.IMPORT: + importLine = currentLine + case token.LPAREN: + if currentLine == importLine { + inImports = true + } + case token.RPAREN: + inImports = false + case token.STRING: + if inImports { + if nonStdlibImportRegex.MatchString(lit) { + if currentLine-lastNonStdlibImportLine > 1 && lastNonStdlibImportLine > 0 { + nextEdit = edit{line: currentLine - 1, cmd: removeLine} + } + lastNonStdlibImportLine = currentLine + } else if lastNonStdlibImportLine > 0 { + // It would be nicer to fix this automatically, but how? + return nil, errors.New("stdlib import after non-stdlib import is not allowed") + } + } case token.RBRACE: if currentLine-lastNonEmptyLine > 1 { // ......foo @@ -101,5 +129,5 @@ func braceFmt(src []byte) []byte { } } - return bytes.Join(srcLines, []byte("\n")) + return bytes.Join(srcLines, []byte("\n")), nil } diff --git a/internal/cmd/bracefmt/brace_test.go b/internal/cmd/gitalyfmt/format_test.go index b3de996dd..4dae5ea83 100644 --- a/internal/cmd/bracefmt/brace_test.go +++ b/internal/cmd/gitalyfmt/format_test.go @@ -6,12 +6,13 @@ import ( "github.com/stretchr/testify/require" ) -func TestBraceFmt(t *testing.T) { +func TestFormat(t *testing.T) { testCases := []struct { desc string in string out string unchanged bool + fail bool }{ { desc: "empty lines inside braces", @@ -114,11 +115,60 @@ func foo() { `, unchanged: true, }, + { + desc: "empty lines between non-stdlib imports", + in: `package main + +import ( + "net/http" + + "example.com/foo" + + bar "example.com/bar" +) + +func main() {} +`, + out: `package main + +import ( + "net/http" + + "example.com/foo" + bar "example.com/bar" +) + +func main() {} +`, + }, + { + desc: "alternating stdlib and non stdlib", + in: `package main + +import ( + "net/http" + + "example.com/foo" + + "io" +) + +func main() {} +`, + fail: true, + }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - out := braceFmt([]byte(tc.in)) + out, err := format([]byte(tc.in)) + + if tc.fail { + require.Error(t, err, "expect format error") + return + } + + require.NoError(t, err, "format error") if tc.unchanged { require.Equal(t, tc.in, string(out)) diff --git a/internal/cmd/bracefmt/main.go b/internal/cmd/gitalyfmt/main.go index ffa4b05d9..bbc6b2d7f 100644 --- a/internal/cmd/bracefmt/main.go +++ b/internal/cmd/gitalyfmt/main.go @@ -9,7 +9,7 @@ import ( ) const ( - progName = "bracefmt" + progName = "gitalyfmt" ) var ( @@ -25,7 +25,7 @@ func main() { } if err := _main(flag.Args()); err != nil { - fmt.Fprintf(os.Stderr, "%s: fatal: %v", progName, err) + fmt.Fprintf(os.Stderr, "%s: fatal: %v\n", progName, err) os.Exit(1) } } @@ -42,7 +42,10 @@ func _main(args []string) error { return err } - dst := braceFmt(src) + dst, err := format(src) + if err != nil { + return fmt.Errorf("%s: %v", f, err) + } if bytes.Equal(src, dst) { continue } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index abe48934c..cacde0033 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -14,7 +14,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config/sentry" ) diff --git a/internal/git/log/tag_test.go b/internal/git/log/tag_test.go index 92750d693..2aadb8511 100644 --- a/internal/git/log/tag_test.go +++ b/internal/git/log/tag_test.go @@ -6,11 +6,10 @@ import ( "strings" "testing" - "gitlab.com/gitlab-org/gitaly/internal/git/catfile" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/internal/git/catfile" + "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) diff --git a/internal/git/objectpool/link.go b/internal/git/objectpool/link.go index 9f062cb0c..534847d10 100644 --- a/internal/git/objectpool/link.go +++ b/internal/git/objectpool/link.go @@ -10,10 +10,9 @@ import ( "path/filepath" "strings" + "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/remote" "gitlab.com/gitlab-org/gitaly/internal/git/repository" - - "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) diff --git a/internal/git/protocol.go b/internal/git/protocol.go index 922238d50..ac86873b8 100644 --- a/internal/git/protocol.go +++ b/internal/git/protocol.go @@ -7,7 +7,6 @@ import ( grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" "github.com/prometheus/client_golang/prometheus" - "gitlab.com/gitlab-org/gitaly/internal/config" ) diff --git a/internal/git/protocol_test.go b/internal/git/protocol_test.go index d3d430b95..925a4ff74 100644 --- a/internal/git/protocol_test.go +++ b/internal/git/protocol_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config" ) diff --git a/internal/git/remote/remote_test.go b/internal/git/remote/remote_test.go index af4c56a9e..c695bd041 100644 --- a/internal/git/remote/remote_test.go +++ b/internal/git/remote/remote_test.go @@ -3,9 +3,8 @@ package remote import ( "testing" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go index f89f590ca..ceb581a1f 100644 --- a/internal/git/updateref/updateref_test.go +++ b/internal/git/updateref/updateref_test.go @@ -7,10 +7,9 @@ import ( "testing" "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" + "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) func setup(t *testing.T) (context.Context, *gitalypb.Repository, string, func()) { diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go index 1d1d51a6f..97be5c9e1 100644 --- a/internal/praefect/config/config.go +++ b/internal/praefect/config/config.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/BurntSushi/toml" - "gitlab.com/gitlab-org/gitaly/internal/config/auth" "gitlab.com/gitlab-org/gitaly/internal/config/log" "gitlab.com/gitlab-org/gitaly/internal/config/prometheus" diff --git a/internal/praefect/datastore/db.go b/internal/praefect/datastore/db.go index 2771326f6..2a0fa1cfd 100644 --- a/internal/praefect/datastore/db.go +++ b/internal/praefect/datastore/db.go @@ -8,7 +8,6 @@ import ( // Blank import to enable integration of github.com/lib/pq into database/sql _ "github.com/lib/pq" - "gitlab.com/gitlab-org/gitaly/internal/praefect/config" ) diff --git a/internal/praefect/grpc-proxy/proxy/handler_test.go b/internal/praefect/grpc-proxy/proxy/handler_test.go index fe0133a34..629d153c9 100644 --- a/internal/praefect/grpc-proxy/proxy/handler_test.go +++ b/internal/praefect/grpc-proxy/proxy/handler_test.go @@ -8,6 +8,7 @@ package proxy_test import ( + "fmt" "io" "log" "net" @@ -20,15 +21,12 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/proxy" + pb "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/testdata" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" - - "fmt" - - pb "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/testdata" ) const ( diff --git a/internal/praefect/grpc-proxy/proxy/helper_test.go b/internal/praefect/grpc-proxy/proxy/helper_test.go index 7502fc271..64fea0493 100644 --- a/internal/praefect/grpc-proxy/proxy/helper_test.go +++ b/internal/praefect/grpc-proxy/proxy/helper_test.go @@ -6,10 +6,9 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/proxy" + testservice "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/testdata" "golang.org/x/net/context" "google.golang.org/grpc" - - testservice "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/testdata" ) func newListener(tb testing.TB) net.Listener { diff --git a/internal/praefect/grpc-proxy/proxy/peeker_test.go b/internal/praefect/grpc-proxy/proxy/peeker_test.go index e6de9c884..31422cf39 100644 --- a/internal/praefect/grpc-proxy/proxy/peeker_test.go +++ b/internal/praefect/grpc-proxy/proxy/peeker_test.go @@ -6,12 +6,11 @@ import ( "time" "github.com/golang/protobuf/proto" - "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/proxy" - "golang.org/x/net/context" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/proxy" testservice "gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/testdata" + "golang.org/x/net/context" ) // TestStreamPeeking demonstrates that a director function is able to peek diff --git a/internal/praefect/replicator.go b/internal/praefect/replicator.go index 03b76ffa9..7061e2f6b 100644 --- a/internal/praefect/replicator.go +++ b/internal/praefect/replicator.go @@ -5,13 +5,12 @@ import ( "fmt" "time" - "gitlab.com/gitlab-org/gitaly/internal/praefect/metrics" - "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/praefect/conn" "gitlab.com/gitlab-org/gitaly/internal/praefect/datastore" + "gitlab.com/gitlab-org/gitaly/internal/praefect/metrics" "gitlab.com/gitlab-org/gitaly/internal/praefect/models" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "golang.org/x/sync/errgroup" diff --git a/internal/praefect/service/server/info.go b/internal/praefect/service/server/info.go index bcda4e0de..f960a9ea5 100644 --- a/internal/praefect/service/server/info.go +++ b/internal/praefect/service/server/info.go @@ -5,11 +5,10 @@ import ( "sync" grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - "golang.org/x/sync/errgroup" - "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/praefect/models" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "golang.org/x/sync/errgroup" ) // ServerInfo sends ServerInfoRequest to all of a praefect server's internal gitaly nodes and aggregates the results into diff --git a/internal/safe/file_writer_test.go b/internal/safe/file_writer_test.go index ff64dd9e1..08b498f0b 100644 --- a/internal/safe/file_writer_test.go +++ b/internal/safe/file_writer_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/safe" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) diff --git a/internal/service/cleanup/apply_bfg_object_map_stream.go b/internal/service/cleanup/apply_bfg_object_map_stream.go index b7a07fa9a..e2276a434 100644 --- a/internal/service/cleanup/apply_bfg_object_map_stream.go +++ b/internal/service/cleanup/apply_bfg_object_map_stream.go @@ -4,12 +4,11 @@ import ( "fmt" "io" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" "gitlab.com/gitlab-org/gitaly/internal/service/cleanup/internalrefs" "gitlab.com/gitlab-org/gitaly/internal/service/cleanup/notifier" + "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" ) diff --git a/internal/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/service/cleanup/apply_bfg_object_map_stream_test.go index e226978ea..9eb19da78 100644 --- a/internal/service/cleanup/apply_bfg_object_map_stream_test.go +++ b/internal/service/cleanup/apply_bfg_object_map_stream_test.go @@ -9,12 +9,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "google.golang.org/grpc/codes" - "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "google.golang.org/grpc/codes" ) func TestApplyBfgObjectMapStreamSuccess(t *testing.T) { diff --git a/internal/service/cleanup/internalrefs/cleaner.go b/internal/service/cleanup/internalrefs/cleaner.go index db6e45ac3..6efb4d618 100644 --- a/internal/service/cleanup/internalrefs/cleaner.go +++ b/internal/service/cleanup/internalrefs/cleaner.go @@ -9,10 +9,9 @@ import ( grpc_logrus "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/git" "gitlab.com/gitlab-org/gitaly/internal/git/updateref" + "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) // Only references in these namespaces are cleaned up diff --git a/internal/service/cleanup/notifier/notifier.go b/internal/service/cleanup/notifier/notifier.go index 631d14ad9..a0d66ccba 100644 --- a/internal/service/cleanup/notifier/notifier.go +++ b/internal/service/cleanup/notifier/notifier.go @@ -5,7 +5,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) diff --git a/internal/service/cleanup/testhelper_test.go b/internal/service/cleanup/testhelper_test.go index ed4d2ec57..1ad6230f2 100644 --- a/internal/service/cleanup/testhelper_test.go +++ b/internal/service/cleanup/testhelper_test.go @@ -4,11 +4,10 @@ import ( "net" "testing" + "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc" "google.golang.org/grpc/reflection" - - "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) func runCleanupServiceServer(t *testing.T) (*grpc.Server, string) { diff --git a/internal/service/commit/count_diverging_commits.go b/internal/service/commit/count_diverging_commits.go index 9381c9a5c..1593d8b57 100644 --- a/internal/service/commit/count_diverging_commits.go +++ b/internal/service/commit/count_diverging_commits.go @@ -8,9 +8,8 @@ import ( "strconv" "strings" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/internal/git" + "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) diff --git a/internal/service/commit/count_diverging_commits_test.go b/internal/service/commit/count_diverging_commits_test.go index 0343b52a2..684a6da0e 100644 --- a/internal/service/commit/count_diverging_commits_test.go +++ b/internal/service/commit/count_diverging_commits_test.go @@ -6,11 +6,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "golang.org/x/net/context" "google.golang.org/grpc/codes" - - "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) func createRepoWithDivergentBranches(t *testing.T, leftCommits, rightCommits int, leftBranchName, rightBranchName string) (*gitalypb.Repository, func()) { diff --git a/internal/service/commit/find_commit.go b/internal/service/commit/find_commit.go index 31f31e935..ca2cf7ca1 100644 --- a/internal/service/commit/find_commit.go +++ b/internal/service/commit/find_commit.go @@ -3,10 +3,9 @@ package commit import ( "context" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/log" + "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) diff --git a/internal/service/commit/list_commits_by_oid.go b/internal/service/commit/list_commits_by_oid.go index 614626055..9d024566d 100644 --- a/internal/service/commit/list_commits_by_oid.go +++ b/internal/service/commit/list_commits_by_oid.go @@ -1,12 +1,11 @@ package commit import ( + "github.com/prometheus/client_golang/prometheus" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - - "github.com/prometheus/client_golang/prometheus" ) var ( diff --git a/internal/service/hooks/post_receive.go b/internal/service/hooks/post_receive.go index bfe6e628a..ae65df781 100644 --- a/internal/service/hooks/post_receive.go +++ b/internal/service/hooks/post_receive.go @@ -4,10 +4,9 @@ import ( "errors" "os/exec" - "gitlab.com/gitlab-org/gitaly/streamio" - "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "gitlab.com/gitlab-org/gitaly/streamio" ) func (s *server) PostReceiveHook(stream gitalypb.HookService_PostReceiveHookServer) error { diff --git a/internal/service/hooks/post_receive_test.go b/internal/service/hooks/post_receive_test.go index bf9adf0fa..32efe0f43 100644 --- a/internal/service/hooks/post_receive_test.go +++ b/internal/service/hooks/post_receive_test.go @@ -7,16 +7,13 @@ import ( "path/filepath" "testing" - "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "github.com/stretchr/testify/assert" - "gitlab.com/gitlab-org/gitaly/streamio" - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config" + "gitlab.com/gitlab-org/gitaly/internal/helper/text" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" ) diff --git a/internal/service/hooks/pre_receive.go b/internal/service/hooks/pre_receive.go index 63ff2db90..eaa36ad3f 100644 --- a/internal/service/hooks/pre_receive.go +++ b/internal/service/hooks/pre_receive.go @@ -6,12 +6,11 @@ import ( "os/exec" "path/filepath" - "gitlab.com/gitlab-org/gitaly/streamio" - "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/gitlabshell" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "gitlab.com/gitlab-org/gitaly/streamio" ) type hookRequest interface { diff --git a/internal/service/hooks/pre_receive_test.go b/internal/service/hooks/pre_receive_test.go index 52ce8ec7b..d3f770e85 100644 --- a/internal/service/hooks/pre_receive_test.go +++ b/internal/service/hooks/pre_receive_test.go @@ -7,17 +7,13 @@ import ( "path/filepath" "testing" - "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "github.com/stretchr/testify/assert" - - "gitlab.com/gitlab-org/gitaly/streamio" - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config" + "gitlab.com/gitlab-org/gitaly/internal/helper/text" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "gitlab.com/gitlab-org/gitaly/streamio" "google.golang.org/grpc/codes" ) diff --git a/internal/service/hooks/update.go b/internal/service/hooks/update.go index 6cfad6093..6f246e207 100644 --- a/internal/service/hooks/update.go +++ b/internal/service/hooks/update.go @@ -4,10 +4,9 @@ import ( "errors" "os/exec" - "gitlab.com/gitlab-org/gitaly/streamio" - "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "gitlab.com/gitlab-org/gitaly/streamio" ) func (s *server) UpdateHook(in *gitalypb.UpdateHookRequest, stream gitalypb.HookService_UpdateHookServer) error { diff --git a/internal/service/hooks/update_test.go b/internal/service/hooks/update_test.go index 07b64a28c..3f68603dd 100644 --- a/internal/service/hooks/update_test.go +++ b/internal/service/hooks/update_test.go @@ -8,11 +8,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config" + "gitlab.com/gitlab-org/gitaly/internal/helper/text" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" diff --git a/internal/service/objectpool/fetch_into_object_pool.go b/internal/service/objectpool/fetch_into_object_pool.go index 206783062..2e50e81f7 100644 --- a/internal/service/objectpool/fetch_into_object_pool.go +++ b/internal/service/objectpool/fetch_into_object_pool.go @@ -7,7 +7,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git/objectpool" "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) diff --git a/internal/service/objectpool/fetch_into_object_pool_test.go b/internal/service/objectpool/fetch_into_object_pool_test.go index 16a40d32b..b3ae1c97e 100644 --- a/internal/service/objectpool/fetch_into_object_pool_test.go +++ b/internal/service/objectpool/fetch_into_object_pool_test.go @@ -5,13 +5,12 @@ import ( "path/filepath" "testing" - "google.golang.org/grpc/codes" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/objectpool" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "google.golang.org/grpc/codes" ) func TestFetchIntoObjectPool_Success(t *testing.T) { diff --git a/internal/service/objectpool/link_test.go b/internal/service/objectpool/link_test.go index f062f427c..9265eaf08 100644 --- a/internal/service/objectpool/link_test.go +++ b/internal/service/objectpool/link_test.go @@ -5,12 +5,11 @@ import ( "path/filepath" "testing" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/git/objectpool" + "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" diff --git a/internal/service/remote/remotes.go b/internal/service/remote/remotes.go index fe9432ffd..e4a0893e2 100644 --- a/internal/service/remote/remotes.go +++ b/internal/service/remote/remotes.go @@ -8,11 +8,10 @@ import ( "io/ioutil" "strings" - "gitlab.com/gitlab-org/gitaly/internal/git/remote" - "gitlab.com/gitlab-org/gitaly/internal/rubyserver" - "gitlab.com/gitlab-org/gitaly/internal/git" + "gitlab.com/gitlab-org/gitaly/internal/git/remote" "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" + "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/internal/service/repository/cleanup.go b/internal/service/repository/cleanup.go index 141a61507..038925854 100644 --- a/internal/service/repository/cleanup.go +++ b/internal/service/repository/cleanup.go @@ -11,7 +11,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) diff --git a/internal/service/repository/clone_from_pool_internal_test.go b/internal/service/repository/clone_from_pool_internal_test.go index 7d4fbc649..b31b8c428 100644 --- a/internal/service/repository/clone_from_pool_internal_test.go +++ b/internal/service/repository/clone_from_pool_internal_test.go @@ -8,13 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "google.golang.org/grpc/metadata" - "gitlab.com/gitlab-org/gitaly/internal/git/objectpool" "gitlab.com/gitlab-org/gitaly/internal/helper/text" "gitlab.com/gitlab-org/gitaly/internal/service/repository" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "google.golang.org/grpc/metadata" ) func NewTestObjectPool(t *testing.T) (*objectpool.ObjectPool, *gitalypb.Repository) { diff --git a/internal/service/repository/clone_from_pool_test.go b/internal/service/repository/clone_from_pool_test.go index 86731b7af..e51bffad0 100644 --- a/internal/service/repository/clone_from_pool_test.go +++ b/internal/service/repository/clone_from_pool_test.go @@ -6,12 +6,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "google.golang.org/grpc/metadata" - "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/service/repository" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "google.golang.org/grpc/metadata" ) func TestCloneFromPoolHTTP(t *testing.T) { diff --git a/internal/service/repository/replicate.go b/internal/service/repository/replicate.go index 9cc5eae01..2f0069f0a 100644 --- a/internal/service/repository/replicate.go +++ b/internal/service/repository/replicate.go @@ -8,11 +8,10 @@ import ( "os" "path/filepath" - "gitlab.com/gitlab-org/gitaly/internal/safe" - "gitlab.com/gitlab-org/gitaly/client" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/helper" + "gitlab.com/gitlab-org/gitaly/internal/safe" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" "golang.org/x/sync/errgroup" diff --git a/internal/service/server/disk_stats_test.go b/internal/service/server/disk_stats_test.go index 4ad8966c3..2ba75bbd5 100644 --- a/internal/service/server/disk_stats_test.go +++ b/internal/service/server/disk_stats_test.go @@ -4,12 +4,11 @@ import ( "math" "testing" - "golang.org/x/sys/unix" - "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + "golang.org/x/sys/unix" ) func TestStorageDiskStatistics(t *testing.T) { diff --git a/internal/service/server/info.go b/internal/service/server/info.go index ce674b13c..636a302ba 100644 --- a/internal/service/server/info.go +++ b/internal/service/server/info.go @@ -7,14 +7,13 @@ import ( "path" grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - "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/helper" "gitlab.com/gitlab-org/gitaly/internal/helper/fstype" "gitlab.com/gitlab-org/gitaly/internal/storage" "gitlab.com/gitlab-org/gitaly/internal/version" + "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) func (s *server) ServerInfo(ctx context.Context, in *gitalypb.ServerInfoRequest) (*gitalypb.ServerInfoResponse, error) { diff --git a/internal/service/ssh/receive_pack.go b/internal/service/ssh/receive_pack.go index 33b4fa7ae..fdb87beb0 100644 --- a/internal/service/ssh/receive_pack.go +++ b/internal/service/ssh/receive_pack.go @@ -4,13 +4,12 @@ import ( "fmt" "strconv" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" - grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/helper" + "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" ) |