Skip to content

Commit

Permalink
Show release notes for a repository without tags
Browse files Browse the repository at this point in the history
If a repository does not have tags, then all commits are the release
log.
  • Loading branch information
extsoft committed Dec 31, 2019
1 parent 4ec7ef7 commit 94ecdc7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ usage: git elegant show-release-notes [<layout> | <layout> <from-reference> | <l

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

There are two options for a `layout`:

Expand Down
5 changes: 3 additions & 2 deletions libexec/git-elegant-show-release-notes
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ command-description() {
cat<<MESSAGE
Generates a release notes using commits subjects between the given references.
The commits are ordered from oldest to newest. By default, the \`from-reference\`
is the last available tag, and the \`to-reference\` is a HEAD revision.
is the last available tag, and the \`to-reference\` is a HEAD revision. If
there are no tags, all commits will be displayed.
There are two options for a \`layout\`:
Expand Down Expand Up @@ -73,7 +74,7 @@ default() {
local first=${2:-$(last-tag)}
local second=${3:-@}
local diapason=${first}...${second}
if [[ ${first} == all-commits ]]; then
if [[ ${first} == all-commits ]] || [[ -z ${first} ]]; then
diapason=${second}
fi
case ${layout} in
Expand Down
11 changes: 11 additions & 0 deletions tests/git-elegant-show-release-notes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ teardown() {
[[ "${status}" -eq 43 ]]
[[ "${lines[@]}" =~ "'some' layout is not supported." ]]
}

@test "'show-release-notes': displays all commits if there is no tags" {
repo "git tag | xargs git tag -d"
check git-elegant show-release-notes
[[ "${status}" -eq 0 ]]
[[ "${lines[0]}" == "Release notes" ]]
[[ "${lines[1]}" == "- Add file" ]]
[[ "${lines[2]}" == "- Add ${first}" ]]
[[ "${lines[3]}" == "- Add ${second}" ]]
[[ "${lines[4]}" == "- Add ${third}" ]]
}

0 comments on commit 94ecdc7

Please sign in to comment.