Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 8b6d4f8

Browse files
authored
chore: centralize logic for disabling Batch Changes on dotcom (#63370)
This is how it's done for Code Insights as well. ## Test plan CI
1 parent dd32e5f commit 8b6d4f8

File tree

4 files changed

+5
-19
lines changed

4 files changed

+5
-19
lines changed

cmd/frontend/enterprise/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ go_library(
1313
"//internal/codeintel/types",
1414
"//internal/conf",
1515
"//internal/database",
16-
"//internal/dotcom",
1716
],
1817
)

cmd/frontend/enterprise/enterprise.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/sourcegraph/sourcegraph/internal/codeintel/types"
1414
"github.com/sourcegraph/sourcegraph/internal/conf"
1515
"github.com/sourcegraph/sourcegraph/internal/database"
16-
"github.com/sourcegraph/sourcegraph/internal/dotcom"
1716
)
1817

1918
// Services is a bag of HTTP handlers and factory functions that are registered by the
@@ -143,12 +142,6 @@ func (e *emptyWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
143142
makeNotFoundHandler(e.name)
144143
}
145144

146-
type ErrBatchChangesDisabledDotcom struct{}
147-
148-
func (e ErrBatchChangesDisabledDotcom) Error() string {
149-
return "batch changes is not available on Sourcegraph.com; use Sourcegraph Cloud or self-hosted instead"
150-
}
151-
152145
type ErrBatchChangesDisabled struct{}
153146

154147
func (e ErrBatchChangesDisabled) Error() string {
@@ -168,11 +161,6 @@ func BatchChangesEnabledForSite() error {
168161
return ErrBatchChangesDisabled{}
169162
}
170163

171-
// Batch Changes are disabled on sourcegraph.com
172-
if dotcom.SourcegraphDotComMode() {
173-
return ErrBatchChangesDisabledDotcom{}
174-
}
175-
176164
return nil
177165
}
178166

cmd/frontend/internal/batches/resolvers/errors.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ func (e ErrBatchChangesOverLimit) Extensions() map[string]any {
6060
return map[string]any{"code": "ErrBatchChangesOverLimit"}
6161
}
6262

63-
type ErrBatchChangesDisabledDotcom struct{ error }
64-
65-
func (e ErrBatchChangesDisabledDotcom) Extensions() map[string]any {
66-
return map[string]any{"code": "ErrBatchChangesDisabledDotcom"}
67-
}
68-
6963
type ErrEnsureBatchChangeFailed struct{}
7064

7165
func (e ErrEnsureBatchChangeFailed) Error() string {

internal/conf/computed.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/sourcegraph/sourcegraph/internal/conf/confdefaults"
1515
"github.com/sourcegraph/sourcegraph/internal/conf/conftypes"
1616
"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
17+
"github.com/sourcegraph/sourcegraph/internal/dotcom"
1718
"github.com/sourcegraph/sourcegraph/internal/hashutil"
1819
"github.com/sourcegraph/sourcegraph/internal/license"
1920
srccli "github.com/sourcegraph/sourcegraph/internal/src-cli"
@@ -164,6 +165,10 @@ func UpdateChannel() string {
164165
}
165166

166167
func BatchChangesEnabled() bool {
168+
if dotcom.SourcegraphDotComMode() {
169+
// Batch Changes is always disabled on dotcom.
170+
return false
171+
}
167172
if enabled := Get().BatchChangesEnabled; enabled != nil {
168173
return *enabled
169174
}

0 commit comments

Comments
 (0)