-
Notifications
You must be signed in to change notification settings - Fork 9
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7dac6a0
refactor: externalize hook script, refs #49
calebcartwright 5d3f3ee
feat: change behavior when config file is missing
calebcartwright ac0733b
chore: hook script cleanup to remove extraneous new line
calebcartwright 9dbdd1c
chore: minor reordering of statements to fix spurrious code coverage …
calebcartwright 192730f
chore: fix spurious uncovered line in kcov coverage report
calebcartwright File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
"rustup", | ||
"sendemail", | ||
"setvariable", | ||
"shellcheck", | ||
"shiba", | ||
"swellaby", | ||
"testresults", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "rusty-hook" | ||
version = "0.8.4" | ||
version = "0.9.0" | ||
authors = ["Swellaby <[email protected]>"] | ||
description = "git hook utility" | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/sh | ||
# rusty-hook | ||
# version {{VERSION}} | ||
|
||
hookName=$(basename "$0") | ||
gitParams="$*" | ||
|
||
if ! command -v rusty-hook >/dev/null 2>&1; then | ||
if [ -z "${RUSTY_HOOK_SKIP_AUTO_INSTALL}" ]; then | ||
echo "Finalizing rusty-hook configuration..." | ||
echo "This may take a few seconds..." | ||
cargo install rusty-hook >/dev/null 2>&1 | ||
else | ||
echo "rusty-hook is not installed, and auto install is disabled" | ||
echo "skipping $hookName hook" | ||
echo "You can reinstall it using 'cargo install rusty-hook' or delete this hook" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
rusty-hook run --hook "$hookName" "$gitParams" | ||
rhExitCode=$? | ||
|
||
if [ $rhExitCode -ne 0 ]; then | ||
# shellcheck disable=SC2170,SC1083 | ||
if [ $rhExitCode -eq {{NO_CONFIG_FILE_EXIT_CODE}} ]; then | ||
if [ "$hookName" = "pre-commit" ]; then | ||
echo "rusty-hook git hooks are configured, but no config file was found" | ||
echo "In order to use rusty-hook, your project must have a config file" | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
fi | ||
exit 0 | ||
else | ||
echo "Configured hook command failed" | ||
echo "$hookName hook rejected" | ||
exit $rhExitCode | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.