-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog-all-echo.sh
47 lines (40 loc) · 1.23 KB
/
changelog-all-echo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
tags=$(git tag --sort=creatordate)
# 将标签列表分割成数组
IFS=$'\n' read -d '' -ra tag_array <<<"$tags"
array_length=${#tag_array[@]}
function part() {
name=$1
pattern=$2
changes=$(grep -E "^($pattern)" releaseNotes.tmp | sed -E "s/($pattern): //g" | sort | uniq | awk '{print NR". "$0}')
lines=$(printf "\\$changes\n" | wc -l)
if [ $lines -gt 0 ]; then
echo "### $name"
echo ""
echo "$changes"
echo ""
fi
}
# 遍历数组
for ((i = array_length - 1; i > 0; i--)); do
element="${tag_array[i]}"
# 计算下一个元素的索引
next_index=$((i - 1))
tag_info=$(git show --quiet --format="%ci" --date=short $element | awk '{print $1}')
# 检查是否越界
next_element="${tag_array[next_index]}"
echo "# $element - $tag_info"
git log --pretty=format:'%s' "$element...$next_element" | sort -k2n | uniq >./releaseNotes.tmp
echo ""
part "Features" "feature|feat"
part "Bug Fixes" "bugfix|fix"
part "Enhancements" "enhance"
part "Tests" "test"
part "Documents" "docs|doc"
part "Refactors" "refactor"
part "Styles" "style"
part "Others" "other"
part "Perfs" "perf"
done
rm -f ./releaseNotes.tmp
rm -f ./tags.tmp