You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Protect against lost changes when setup_environment fails
Commit c3d972d fixed an issue where we would not restore changes in the
event a plugin failed to load. Unfortunately, it introduced a regression
where if `setup_environment` were to raise an error for any reason we
would always call `cleanup_environment`.
This is not necessarily always safe. For example, in the case of
pre-commit, `setup_environment` might fail before it is able to create a
stash of the working tree, so calling `cleanup_environment` could result
in lost changes.
Change the ordering so that we (hopefully) get the best of both worlds:
* Call `load_hooks` first outside of the `begin`/`ensure` block so
that if it fails we haven't touched the repository yet, so the repo
won't be in a bad state if a plugin can't be loaded or a signature
is invalid
* Call `setup_environment` outside of the `begin`/`ensure` block so
that in the worst case we don't accidentally clobber anything with
`cleanup_environment`
0 commit comments