-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add hooks to check .sh and .bash headers - Fixes #1491 #1765
Conversation
Hi @cornfeedhobo , Your question disappeared while i was replying to it: cornfeedhobo wrote:
Answerre: @ravenhall's comment on #1491 suggested adding a message to replace the ravenhall's suggestion
In doing a bit of research into how others were dealing with this, I came across the
However, I will admit that this might be overly clever, in that the hooks make sure the file is not executable, so the only way to see the message would be something like re: shellcheck: The main body of the shellcheck, The need for
Soo, we could simply the header by reducing the |
@davidpfarrell My bad. koala_man ended up explaining it to me, so I deleted the comment. Thanks for checking in. Edit: Interesting quotes from irc about this:
I have no knowledge of the corner/edge cases this could run into, but I'm marking it as approved since it passes CI and I really consider the error message just a best effort. |
Thanks for the thorough explanation, @davidpfarrell - looks good to me! One comment on the |
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.
Hey @davidpfarrell , thats a great idea!
I left a couple of comments, and I also agree with @nwinkler that the message can be improved.
Thanks for the effort you are putting in btw 😄
Hey Team,
The existing text was a bit of a place-holder that i copy/pasted from the interwebs. It should probably be more bash-it specific, but I wouldn't want to get too verbose with it. I'm thinking something like:
Maybe remove the #!The more I think about it though, the more it might make since to simplify the whole header for
Reasoning being:
Here are some tests with no
The only one that looks concerning here is So my vote is to simplify the |
Hi Team, I just committed an update:
|
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.
LGTM
GREAT! I had to do a quick update for the just-added sdkman .bash file -- That makes 3 today - Let's merge this before any more get in :) |
Description
Adds local pre-commit hooks to check
.sh
and.bash
files for proper headers and executable flags.Hooks Folder
Introduces a
hooks/
folder on root to act as a home for custom pre-commit hooks.Local Repo
Adds a
local
repo to".pre-commit-config.yaml"
dot-sh Hook
Adds the
dot-sh
hook to check.sh
files against bash-it requirements:#!
headerfile.sh header:
dot-bash Hook
Adds the
dot-bash
hook to check.bash
files against bash-it requirements:#!
headershellcheck
headerfile.bash header:
Fix Existing Files
Once the hooks were activated, some existing
.bash
files from"clean_files.txt"
triggered errors.This PR also includes fixes to those few files.
Motivation and Context
Intended to help enforce consistent header (
#!
) usage across bash-it executable and include scripts.Fixes #1491
How Has This Been Tested?
Extensive testing locally by manipulating
.sh
and.bash
files to confirm expected behavior/reporting from the hooks.Screenshots (if appropriate):
Types of changes
Checklist:
clean_files.txt
and formatted it usinglint_clean_files.sh
.TODO
.bash
files?