-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwardoc
executable file
·130 lines (111 loc) · 4.44 KB
/
wardoc
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /bin/zsh
### wardoc — categorize and auto-document recent commits into markdown that's suitable as a pretty release page
#
# This is primarily called by havoc, but you can call it directly for testing.
start=$argv[1]
newtag=$argv[2]
range=$argv[3]
dosummary=$argv[4]
# Format of commit lines can be customized
# Consider showing author name and date in defaults: %an, %aI
fmt=${HAVOC_COMMIT_FORMAT-'%s (%h) (:sunglasses:%an)'}
# print -- start: $start -- newtag: $newtag -- range: $range >&2
feat=':new: Features'
bugs=':mechanic: Fixes (problems/brokenness)'
misc=':basket: Other/Misc (non-user facing)'
breaking=':bomb: Breaking Changes'
crises=':comet: Crises'
# Selected kinda from: gitmoji -l
declare -A bucketmap=(
# GITMOJI (my version)
':sparkles:' $feat # Features
':tada:' $feat # begin project or major feature
':books:' $feat # docs/comments (also memo)
':zap:' $feat # Performance
':lock:' $feat # Security/Privacy
':zap:' $feat # perf (also racehorse/rabbit)
':wheelchair:' $feat # accessibility
':lipstick:' $feat # User Interface
':zap:' $feat # Performance
':abc:' $feat # i18n
':construction:' $feat # WIP, progress on incomplete feature
':bug:' $bugs # Bug Fixes
':wastebasket:' $bugs # Removals
':wrench:' $misc # Configuration
':recycle:' $misc # Refactors
':rat:' $misc # tests (also lab_coat/test_tube)
':flags:' $misc # feature flag
':guard:' $misc # compiler/linter/CI problem (temporary)
':ledger:' $misc # logs (also satellite/mag)
':package:' $misc # update deps (arrow_up)
':recycle:' $misc # refactor/move things (also truck)
':poop:' $misc # write bad code (OR remove code?)
':wrench:' $misc # config (also hammer)
':bricks:' $misc # infra
':key:' $misc # secrets
':alien:' $misc # 3rd-party API changes
':robot:' $misc # automation
':alembic:' $misc # experiments
':stethoscope:' $misc # health-check
':thread:' $misc # concurrency
':boom:' $breaking # Breaking Changes
# MORE STANDARD (traditional)
'feat:' $feat # Features
'docs:' $feat # Documentation
'fix:' $bugs # Bug Fixes
'refactor:' $misc # Refactors
'build:' $misc # Build Tooling
'test:' $misc # Testing
'style:' $misc # Styling
'breaking change:' $breaking # Breaking Changes
)
declare -A trademojis=(
'feat:' ':sparkles:'
'docs:' ':sparkles:'
'fix:' ':bug:'
'refactor:' ':misc:'
'build:' ':misc:'
'test:' ':misc:'
'style:' ':misc:'
'breaking change:' ':boom:'
)
repo=$(git config remote.origin.url | sed -e 's/.*://' -e 's/.git$//')
ghurl='https://github.com/'
# repo="MicahElliott/captain"
url="$ghurl$repo"
releaseurl="$url/releases/tag/$newtag"
print "**[Full Changelog]($url/compare/$start...$newtag)**"
# Read into array
commits=( "${(@f)$( git log --pretty=format:$fmt $=range )}" )
if (( dosummary > 0 ))
then print "\nGenerating an LLM summary; this can take a while...." >&2
print "\n## :loudspeaker: Overview"
( print "Summarize the following git commits in a couple paragraphs, without referring to commit hashes:\n\n" ; git log $range ) | llm
print
fi
print "\nCommits to be included:\n${(j:\n:)commits}" >&2
prefixes=( $(print -l $commits |cut -f1 -d' ' | sort -u) )
# print prefixes: $prefixes >2
# Print each bucket with all of its commit types in it.
# Eg, feat bucket has sparkles/feat and books/docs together.
buckets=( "$feat" "$bugs" "$misc" "$breaking" "$crises" )
for bucket in $buckets
do curs=()
for c in $commits
do pre=$(cut -f1 -d' ' <<< $c)
# This has the added benefit of selecting only the registered prefixes,
# so commit not following the proper pattern will be auto-discarded.
if [[ $bucketmap[$pre] == $bucket ]]
then # print -- p: $pre -- t: $trademojis[$pre]
# Prefix traditional style with emojis
trad="$trademojis[$pre]"
if [[ -n $trad ]]; then c="$trad $c"; fi
curs+=$c
fi
done
if (( $#curs > 0 ))
then print "\n## $bucket\n";
for x in $curs; do print -- "- $x"; done
fi
done
print -- "\n_This release was created with [havoc](https://github.com/MicahElliott/havoc)._"