Skip to content
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

Fix early exit hook wd change #1520

Merged
merged 8 commits into from
Sep 29, 2021
Merged

Conversation

keithduncan
Copy link
Contributor

@keithduncan keithduncan commented Sep 29, 2021

An early exit hook would revert the shell to the bootstrap’s working directory which is the builds dir and not the specific build being worked on. This was because the beforeWd didn’t hold the value of the "before working directory" but instead os.Getwd().

To handle this case I have removed that otherwise unused variable from the ScriptWrapper struct, and we now detecting the hook early exit case based on an absence of an afterEnv and return an error. The bootstrap handles that category of error by continuing on without applying any changes since they are incomputable.

This matches the previous behaviour where we would: get a blank afterEnv and do nothing with it (since we didn’t support propagating removed vars up into the shell env), and get an empty string for the "new" working directory which because it wasn’t absolute would be appended to the CWD to get the exact same string back 🙈

If Changes() returns an error because it cannot read the afterEnv (distinct from a successfully read but empty afterEnv) we return an error and the bootstrap process aborts the job, same behaviour as before.

@keithduncan keithduncan merged commit abf5c52 into main Sep 29, 2021
@keithduncan keithduncan deleted the keithduncan/fix-early-exit-hook-wd branch September 29, 2021 09:02
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.

1 participant