Skip to content

Commit

Permalink
Revert "Deprecate THASH. (vercel#4526)"
Browse files Browse the repository at this point in the history
This reverts commit dba32b3.
  • Loading branch information
nathanhammond committed Apr 27, 2023
1 parent f6082b4 commit 54ea549
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
12 changes: 0 additions & 12 deletions cli/internal/run/global_hash.go
Expand Up @@ -3,10 +3,8 @@ package run
import (
"fmt"
"path/filepath"
"strings"

"github.com/hashicorp/go-hclog"
"github.com/mitchellh/cli"
"github.com/vercel/turbo/cli/internal/env"
"github.com/vercel/turbo/cli/internal/fs"
"github.com/vercel/turbo/cli/internal/globby"
Expand Down Expand Up @@ -94,8 +92,6 @@ func calculateGlobalHash(
envVarPassthroughs []string,
envMode util.EnvMode,
logger hclog.Logger,
ui cli.Ui,
isStructuredOutput bool,
) (GlobalHashable, error) {
// Calculate env var dependencies
envVars := []string{}
Expand All @@ -106,14 +102,6 @@ func calculateGlobalHash(
return GlobalHashable{}, err
}

// The only way we can add env vars into the hash via matching is via THASH,
// so we only do a simple check here for entries in `BySource.Matching`.
// If we enable globalEnv to accept wildcard characters, we'll need to update this
// check.
if !isStructuredOutput && len(globalHashableEnvVars.BySource.Matching) > 0 {
ui.Warn(fmt.Sprintf("[DEPRECATED] Using .*THASH.* to specify an environment variable for inclusion into the hash is deprecated. You specified: %s.", strings.Join(globalHashableEnvVars.BySource.Matching.Names(), ", ")))
}

logger.Debug("global hash env vars", "vars", globalHashableEnvVars.All.Names())

// Calculate global file dependencies
Expand Down
4 changes: 0 additions & 4 deletions cli/internal/run/run.go
Expand Up @@ -160,8 +160,6 @@ func (r *run) run(ctx gocontext.Context, targets []string) error {
return fmt.Errorf("failed to read package.json: %w", err)
}

isStructuredOutput := r.opts.runOpts.GraphDot || r.opts.runOpts.DryRunJSON

var pkgDepGraph *context.Context
if r.opts.runOpts.SinglePackage {
pkgDepGraph, err = context.SinglePackageGraph(r.base.RepoRoot, rootPackageJSON)
Expand Down Expand Up @@ -256,8 +254,6 @@ func (r *run) run(ctx gocontext.Context, targets []string) error {
turboJSON.GlobalPassthroughEnv,
r.opts.runOpts.EnvMode,
r.base.Logger,
r.base.UI,
isStructuredOutput,
)

if err != nil {
Expand Down
18 changes: 1 addition & 17 deletions turborepo-tests/integration/tests/global_env.t
Expand Up @@ -39,7 +39,6 @@ Setup

# set env var with "THASH" and ensure cache miss
$ SOMETHING_THASH_YES=hi ${TURBO} run build --filter=util --output-logs=hash-only
[DEPRECATED] Using .*THASH.* to specify an environment variable for inclusion into the hash is deprecated. You specified: SOMETHING_THASH_YES.
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -59,19 +58,4 @@ Setup
Tasks: 1 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

# THASH deprecation doesn't break --dry=json
$ SOMETHING_THASH_YES=hi ${TURBO} run build --filter=util --dry=json | jq -r '.tasks[0].environmentVariables.global[0]'
SOMETHING_THASH_YES=8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4

# THASH deprecation doesn't break --graph
$ SOMETHING_THASH_YES=hi ${TURBO} run build --filter=util --graph

digraph {
\tcompound = "true" (esc)
\tnewrank = "true" (esc)
\tsubgraph "root" { (esc)
\t\t"[root] util#build" -> "[root] ___ROOT___" (esc)
\t} (esc)
}


0 comments on commit 54ea549

Please sign in to comment.