mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
fix: Fix error message when Tag can not be acquired
This commit is contained in:
parent
96562bcc9a
commit
b01be88230
2 changed files with 56 additions and 1 deletions
|
|
@ -95,9 +95,63 @@ func TestGeneratorNotFoundCommits(t *testing.T) {
|
|||
},
|
||||
})
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
err := gen.Generate(buf, "foo")
|
||||
assert.Error(err)
|
||||
assert.Equal("", buf.String())
|
||||
}
|
||||
|
||||
func TestGeneratorNotFoundCommitsOne(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
testName := "not_found"
|
||||
|
||||
setup(testName, func(git gitcmd.Client) {
|
||||
git.Exec("commit", "--allow-empty", "--date", "Mon Jan 1 00:00:00 2018 +0000", "-m", "chore(*): First commit")
|
||||
})
|
||||
|
||||
gen := NewGenerator(&Config{
|
||||
Bin: "git",
|
||||
WorkingDir: filepath.Join(testRepoRoot, testName),
|
||||
Template: filepath.Join(cwd, "testdata", testName+".md"),
|
||||
Info: &Info{
|
||||
RepositoryURL: "https://github.com/git-chglog/git-chglog",
|
||||
},
|
||||
Options: &Options{
|
||||
CommitFilters: map[string][]string{},
|
||||
CommitSortBy: "Scope",
|
||||
CommitGroupBy: "Type",
|
||||
CommitGroupSortBy: "Title",
|
||||
CommitGroupTitleMaps: map[string]string{},
|
||||
HeaderPattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$",
|
||||
HeaderPatternMaps: []string{
|
||||
"Type",
|
||||
"Scope",
|
||||
"Subject",
|
||||
},
|
||||
IssuePrefix: []string{
|
||||
"#",
|
||||
"gh-",
|
||||
},
|
||||
RefActions: []string{},
|
||||
MergePattern: "^Merge pull request #(\\d+) from (.*)$",
|
||||
MergePatternMaps: []string{
|
||||
"Ref",
|
||||
"Source",
|
||||
},
|
||||
RevertPattern: "^Revert \"([\\s\\S]*)\"$",
|
||||
RevertPatternMaps: []string{
|
||||
"Header",
|
||||
},
|
||||
NoteKeywords: []string{
|
||||
"BREAKING CHANGE",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
err := gen.Generate(buf, "foo")
|
||||
assert.Contains(err.Error(), "\"foo\" was not found")
|
||||
assert.Error(err)
|
||||
assert.Equal("", buf.String())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package chglog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -33,7 +34,7 @@ func (r *tagReader) ReadAll() ([]*Tag, error) {
|
|||
tags := []*Tag{}
|
||||
|
||||
if err != nil {
|
||||
return tags, err
|
||||
return tags, fmt.Errorf("failed to get git-tag: %s", err.Error())
|
||||
}
|
||||
|
||||
lines := strings.Split(out, "\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue