-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: synced file(s) with honestbank/.github
- Loading branch information
1 parent
8fd0c1a
commit 3c079db
Showing
3 changed files
with
181 additions
and
0 deletions.
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
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,50 @@ | ||
#!/bin/bash | ||
|
||
# Function to get the current branch name | ||
get_current_branch() { | ||
git branch --show-current | ||
} | ||
|
||
# Function to get the commit message | ||
get_commit_message() { | ||
cat "$1" | ||
} | ||
|
||
# Function to write the commit message | ||
write_commit_message() { | ||
echo "$2" > "$1" | ||
} | ||
|
||
# Function to extract the ticket ID from the branch name | ||
extract_ticket_id() { | ||
echo "$1" | grep -o -E '(acq|da|data|dec|devop|ds|it|mlops|nerds|qa|sec|spe|ss)-[0-9]+' | tr '[:lower:]' '[:upper:]' | ||
} | ||
|
||
# Main script | ||
main() { | ||
if [ $# -eq 0 ]; then | ||
echo "commit message file not found, are you sure you set the stage for this hook to be in stages: [ commit-msg ]?" | ||
exit 1 | ||
fi | ||
|
||
commit_message_file="$1" | ||
branch_name=$(get_current_branch) | ||
ticket_id=$(extract_ticket_id "$branch_name") | ||
|
||
if [ -z "$ticket_id" ]; then | ||
echo "Warning: No ticket ID found in branch name '$branch_name'" | ||
exit 0 | ||
fi | ||
|
||
commit_message=$(get_commit_message "$commit_message_file") | ||
first_line=$(echo "$commit_message" | head -n 1) | ||
|
||
# Check if the first line already contains the ticket_id | ||
if ! echo "$first_line" | grep -qi "$ticket_id"; then | ||
first_line="$first_line [$ticket_id]" | ||
commit_message="$first_line$(echo "$commit_message" | tail -n +2)" | ||
write_commit_message "$commit_message_file" "$commit_message" | ||
fi | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/bin/bash | ||
|
||
# Function to check if Aspell is installed | ||
check_aspell() { | ||
if command -v aspell > /dev/null; then | ||
return 1 | ||
else | ||
echo "Aspell is not installed. Automatically installing" | ||
return 0 | ||
fi | ||
} | ||
|
||
# Function to install Aspell on Debian-based systems | ||
install_aspell_debian() { | ||
echo "Attempting to install Aspell on Debian-based system..." | ||
sudo apt-get update && sudo apt-get install -y aspell | ||
} | ||
|
||
# Function to install Aspell on macOS | ||
install_aspell_mac() { | ||
echo "Attempting to install Aspell on macOS..." | ||
brew install aspell | ||
} | ||
|
||
# Main logic | ||
if check_aspell; then | ||
# Identify the platform | ||
case "$(uname -s)" in | ||
Linux) | ||
if [ -f /etc/debian_version ]; then | ||
install_aspell_debian | ||
else | ||
echo "Unsupported Linux distribution." | ||
fi | ||
;; | ||
Darwin) | ||
install_aspell_mac | ||
;; | ||
*) | ||
echo "Unsupported operating system." | ||
;; | ||
esac | ||
fi | ||
|
||
|
||
read -r -d '' dictionary <<'EOF' | ||
personal_ws-1.1 en 2 | ||
anteraja | ||
argocd | ||
artajasa | ||
bersama | ||
bigquery | ||
brankas | ||
brankass | ||
cardmember | ||
checkly | ||
checkov | ||
ci | ||
cloudkms | ||
confluentinc | ||
coreapi | ||
deadletter | ||
deadletters | ||
decrypter | ||
ekyc | ||
encrypter | ||
finexus | ||
freshchat | ||
goka | ||
golang | ||
hnst | ||
honestbank | ||
honestcard | ||
jq | ||
json | ||
kafdrop | ||
menubook | ||
mst | ||
nonk8s | ||
noti | ||
opentracing | ||
perf | ||
perso | ||
pushgateway | ||
rclone | ||
resc | ||
roleset | ||
rolesets | ||
rtrw | ||
rudderstack | ||
schemaregistry | ||
snyk | ||
strimzi | ||
terratest | ||
ulid | ||
usecase | ||
waitlist | ||
waitlisted | ||
yaml | ||
EOF | ||
|
||
echo "$dictionary" > dictionary.text | ||
|
||
# Your string to check | ||
string=$(cat $1) | ||
|
||
echo "$string" | ||
|
||
# Check spelling | ||
misspelled=$(echo "$string" | aspell --personal ./dictionary.text list) | ||
|
||
rm dictionary.text | ||
|
||
# If the misspelled variable is not empty, there are spelling errors | ||
if [ -n "$misspelled" ]; then | ||
echo "Spelling errors found:" | ||
echo "$misspelled" | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |