/go/{cmd,libraries}: final cleanup

This commit is contained in:
coffeegoddd
2024-11-12 13:49:24 -08:00
parent dc27ff67cd
commit 186e5a8d87
3 changed files with 12 additions and 7 deletions
+1 -3
View File
@@ -21,7 +21,6 @@ import (
"github.com/dolthub/dolt/go/cmd/dolt/cli"
"github.com/dolthub/dolt/go/cmd/dolt/commands"
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions/dolt_ci"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle"
@@ -80,8 +79,7 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d
return 1
}
newCtx := doltdb.ContextWithDoltCICreateBypassKey(ctx)
queryist, sqlCtx, closeFunc, err := cliCtx.QueryEngine(newCtx)
queryist, sqlCtx, closeFunc, err := cliCtx.QueryEngine(ctx)
if err != nil {
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
}
+7 -2
View File
@@ -20,6 +20,8 @@ import (
"sort"
"strings"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo"
"github.com/dolthub/dolt/go/libraries/utils/funcitr"
@@ -61,10 +63,13 @@ func init() {
DocsSchema = schema.MustSchemaFromCols(doltDocsColumns)
}
func ContextWithDoltCICreateBypassKey(ctx context.Context) context.Context {
return context.WithValue(ctx, doltCICtxKey, doltCICtxValueAllow)
// ContextWithDoltCICreateBypassKey returns the sql.Context with a key that will
// allow dolt_ci tables to be created
func ContextWithDoltCICreateBypassKey(ctx *sql.Context) *sql.Context {
return ctx.WithContext(context.WithValue(ctx, doltCICtxKey, doltCICtxValueAllow))
}
// IsDoltCICreateAllowed checks whether dolt_ci tables can be created
func IsDoltCICreateAllowed(ctx context.Context) bool {
if v := ctx.Value(doltCICtxKey); v != nil {
if v == doltCICtxValueAllow {
+4 -2
View File
@@ -184,14 +184,16 @@ func CreateDoltCITables(ctx *sql.Context, db sqle.Database, queryFunc queryFunc,
deleteAllFromWorkflowsTableQuery(), // as last step run delete to create resolve all indexes/fks
}
newCtx := doltdb.ContextWithDoltCICreateBypassKey(ctx)
for _, query := range orderedCreateTableQueries {
err := SqlWriteQuery(ctx, queryFunc, query)
err := SqlWriteQuery(newCtx, queryFunc, query)
if err != nil {
return err
}
}
return commitCIInit(ctx, queryFunc, commiterName, commiterEmail)
return commitCIInit(newCtx, queryFunc, commiterName, commiterEmail)
}
func createWorkflowsTableQuery() string {