Skip to content

Commit

Permalink
indicate, if one requirement got already addressed within a git commi…
Browse files Browse the repository at this point in the history
…t in the past
  • Loading branch information
Jan-Piotraschke committed Apr 19, 2024
1 parent 9ebbbb2 commit c363681
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions scripts/summarize_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# Create or clear the summary file
echo "# Summary of Requirements" > SUMMARY.md

# Fetch all commit messages into an array
commit_messages=()
while IFS= read -r line; do
commit_messages+=("$line")
done < <(git log --pretty=format:%s)

# Find all requirements.md files, sort them, and append their content formatted into the summary
find . -name "requirements.md" | sort | while read file; do
directory=$(dirname "$file")
Expand All @@ -12,14 +18,18 @@ find . -name "requirements.md" | sort | while read file; do
# Ensure that all lines, including those that might end without a newline, are read
while IFS= read -r line || [[ -n "$line" ]]; do
[[ -z "$line" ]] && continue # Skip empty lines
# Extract requirement ID and escape special characters for regex use in git log
# Extract requirement ID
req_id=$(echo "$line" | grep -o '\[.*\]')
# Check if the requirement ID is present in the git commit history
if git log --all --grep="$req_id" > /dev/null; then
echo "| $line | Yes |" >> SUMMARY.md
else
echo "| $line | No |" >> SUMMARY.md
fi
# Initialize a flag to false
found="No"
# Check if the requirement ID is present in any commit message
for msg in "${commit_messages[@]}"; do
if [[ "$msg" == *"$req_id"* ]]; then
found="Yes"
break
fi
done
echo "| $line | $found |" >> SUMMARY.md
done < "$file"
echo "" >> SUMMARY.md
done

0 comments on commit c363681

Please sign in to comment.