Refactor scripts names and location

This commit is contained in:
Matheus Albino Brunhara
2024-02-22 14:09:23 -03:00
parent 186be867c5
commit 160476e536
9 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Array of prefixes to look for
prefixes=("ETICS" "CDK" "IM") # Add your prefixes here
# Get the current working directory
current_dir=$(pwd)
# Find the first occurrence of a folder containing any of the specified prefixes
for prefix in "${prefixes[@]}"; do
found_string=$(find "$current_dir" -type d -path "*${prefix}*" | head -n 1)
if [ -n "$found_string" ]; then
break
fi
done
# Check if a matching folder is found
if [ -z "$found_string" ]; then
echo "Error: No folder containing the specified prefixes found in the current directory or its subdirectories."
else
# Extract the prefix and number from the folder name
regex="${prefixes[0]}-[0-9]+" # Assuming the first prefix for simplicity
etics_number=$(echo "$found_string" | grep -oE "$regex" | tail -n 1)
# Get the commit message parameter
commit_message=$1
# Run the git commit command
git commit -m "[$etics_number] $commit_message"
fi