diff options
Diffstat (limited to 'tools/changelog.sh')
-rwxr-xr-x | tools/changelog.sh | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/tools/changelog.sh b/tools/changelog.sh index 664f34608..6489a3cb2 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -23,8 +23,7 @@ TYPES=( test "Testing" ) -#* Types that will be displayed in their own section, -#* in the order specified here. +#* Types that will be displayed in their own section, in the order specified here. local -a MAIN_TYPES MAIN_TYPES=(feat fix perf docs) @@ -34,7 +33,8 @@ OTHER_TYPES=(refactor style other) #* Commit types that don't appear in $MAIN_TYPES nor $OTHER_TYPES #* will not be displayed and will simply be ignored. - +local -a IGNORED_TYPES +IGNORED_TYPES=(${${${(@k)TYPES}:|MAIN_TYPES}:|OTHER_TYPES}) ############################ # COMMIT PARSING UTILITIES # @@ -139,7 +139,7 @@ function parse-commit { # [BREAKING CHANGE: warning] # commits holds the commit type - commits[$hash]="$(commit:type "$subject")" + types[$hash]="$(commit:type "$subject")" # scopes holds the commit scope scopes[$hash]="$(commit:scope "$subject")" # subjects holds the commit subject @@ -164,26 +164,32 @@ function parse-commit { function display-release { # This function uses the following globals: output, version, - # commits (A), subjects (A), scopes (A), breaking (A) and reverts (A). + # types (A), subjects (A), scopes (A), breaking (A) and reverts (A). # # - output is the output format to use when formatting (raw|text|md) # - version is the version in which the commits are made - # - commits, subjects, scopes, breaking, and reverts are associative arrays + # - types, subjects, scopes, breaking, and reverts are associative arrays # with commit hashes as keys # Remove commits that were reverted local hash rhash for hash rhash in ${(kv)reverts}; do - if (( ${+commits[$rhash]} )); then + if (( ${+types[$rhash]} )); then # Remove revert commit - unset "commits[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]" + unset "types[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]" # Remove reverted commit - unset "commits[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]" + unset "types[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]" fi done + # Remove commits from ignored types unless it has breaking change information + for hash in ${(k)types[(R)${(j:|:)IGNORED_TYPES}]}; do + (( ! ${+breaking[$hash]} )) || continue + unset "types[$hash]" "subjects[$hash]" "scopes[$hash]" + done + # If no commits left skip displaying the release - if (( $#commits == 0 )); then + if (( $#types == 0 )); then return fi @@ -313,7 +319,7 @@ function display-release { local hash type="$1" local -a hashes - hashes=(${(k)commits[(R)$type]}) + hashes=(${(k)types[(R)$type]}) # If no commits found of type $type, go to next type (( $#hashes != 0 )) || return 0 @@ -330,7 +336,7 @@ function display-release { # Commits made under types considered other changes local -A changes - changes=(${(kv)commits[(R)${(j:|:)OTHER_TYPES}]}) + changes=(${(kv)types[(R)${(j:|:)OTHER_TYPES}]}) # If no commits found under "other" types, don't display anything (( $#changes != 0 )) || return 0 @@ -388,19 +394,19 @@ function main { fi # Commit classification arrays - local -A commits subjects scopes breaking reverts + local -A types subjects scopes breaking reverts local truncate=0 read_commits=0 local version tag local hash refs subject body # Get the first version name: # 1) try tag-like version, or - # 2) try name-rev, or - # 3) try branch name, or + # 2) try branch name, or + # 3) try name-rev, or # 4) try short hash version=$(command git describe --tags $until 2>/dev/null) \ - || version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" $until 2>/dev/null) \ || version=$(command git symbolic-ref --quiet --short $until 2>/dev/null) \ + || version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" $until 2>/dev/null) \ || version=$(command git rev-parse --short $until 2>/dev/null) # Get commit list from $until commit until $since commit, or until root commit if $since is unset @@ -414,7 +420,7 @@ function main { # --first-parent: commits from merged branches are omitted local SEP="0mZmAgIcSeP" local -a raw_commits - raw_commits=(${(0)"$(command git log -z \ + raw_commits=(${(0)"$(command git -c log.showSignature=false log -z \ --format="%h${SEP}%D${SEP}%s${SEP}%b" --abbrev=7 \ --no-merges --first-parent $range)"}) @@ -441,7 +447,7 @@ function main { # Output previous release display-release # Reinitialize commit storage - commits=() + types=() subjects=() scopes=() breaking=() |