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

feat: improve behavior when config file is missing #53

Merged
merged 5 commits into from
Jul 11, 2019

Conversation

calebcartwright
Copy link
Member

Changes

  • Externalizes the hook script contents into a script file
  • Enhances the rusty-hook cli to respond with a specific exit code (currently 3) when the internal error was a missing config file
  • Enhances the git hook scripts to look at the exit code from rusty-hook.
    • Obviously on a zero exit code, everything will pass/proceed as normal
    • On a non-zero exit code, the script will print a message stating which git hook was rejected
    • On a missing config file exit code, the hook will instead exit with 0, allowing the git hook workflow to continue. The pre-commit hook will also display a warning message to the user:
rusty-hook git hooks are configured, but no config file was found
In order to use rusty-hook, your project must have a config file
See https://github.com/swellaby/rusty-hook#configure for more information

If you were trying to remove rusty-hook, then you should also delete the git hook files to remove this warning

Related Issues

@calebcartwright calebcartwright added the enhancement New feature or request label Jul 10, 2019
@calebcartwright calebcartwright added this to the 1.x Release milestone Jul 10, 2019
@calebcartwright calebcartwright self-assigned this Jul 10, 2019
@codecov
Copy link

codecov bot commented Jul 10, 2019

Codecov Report

Merging #53 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #53   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines         134    141    +7     
=====================================
+ Hits          134    141    +7
Impacted Files Coverage Δ
src/config.rs 100% <100%> (ø) ⬆️
src/git.rs 100% <100%> (ø) ⬆️
src/rusty_hook.rs 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7379cc...192730f. Read the comment docs.

echo "See https://github.com/swellaby/rusty-hook#configure for more information"
echo
echo "If you were trying to remove rusty-hook, then you should also delete the git hook files to remove this warning"
echo
Copy link
Member Author

@calebcartwright calebcartwright Jul 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can update this message later on after #51 is completed to include a link to those docs on how to remove rusty-hook. I think it's more important to get this new behavior out though, so plan on tackling #51 (and probably #48) in a follow up PR.


if [ $rhExitCode -ne 0 ]; then
# shellcheck disable=SC2170,SC1083
if [ $rhExitCode -eq {{NO_CONFIG_FILE_EXIT_CODE}} ]; then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{NO_CONFIG_FILE_EXIT_CODE}} is tokenized here so that rusty-hook can inject the correct value as part of writing all the git hook script files. Unsurprisingly, shellcheck doesn't like that, hence the above inline disables.

Copy link
Member

@beverts312 beverts312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@traviskosarek
Copy link
Member

I agree, looks like a good addition

@calebcartwright calebcartwright merged commit 1210b89 into master Jul 11, 2019
@calebcartwright calebcartwright deleted the missing-config-behavior branch July 11, 2019 21:54
@calebcartwright calebcartwright added the done Work on the Issue or PR is completed label Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Work on the Issue or PR is completed enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different behavior on missing config file Externalize hook script(s) in source with include_str! macro
3 participants