Refactor scripts names and location
This commit is contained in:
30
scripts/shell/job/git-commit-with-jira.sh
Executable file
30
scripts/shell/job/git-commit-with-jira.sh
Executable 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
|
||||
Reference in New Issue
Block a user