-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from JsDaddy/feat/setup-hook
feat(ref: no-ref): add setup hook
- Loading branch information
Showing
5 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
...hub/.hooks/commit-msg/check-commit-msg.sh → .github/hooks/commit-msg
100644 → 100755
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,7 +1,6 @@ | ||
#!/usr/bin | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
commit_msg=$(cat .git/COMMIT_EDITMSG) | ||
|
||
echo "$commit_msg" | npx commitlint |
2 changes: 1 addition & 1 deletion
2
.github/.hooks/pre-commit/quality.sh → .github/hooks/pre-commit
100644 → 100755
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,4 +1,4 @@ | ||
#!/usr/bin | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
|
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,39 @@ | ||
#!/bin/bash | ||
|
||
# Define the directory containing sample hooks | ||
SAMPLE_HOOKS_DIR=".github/hooks" | ||
|
||
# Define the target directory for Git hooks | ||
GIT_HOOKS_DIR=".git/hooks" | ||
|
||
# Function to copy or replace hooks | ||
copy_or_replace_hooks() { | ||
for hook in "$SAMPLE_HOOKS_DIR"/*; do | ||
hook_name=$(basename "$hook") | ||
target_hook="$GIT_HOOKS_DIR/$hook_name" | ||
if [ -f "$target_hook" ]; then | ||
echo "Replacing existing hook: $hook_name" | ||
else | ||
echo "Copying new hook: $hook_name" | ||
fi | ||
cp "$hook" "$target_hook" | ||
chmod ug+x "$target_hook" # Ensure executable permission is set | ||
done | ||
} | ||
|
||
# Main function | ||
main() { | ||
# Check if .git/hooks directory exists | ||
if [ ! -d "$GIT_HOOKS_DIR" ]; then | ||
echo "Error: .git/hooks directory not found. Are you in a Git repository?" | ||
exit 1 | ||
fi | ||
|
||
# Copy or replace hooks | ||
copy_or_replace_hooks | ||
|
||
echo "Git hooks setup complete." | ||
} | ||
|
||
# Run the main function | ||
main |
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