mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
refactor: Change to return an error if corresponding commit is empty
This commit is contained in:
parent
8869631aad
commit
22cfb51124
4 changed files with 77 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package chglog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -164,6 +165,10 @@ 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 versions, nil
|
||||
}
|
||||
|
||||
|
|
@ -201,6 +206,10 @@ func (gen *Generator) workdir() (func() error, error) {
|
|||
}
|
||||
|
||||
func (gen *Generator) render(w io.Writer, versions []*Version) error {
|
||||
if _, err := os.Stat(gen.config.Template); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmap := template.FuncMap{
|
||||
"datetime": func(layout string, input time.Time) string {
|
||||
return input.Format(layout)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue