mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
feat: Change to kindly error message when git-tag does not exist
This commit is contained in:
parent
588c3d0a41
commit
82d0df16a8
2 changed files with 37 additions and 32 deletions
|
|
@ -2,6 +2,7 @@
|
|||
package chglog
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
|
@ -135,6 +136,7 @@ func (gen *Generator) Generate(w io.Writer, query string) error {
|
|||
|
||||
func (gen *Generator) readVersions(query string) ([]*Version, error) {
|
||||
tags, first, err := gen.getTags(query)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -172,7 +174,7 @@ func (gen *Generator) readVersions(query string) ([]*Version, error) {
|
|||
}
|
||||
|
||||
if len(versions) == 0 {
|
||||
return nil, fmt.Errorf("a commits corresponding to \"%s\" was not found", query)
|
||||
return nil, fmt.Errorf("commits corresponding to \"%s\" was not found", query)
|
||||
}
|
||||
|
||||
return versions, nil
|
||||
|
|
@ -184,6 +186,10 @@ func (gen *Generator) getTags(query string) ([]*Tag, string, error) {
|
|||
return nil, "", err
|
||||
}
|
||||
|
||||
if len(tags) == 0 {
|
||||
return nil, "", errors.New("git-tag does not exist")
|
||||
}
|
||||
|
||||
first := ""
|
||||
if query != "" {
|
||||
tags, first, err = gen.tagSelector.Select(tags, query)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue