diff options
author | John Cai <jcai@gitlab.com> | 2020-06-17 20:34:58 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2020-06-17 20:34:58 +0300 |
commit | 3e8b412c9840924faf2e58ec8bacea45cb72efc2 (patch) | |
tree | f634a00d810ee277483f5914e4d3a8f47e8843a2 | |
parent | 15031e59ac28fe540191d450feaf0684688c0b28 (diff) |
Turn go update hook to default onjc-turn-go-pre-receive-default-on
-rw-r--r-- | cmd/gitaly-hooks/hooks_test.go | 29 | ||||
-rw-r--r-- | internal/git/receivepack.go | 2 | ||||
-rw-r--r-- | internal/service/operations/apply_patch_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/branches_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/cherry_pick_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/commit_files_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/merge_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/rebase_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/revert_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/squash_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/submodules_test.go | 10 | ||||
-rw-r--r-- | internal/service/operations/tags_test.go | 31 | ||||
-rw-r--r-- | internal/service/operations/update_branches_test.go | 19 |
13 files changed, 24 insertions, 147 deletions
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go index f4f1ed5a6..6a2a9cdbd 100644 --- a/cmd/gitaly-hooks/hooks_test.go +++ b/cmd/gitaly-hooks/hooks_test.go @@ -220,26 +220,15 @@ func TestHooksUpdate(t *testing.T) { socket, stop := runHookServiceServer(t, token) defer stop() - featureSets, err := testhelper.NewFeatureSets([]string{featureflag.GoUpdateHook}) - require.NoError(t, err) - - for _, featureSet := range featureSets { - t.Run(fmt.Sprintf("enabled features: %v", featureSet), func(t *testing.T) { - if featureSet.IsEnabled("use_gitaly_gitlabshell_config") { - config.Config.Hooks.CustomHooksDir = customHooksDir - } - - testHooksUpdate(t, tempGitlabShellDir, socket, token, testhelper.GlHookValues{ - GLID: glID, - GLUsername: glUsername, - GLRepo: glRepository, - GLProtocol: glProtocol, - }, featureSet) - }) - } + testHooksUpdate(t, tempGitlabShellDir, socket, token, testhelper.GlHookValues{ + GLID: glID, + GLUsername: glUsername, + GLRepo: glRepository, + GLProtocol: glProtocol, + }) } -func testHooksUpdate(t *testing.T, gitlabShellDir, socket, token string, glValues testhelper.GlHookValues, features testhelper.FeatureSet) { +func testHooksUpdate(t *testing.T, gitlabShellDir, socket, token string, glValues testhelper.GlHookValues) { defer func(cfg config.Cfg) { config.Config = cfg }(config.Config) @@ -273,9 +262,7 @@ open('%s', 'w') { |f| f.puts(JSON.dump(ARGV)) } var stdout, stderr bytes.Buffer - if features.IsEnabled(featureflag.GoUpdateHook) { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=true", featureflag.GoUpdateHookEnvVar)) - } + cmd.Env = append(cmd.Env, fmt.Sprintf("%s=true", featureflag.GoUpdateHookEnvVar)) cmd.Stdout = &stdout cmd.Stderr = &stderr cmd.Dir = testRepoPath diff --git a/internal/git/receivepack.go b/internal/git/receivepack.go index 6e27a5b58..ab95a4de7 100644 --- a/internal/git/receivepack.go +++ b/internal/git/receivepack.go @@ -46,7 +46,7 @@ func ReceivePackHookEnv(ctx context.Context, req ReceivePackRequest) ([]string, fmt.Sprintf("GITALY_SOCKET=" + config.GitalyInternalSocketPath()), fmt.Sprintf("GITALY_REPO=%s", repo), fmt.Sprintf("GITALY_TOKEN=%s", config.Config.Auth.Token), - fmt.Sprintf("%s=%s", featureflag.GoUpdateHookEnvVar, strconv.FormatBool(featureflag.IsEnabled(ctx, featureflag.GoUpdateHook))), + fmt.Sprintf("%s=%s", featureflag.GoUpdateHookEnvVar, strconv.FormatBool(!featureflag.IsDisabled(ctx, featureflag.GoUpdateHook))), // default on fmt.Sprintf("%s=%s", featureflag.GoPreReceiveHookEnvVar, strconv.FormatBool(featureflag.IsEnabled(ctx, featureflag.GoPreReceiveHook))), }, gitlabshellEnv...) diff --git a/internal/service/operations/apply_patch_test.go b/internal/service/operations/apply_patch_test.go index 309bc2b0d..1b24b2391 100644 --- a/internal/service/operations/apply_patch_test.go +++ b/internal/service/operations/apply_patch_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" @@ -20,17 +19,10 @@ import ( ) func TestSuccessfulUserApplyPatch(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulUserApplyPatch(t, ctx) - }) - } + testSuccessfulUserApplyPatch(t, ctx) } func testSuccessfulUserApplyPatch(t *testing.T, ctx context.Context) { diff --git a/internal/service/operations/branches_test.go b/internal/service/operations/branches_test.go index 0d8b94ccf..e290e3948 100644 --- a/internal/service/operations/branches_test.go +++ b/internal/service/operations/branches_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -76,17 +75,10 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) { } func TestSuccessfulGitHooksForUserCreateBranchRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulGitHooksForUserCreateBranchRequest(t, ctx) - }) - } + testSuccessfulGitHooksForUserCreateBranchRequest(t, ctx) } func testSuccessfulGitHooksForUserCreateBranchRequest(t *testing.T, ctx context.Context) { diff --git a/internal/service/operations/cherry_pick_test.go b/internal/service/operations/cherry_pick_test.go index 3a30688b7..6bbb68acb 100644 --- a/internal/service/operations/cherry_pick_test.go +++ b/internal/service/operations/cherry_pick_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -117,17 +116,10 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) { } func TestSuccessfulGitHooksForUserCherryPickRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulGitHooksForUserCherryPickRequest(t, ctx) - }) - } + testSuccessfulGitHooksForUserCherryPickRequest(t, ctx) } func testSuccessfulGitHooksForUserCherryPickRequest(t *testing.T, ctxOuter context.Context) { diff --git a/internal/service/operations/commit_files_test.go b/internal/service/operations/commit_files_test.go index 2aceef1ba..391ba9c24 100644 --- a/internal/service/operations/commit_files_test.go +++ b/internal/service/operations/commit_files_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -127,17 +126,10 @@ func testSuccessfulUserCommitFilesRequest(t *testing.T, ctxWithFeatureFlags cont } func TestSuccessfulUserCommitFilesRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulUserCommitFilesRequest(t, ctx) - }) - } + testSuccessfulUserCommitFilesRequest(t, ctx) } func TestSuccessfulUserCommitFilesRequestMove(t *testing.T) { diff --git a/internal/service/operations/merge_test.go b/internal/service/operations/merge_test.go index bb5ef67aa..cd3007390 100644 --- a/internal/service/operations/merge_test.go +++ b/internal/service/operations/merge_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -25,17 +24,10 @@ var ( ) func TestSuccessfulMerge(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulMerge(t, ctx) - }) - } + testSuccessfulMerge(t, ctx) } func testSuccessfulMerge(t *testing.T, ctx context.Context) { diff --git a/internal/service/operations/rebase_test.go b/internal/service/operations/rebase_test.go index 7df1cf618..a7d0aeb46 100644 --- a/internal/service/operations/rebase_test.go +++ b/internal/service/operations/rebase_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/rubyserver" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" @@ -24,8 +23,6 @@ var ( ) func TestSuccessfulUserRebaseConfirmableRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() @@ -41,12 +38,7 @@ func TestSuccessfulUserRebaseConfirmableRequest(t *testing.T) { serverSocketPath, stop := runOperationServiceServerWithRubyServer(t, &ruby) defer stop() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulUserRebaseConfirmableRequest(t, ctx, serverSocketPath, pushOptions) - }) - } + testSuccessfulUserRebaseConfirmableRequest(t, ctx, serverSocketPath, pushOptions) } func testSuccessfulUserRebaseConfirmableRequest(t *testing.T, ctxOuter context.Context, serverSocketPath string, pushOptions []string) { diff --git a/internal/service/operations/revert_test.go b/internal/service/operations/revert_test.go index a910bc25d..392255087 100644 --- a/internal/service/operations/revert_test.go +++ b/internal/service/operations/revert_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -117,17 +116,10 @@ func TestSuccessfulUserRevertRequest(t *testing.T) { } func TestSuccessfulGitHooksForUserRevertRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulGitHooksForUserRevertRequest(t, ctx) - }) - } + testSuccessfulGitHooksForUserRevertRequest(t, ctx) } func testSuccessfulGitHooksForUserRevertRequest(t *testing.T, ctxOuter context.Context) { diff --git a/internal/service/operations/squash_test.go b/internal/service/operations/squash_test.go index 6a363ec9a..7164f8dc5 100644 --- a/internal/service/operations/squash_test.go +++ b/internal/service/operations/squash_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -29,17 +28,10 @@ var ( ) func TestSuccessfulUserSquashRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulUserSquashRequest(t, ctx) - }) - } + testSuccessfulUserSquashRequest(t, ctx) } func testSuccessfulUserSquashRequest(t *testing.T, ctx context.Context) { diff --git a/internal/service/operations/submodules_test.go b/internal/service/operations/submodules_test.go index b59deb76d..e3de793b0 100644 --- a/internal/service/operations/submodules_test.go +++ b/internal/service/operations/submodules_test.go @@ -9,24 +9,16 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/git/lstree" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" ) func TestSuccessfulUserUpdateSubmoduleRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulUserUpdateSubmoduleRequest(t, ctx) - }) - } + testSuccessfulUserUpdateSubmoduleRequest(t, ctx) } func testSuccessfulUserUpdateSubmoduleRequest(t *testing.T, ctx context.Context) { diff --git a/internal/service/operations/tags_test.go b/internal/service/operations/tags_test.go index 201eda9b3..8e8946608 100644 --- a/internal/service/operations/tags_test.go +++ b/internal/service/operations/tags_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/text" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -50,17 +49,10 @@ func TestSuccessfulUserDeleteTagRequest(t *testing.T) { } func TestSuccessfulGitHooksForUserDeleteTagRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulGitHooksForUserDeleteTagRequest(t, ctx) - }) - } + testSuccessfulGitHooksForUserDeleteTagRequest(t, ctx) } func testSuccessfulGitHooksForUserDeleteTagRequest(t *testing.T, ctx context.Context) { @@ -195,17 +187,9 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) { } func TestSuccessfulGitHooksForUserCreateTagRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) - ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulGitHooksForUserCreateTagRequest(t, ctx) - }) - } + testSuccessfulGitHooksForUserCreateTagRequest(t, ctx) } func testSuccessfulGitHooksForUserCreateTagRequest(t *testing.T, ctx context.Context) { @@ -298,17 +282,10 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) { } func TestFailedUserDeleteTagDueToHooks(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) - ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testFailedUserDeleteTagDueToHooks(t, ctx) - }) - } + + testFailedUserDeleteTagDueToHooks(t, ctx) } func testFailedUserDeleteTagDueToHooks(t *testing.T, ctx context.Context) { diff --git a/internal/service/operations/update_branches_test.go b/internal/service/operations/update_branches_test.go index 978195c27..f95b4144d 100644 --- a/internal/service/operations/update_branches_test.go +++ b/internal/service/operations/update_branches_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git/log" - "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -53,17 +52,10 @@ func TestSuccessfulUserUpdateBranchRequest(t *testing.T) { } func TestSuccessfulGitHooksForUserUpdateBranchRequest(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testSuccessfulGitHooksForUserUpdateBranchRequest(t, ctx) - }) - } + testSuccessfulGitHooksForUserUpdateBranchRequest(t, ctx) } func testSuccessfulGitHooksForUserUpdateBranchRequest(t *testing.T, ctx context.Context) { @@ -100,17 +92,10 @@ func testSuccessfulGitHooksForUserUpdateBranchRequest(t *testing.T, ctx context. } func TestFailedUserUpdateBranchDueToHooks(t *testing.T) { - featureSet, err := testhelper.NewFeatureSets(nil, featureflag.GoUpdateHook) - require.NoError(t, err) ctx, cancel := testhelper.Context() defer cancel() - for _, features := range featureSet { - t.Run(features.String(), func(t *testing.T) { - ctx = features.WithParent(ctx) - testFailedUserUpdateBranchDueToHooks(t, ctx) - }) - } + testFailedUserUpdateBranchDueToHooks(t, ctx) } func testFailedUserUpdateBranchDueToHooks(t *testing.T, ctx context.Context) { |