mirror of
https://github.com/go-task/task.git
synced 2026-02-25 04:33:43 +01:00
Refactor compiler.go for better maintainability: - Extract isScopedMode() helper function - Split getVariables() into getScopedVariables() and getLegacyVariables() - Fix directory resolution: parent chain env/vars now resolve from their own directory instead of the current task's directory Add nested includes support and tests: - Add testdata/scoped_taskfiles/inc_a/nested/Taskfile.yml (3 levels deep) - Add test case for nested include inheritance (root → a → nested) - Verify nested includes inherit vars from full parent chain Fix flaky tests: - Remove VAR from print tasks (defined in both inc_a and inc_b) - Test only unique variables (UNIQUE_A, UNIQUE_B, ROOT_VAR) Document flatten: true escape hatch: - Add migration guide step for using flatten: true - Add new section explaining flatten bypasses scoping - Include example and usage recommendations
39 lines
782 B
YAML
39 lines
782 B
YAML
version: "3"
|
|
|
|
env:
|
|
INC_A_ENV: env_from_a
|
|
SHARED_ENV: shared_from_a
|
|
|
|
vars:
|
|
VAR: value_from_a
|
|
UNIQUE_A: only_in_a
|
|
|
|
includes:
|
|
nested: ./nested
|
|
|
|
tasks:
|
|
print:
|
|
desc: Print vars from include A
|
|
cmds:
|
|
- echo "A:UNIQUE_A={{.UNIQUE_A}}"
|
|
- echo "A:ROOT_VAR={{.ROOT_VAR}}"
|
|
|
|
try-access-b:
|
|
desc: Try to access B's unique var (should fail in scoped mode)
|
|
cmds:
|
|
- echo "A:UNIQUE_B={{.UNIQUE_B}}"
|
|
|
|
print-env:
|
|
desc: Print env vars from include A
|
|
cmds:
|
|
- echo "A:INC_A_ENV={{.env.INC_A_ENV}}"
|
|
- echo "A:ROOT_ENV={{.env.ROOT_ENV}}"
|
|
- echo "A:SHARED_ENV={{.env.SHARED_ENV}}"
|
|
|
|
test-env-in-var:
|
|
desc: Test using env in a var template
|
|
vars:
|
|
COMPOSED: "env={{.env.ROOT_ENV}}"
|
|
cmds:
|
|
- echo "{{.COMPOSED}}"
|