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

Exit gracefully from hook scripts when requisite bins missing #141

Open
calebcartwright opened this issue Jan 22, 2021 · 0 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Milestone

Comments

@calebcartwright
Copy link
Member

We're deliberate in the underlying git hook scripts to avoid failing (and thus breaking git flows) in environmental cases, such as a missing configuration file, but there's a big case we've missed entirely

if [ ${rustyHookExitCode} -eq ${noConfigFileExitCode} ]; then
if [ "${hookName}" = "pre-commit" ]; then
echo "[rusty-hook] rusty-hook git hooks are configured, but no config file was found"
echo "[rusty-hook] In order to use rusty-hook, your project must have a config file"
echo "[rusty-hook] See https://github.com/swellaby/rusty-hook#configure for more information about configuring rusty-hook"
echo
echo "[rusty-hook] If you were trying to remove rusty-hook, then you should also delete the git hook files to remove this warning"
echo "[rusty-hook] See https://github.com/swellaby/rusty-hook#removing-rusty-hook for more information about removing rusty-hook from your project"
echo
fi
exit 0

However, we've overlooked the scenarios where rusty-hook bin is not already on the system and the subsequent cli installation fails, as well as cargo itself not being available. These are not impossible scenarios by any stretch of the imagination, and could occur relatively easily, for example if cargo's bin directory or cargo itself is not on the user's path, and we've had a couple reports (albeit with different causes) of hook issues due to the executables not being found (refs #105 #140).

To prevent this problematic behavior, we should:

@calebcartwright calebcartwright added the bug Something isn't working label Jan 22, 2021
@calebcartwright calebcartwright added this to To do in 1.0 Release via automation Jan 22, 2021
@calebcartwright calebcartwright added this to the 1.x Release milestone Jan 22, 2021
@calebcartwright calebcartwright added the good first issue Good for newcomers label Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
1.0 Release
  
To do
Development

No branches or pull requests

1 participant