Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
f341c8c2
Unverified
Commit
f341c8c2
authored
Sep 07, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(changelog): print BREAKING CHANGE messages in a prettier way
parent
af271c9e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
changelog.sh
tools/changelog.sh
+15
-10
No files found.
tools/changelog.sh
View file @
f341c8c2
...
@@ -181,6 +181,12 @@ function display-release {
...
@@ -181,6 +181,12 @@ function display-release {
return
return
fi
fi
# Get length of longest scope for padding
local
max_scope
=
0
for
hash
in
${
(k)scopes
}
;
do
max_scope
=
$((
max_scope <
${#
scopes
[
$hash
]
}
?
${#
scopes
[
$hash
]
}
: max_scope
))
done
##* Formatting functions
##* Formatting functions
# Format the hash according to output format
# Format the hash according to output format
...
@@ -220,18 +226,13 @@ function display-release {
...
@@ -220,18 +226,13 @@ function display-release {
#* Uses $scopes (A) and $hash from outer scope
#* Uses $scopes (A) and $hash from outer scope
local
scope
=
"
${
1
:-${
scopes
[
$hash
]
}}
"
local
scope
=
"
${
1
:-${
scopes
[
$hash
]
}}
"
# Get length of longest scope for padding
local
max_scope
=
0
padding
=
0
for
hash
in
${
(k)scopes
}
;
do
max_scope
=
$((
max_scope <
${#
scopes
[
$hash
]
}
?
${#
scopes
[
$hash
]
}
: max_scope
))
done
# If no scopes, exit the function
# If no scopes, exit the function
if
[[
$max_scope
-eq
0
]]
;
then
if
[[
$max_scope
-eq
0
]]
;
then
return
return
fi
fi
# Get how much padding is required for this scope
# Get how much padding is required for this scope
local
padding
=
0
padding
=
$((
max_scope <
${#
scope
}
?
0
: max_scope
-
${#
scope
}
))
padding
=
$((
max_scope <
${#
scope
}
?
0
: max_scope
-
${#
scope
}
))
padding
=
"
${
(r
:
$padding
::
:
)
:-}
"
padding
=
"
${
(r
:
$padding
::
:
)
:-}
"
...
@@ -290,11 +291,15 @@ function display-release {
...
@@ -290,11 +291,15 @@ function display-release {
md
)
fmt
:header
"BREAKING CHANGES ⚠"
3
;;
md
)
fmt
:header
"BREAKING CHANGES ⚠"
3
;;
esac
esac
local hash
subject
local hash
message
local
wrap_width
=
$((
(
COLUMNS <
100
? COLUMNS :
100
)
-
3
))
for
hash
message
in
${
(kv)breaking
}
;
do
for
hash
message
in
${
(kv)breaking
}
;
do
echo
" -
$(
fmt
:hash
)
$(
fmt
:scope
)$(
fmt
:subject
"
${
message
}
"
)
"
# Format the BREAKING CHANGE message by word-wrapping it at maximum 100 characters
done
|
sort
# (use $COLUMNS if smaller than 100), and adding a 3-space left padding.
echo
message
=
"
$(
fmt
-w
$wrap_width
<<<
"
$message
"
|
sed
's/^/ /'
)
"
# Display hash and scope first, and then the full message with newline separators
echo
" -
$(
fmt
:hash
)
$(
fmt
:scope
)
\n\n
$(
fmt
:subject
"
$message
"
)
\n
"
done
}
}
function
display:type
{
function
display:type
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment