Skip to content

feat: add TASK_SOURCES special variable #2047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fhofherr
Copy link

@fhofherr fhofherr commented Feb 7, 2025

This commit adds the TASK_SOURCES variable to tasks. If a task defines the sources key, TASK_SOURCES contains the list of paths referenced by sources. Globs are expanded.

This was initially implemented by @hernandanielg in #1146 to fix #948. The PR seemed to have stalled since, which is why I'm now opening this new PR. In contrast to #1146 my changes set TASK_SOURCES to a list, which allows users to use template functions to transform the value of TASK_SOURCES. Additionally, I decided to name the variable TASK_SOURCES instead of SOURCES, as I wanted to make clear that this variable only exists for tasks.

I'm aware of this comment by @callegar which wondered if sources should be changed to accept the value of variables. However, this seemed like a bigger change to me (I may be wrong since I don't know the code in detail). Therefore I opted to stick with the original proposal.

The downside of my change is, that globs get expanded whenever the TASK_SOURCES variable is set. I'm not yet sure under which circumstances Compiler.FastGetVariables and Compiler.GetVariables are called. Both of those methods call the getVariables method which in turn calls the getSpecialVariables method I modified. Would it be enough to just pass evaluateShVars to getSpecialVariables (maybe renaming it to fast in the process) and skip glob expansion if it is true?

This commit adds the `TASK_SOURCES` variable to tasks. If a task defines
the `sources` key, `TASK_SOURCES` contains the list of paths referenced
by `sources`. Globs are expanded.

This was initially implemented by @hernandanielg in go-task#1146 to fix go-task#948.
@fhofherr fhofherr force-pushed the 948-uses-sources-as-variable branch from ef9ffda to 191cb5d Compare February 7, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use sources as variable
1 participant