Skip to content

Commit 94ecdc7

Browse files
committed
Show release notes for a repository without tags
If a repository does not have tags, then all commits are the release log.
1 parent 4ec7ef7 commit 94ecdc7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

docs/commands.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ usage: git elegant show-release-notes [<layout> | <layout> <from-reference> | <l
328328

329329
Generates a release notes using commits subjects between the given references.
330330
The commits are ordered from oldest to newest. By default, the `from-reference`
331-
is the last available tag, and the `to-reference` is a HEAD revision.
331+
is the last available tag, and the `to-reference` is a HEAD revision. If
332+
there are no tags, all commits will be displayed.
332333

333334
There are two options for a `layout`:
334335

libexec/git-elegant-show-release-notes

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ command-description() {
1616
cat<<MESSAGE
1717
Generates a release notes using commits subjects between the given references.
1818
The commits are ordered from oldest to newest. By default, the \`from-reference\`
19-
is the last available tag, and the \`to-reference\` is a HEAD revision.
19+
is the last available tag, and the \`to-reference\` is a HEAD revision. If
20+
there are no tags, all commits will be displayed.
2021
2122
There are two options for a \`layout\`:
2223
@@ -73,7 +74,7 @@ default() {
7374
local first=${2:-$(last-tag)}
7475
local second=${3:-@}
7576
local diapason=${first}...${second}
76-
if [[ ${first} == all-commits ]]; then
77+
if [[ ${first} == all-commits ]] || [[ -z ${first} ]]; then
7778
diapason=${second}
7879
fi
7980
case ${layout} in

tests/git-elegant-show-release-notes.bats

+11
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,14 @@ teardown() {
7171
[[ "${status}" -eq 43 ]]
7272
[[ "${lines[@]}" =~ "'some' layout is not supported." ]]
7373
}
74+
75+
@test "'show-release-notes': displays all commits if there is no tags" {
76+
repo "git tag | xargs git tag -d"
77+
check git-elegant show-release-notes
78+
[[ "${status}" -eq 0 ]]
79+
[[ "${lines[0]}" == "Release notes" ]]
80+
[[ "${lines[1]}" == "- Add file" ]]
81+
[[ "${lines[2]}" == "- Add ${first}" ]]
82+
[[ "${lines[3]}" == "- Add ${second}" ]]
83+
[[ "${lines[4]}" == "- Add ${third}" ]]
84+
}

0 commit comments

Comments
 (0)