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 28, 2023
1 parent f3dd806 commit 5620df5
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
Original file line number Diff line number Diff line change
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 @@ -124,8 +122,6 @@ func getGlobalHashInputs(
envVarPassthroughs []string,
envMode util.EnvMode,
logger hclog.Logger,
ui cli.Ui,
isStructuredOutput bool,
) (GlobalHashableInputs, error) {
// Calculate env var dependencies
envVars := []string{}
Expand All @@ -136,14 +132,6 @@ func getGlobalHashInputs(
return GlobalHashableInputs{}, 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
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,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 @@ -252,8 +250,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
Original file line number Diff line number Diff line change
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 5620df5

Please sign in to comment.