Many additions and changes

This commit is contained in:
Matheus Albino Brunhara
2024-07-25 14:27:47 -03:00
parent 38bd245285
commit 9e8948bd92
9 changed files with 216 additions and 43 deletions

View File

@@ -1,30 +1,12 @@
#!/bin/bash
# Array of prefixes to look for
prefixes=("ETICS" "CDK" "IM") # Add your prefixes here
jira_ticket=$(echo $(pwd) | grep -oE "(ETICS|CDK|IM)-[0-9]+" | tail -n1)
# 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"
if [ -z $jira_ticket ]; then
echo "[ERROR] No Jira Ticket was found in current working directory"
exit 1
fi
commit_message=$1
git commit -m "[$jira_ticket] $commit_message"