Skip to content

Exit gracefully from hook scripts when requisite bins missing #141

Description

@calebcartwright

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions