new: Release script order of commits can now be specified.
This commit is contained in:
parent
8883eabe1e
commit
e69d6d60eb
1 changed files with 44 additions and 11 deletions
|
|
@ -1,14 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check for the "final" flag in command line arguments
|
||||
finalFlag=false
|
||||
# Usage function to display help
|
||||
usage() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -f, --final Use the last 'final' tag as the start point."
|
||||
echo " -n, --newest Display commits from newest to oldest."
|
||||
echo " -h, --help Display this help and exit."
|
||||
echo ""
|
||||
echo "This script generates release notes from git commits based on tags."
|
||||
echo "By default, it lists commits from the last tag to HEAD, sorted from oldest to newest."
|
||||
}
|
||||
|
||||
# Check for command line arguments
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "final" ]]; then
|
||||
finalFlag=true
|
||||
break
|
||||
fi
|
||||
case "$arg" in
|
||||
-f|--final)
|
||||
finalFlag=true
|
||||
;;
|
||||
-n|--newest)
|
||||
newestFirst=true
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $arg"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Adjust sort order based on the flag
|
||||
if [ "${newestFirst}" = true ]; then
|
||||
sortOrder="tail -r"
|
||||
else
|
||||
sortOrder="cat"
|
||||
fi
|
||||
|
||||
# Get tags sorted by creation date
|
||||
tags=$(git tag --sort=creatordate)
|
||||
|
||||
|
|
@ -23,7 +55,7 @@ fi
|
|||
len=${#tagArray[@]}
|
||||
|
||||
# Find the last tag or the last "final" tag based on the flag
|
||||
if $finalFlag; then
|
||||
if [ "${finalFlag}" = true ]; then
|
||||
for (( i=len-1; i>=0; i-- )); do
|
||||
if [[ "${tagArray[i]}" == *"final"* ]]; then
|
||||
latestTag="${tagArray[i]}"
|
||||
|
|
@ -48,10 +80,10 @@ echo "## Release Notes from $latestTag to this release"
|
|||
echo ""
|
||||
|
||||
# Fetch commit logs from the latest tag to HEAD and categorize them
|
||||
newfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'new:' | sed 's/new:/-/g' | sort | uniq)
|
||||
updatedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'update:' | sed 's/update:/-/g' | sort | uniq)
|
||||
fixedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'fix:' | sed 's/fix:/-/g' | sort | uniq)
|
||||
deletedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'delete:' | sed 's/delete:/-/g' | sort | uniq)
|
||||
newfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'new:' | sed 's/new:/- /g' | sort | uniq | $sortOrder)
|
||||
updatedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'update:' | sed 's/update:/- /g' | sort | uniq | $sortOrder)
|
||||
fixedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'fix:' | sed 's/fix:/- /g' | sort | uniq | $sortOrder)
|
||||
deletedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'delete:' | sed 's/delete:/- /g' | sort | uniq | $sortOrder)
|
||||
|
||||
# Output formatted commit lists
|
||||
echo "New Features:"
|
||||
|
|
@ -88,3 +120,4 @@ if [ -z "$deletedfeatures" ]; then
|
|||
else
|
||||
echo "$deletedfeatures"
|
||||
fi
|
||||
echo ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue