Metadata: Track undefined jinja names and decide whether to download source #964
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background:
Some of the functions that decide whether or not to download the source before jinja rendering changed recently. (For example, 1a7ebca / cc6a3f9)
The function
parse_or_try_download()
decides whether the source is needed before the final parse. Previously, the decision was made based on the contents of thepackage/version
field. As it turns out, this is not a sufficient condition, because it fails for a recipe like this:Solution:
During the first parse, we permit undefined jinja variables using a special class named
UndefinedNeverFail
. I tweaked that class so that it records the names of the undefined variables. These names are stored inMetadata.undefined_jinja_vars
. Now, duringparse_or_try_download()
, we can just check the names of the variables that remain undefined. If anyGIT_
variables were undefined, we need to download the source.Note: This PR looks big, but that's just because the first commit moves some lines of code around (without changing them). I recommend reviewing these commits individually, not as a combined diff.
cc @msarahan