From 9c84c344d762b200de7acc794b9a0e7832144e7a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 10 Jan 2022 19:39:05 +0100 Subject: fix: disable `log.showSignature` in `git log` calls --- tools/changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/changelog.sh') diff --git a/tools/changelog.sh b/tools/changelog.sh index 664f34608..86774a7ea 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -414,7 +414,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)"}) -- cgit v1.2.3-70-g09d2 From 035c856c2cbbad2b45252ec8c065c3a9e7eefa65 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Jan 2022 17:46:09 +0100 Subject: fix: get branch name first in `omz version` and changelog --- lib/cli.zsh | 7 ++++--- tools/changelog.sh | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'tools/changelog.sh') diff --git a/lib/cli.zsh b/lib/cli.zsh index 0a85402df..ec59d1d44 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -791,12 +791,13 @@ function _omz::version { # Get the version name: # 1) try tag-like version - # 2) try name-rev - # 3) try branch name + # 2) try branch name + # 3) try name-rev (tag~ or branch~) local version version=$(command git describe --tags HEAD 2>/dev/null) \ + || version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \ || version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \ - || version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) + || version="" # Get short hash for the current HEAD local commit=$(command git rev-parse --short HEAD 2>/dev/null) diff --git a/tools/changelog.sh b/tools/changelog.sh index 86774a7ea..49532a4a4 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -395,12 +395,12 @@ function main { # 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 -- cgit v1.2.3-70-g09d2 From 3c5367d272011e7bca9fa4e8f9a5f9635f938d11 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 28 Jan 2022 13:22:31 +0100 Subject: fix(changelog): don't show changelog with only ignored type commits --- tools/changelog.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'tools/changelog.sh') diff --git a/tools/changelog.sh b/tools/changelog.sh index 49532a4a4..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,7 +394,7 @@ 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 @@ -441,7 +447,7 @@ function main { # Output previous release display-release # Reinitialize commit storage - commits=() + types=() subjects=() scopes=() breaking=() -- cgit v1.2.3-70-g09d2