-
Notifications
You must be signed in to change notification settings - Fork 124
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
CARGO_MAKE_CURRENT_TASK_NAME
shows previous task's name when printed in a condition_script
#1173
Comments
@wmmc88 i think we talked about it before in some other issue. example of default behavior: [tasks.first]
script = """
echo "current (first): ${CARGO_MAKE_CURRENT_TASK_NAME}"
"""
[tasks.second]
dependencies = ["first"]
condition_script = """
echo "condition (second): ${CARGO_MAKE_CURRENT_TASK_NAME}"
"""
script = """
echo "current (second): ${CARGO_MAKE_CURRENT_TASK_NAME}"
""" running it gitpod /workspace/misc-test (cargo_make_1173) $ cargo make second
[cargo-make] INFO - cargo make 0.37.21
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: second
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: first
current (first): first
condition (second): first
[cargo-make] INFO - Running Task: second
current (second): second
[cargo-make] INFO - Build Done in 0.01 seconds. with a plugin that overwrites this logic for task second [plugins.impl.set-task-name]
script = '''
set_env CARGO_MAKE_CURRENT_TASK_NAME ${task.name}
cm_plugin_run_task
'''
[tasks.first]
script = """
echo "current (first): ${CARGO_MAKE_CURRENT_TASK_NAME}"
"""
[tasks.second]
plugin = "set-task-name"
dependencies = ["first"]
condition_script = """
echo "condition (second): ${CARGO_MAKE_CURRENT_TASK_NAME}"
"""
script = """
echo "current (second): ${CARGO_MAKE_CURRENT_TASK_NAME}"
""" running it gitpod /workspace/misc-test (cargo_make_1173) $ cargo make second
[cargo-make] INFO - cargo make 0.37.21
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: second
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: first
current (first): first
condition (second): second
[cargo-make] INFO - Running Task: second
current (second): second
[cargo-make] INFO - Build Done in 0.01 seconds. |
@sagiegurari yes, I believe we talked about env mutation before, and it makes sense to me that the env isn't changed for most normal environment variables, but this is a question specifically to do with What prompted my question was because there is this line of code which seems to mutate the env before the condition script but:
So in the following file: [tasks.first]
script = """
#!@duckscript
echo "current (first): ${CARGO_MAKE_CURRENT_TASK_NAME}"
"""
[tasks.second]
dependencies = ["first"]
env = { "CARGO_MAKE_CURRENT_TASK_NAME" = "dummy", "ENV_VAR" = "hello!" }
condition_script = """
#!@duckscript
echo "condition (second): ${CARGO_MAKE_CURRENT_TASK_NAME}"
echo "condition env var: ${ENV_VAR}"
"""
script = """
#!@duckscript
echo "current (second): ${CARGO_MAKE_CURRENT_TASK_NAME}"
echo "current env var: ${ENV_VAR}"
""" it outputs:
Notice that in the prints in the condition script, |
@wmmc88 hmmm you are right! i can't remember what i did :D |
@wmmc88 thanks for finding and reporting bugs in cargo-make and insisting on them :) i'm not sure why the code was like it was. things change but you are correct and I think I solved it and releasing it now (will take around 15 mins) |
@sagiegurari no problem! I always try to make sure to report bugs when I find them (and help fix if time permits 😁) |
Describe The Bug
This is somewhat of a follow up to this comment I made on a pr a while back: #1132 (comment)
Right now,
CARGO_MAKE_CURRENT_TASK_NAME
only get updated after the condition passes:cargo-make/src/lib/runner.rs
Line 412 in 1f7adb3
This has the side effect that if you were to print
CARGO_MAKE_CURRENT_TASK_NAME
in acondition_script
, it would actually print the previous task's name. Is this intended behavior?The text was updated successfully, but these errors were encountered: