Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
964ea60e55 | |||
2386e278c7 | |||
66de41874d | |||
9aace7aa2b | |||
6c787535a8 |
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,3 +1,15 @@
|
||||
## 0.13.0 (2024-10-25)
|
||||
|
||||
### Feat
|
||||
|
||||
- :sparkles: use time.Time.Before() instead of Sub()
|
||||
|
||||
## 0.12.0 (2024-10-25)
|
||||
|
||||
### Feat
|
||||
|
||||
- :sparkles: use tagger.when to find latest tag
|
||||
|
||||
## 0.11.1 (2024-07-11)
|
||||
|
||||
### Fix
|
||||
|
2
cz.yaml
2
cz.yaml
@ -5,5 +5,5 @@ commitizen:
|
||||
name: cz_conventional_commits
|
||||
tag_format: $version
|
||||
update_changelog_on_bump: true
|
||||
version: 0.11.1
|
||||
version: 0.13.0
|
||||
version_scheme: semver
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/client"
|
||||
@ -62,28 +62,34 @@ func FetchTags() func(repo *git.Repository) error {
|
||||
}
|
||||
}
|
||||
|
||||
func getLatestGitTag(options ...GetLatestGitTagOption) (tag string, err error) {
|
||||
r, err := git.PlainOpen(".")
|
||||
func getLatestGitTag(options ...GetLatestGitTagOption) (string, error) {
|
||||
var (
|
||||
tag string
|
||||
tagDate *time.Time
|
||||
err error
|
||||
)
|
||||
|
||||
repo, err := git.PlainOpen(".")
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error opening git repo at %s: %w", ".", err)
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
err := opt(r)
|
||||
err := opt(repo)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
tagRefs, err := r.Tags()
|
||||
tags, err := repo.TagObjects()
|
||||
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error getting git tag refs %w", err)
|
||||
return "", fmt.Errorf("error getting git tags %w", err)
|
||||
}
|
||||
|
||||
for {
|
||||
r, err := tagRefs.Next()
|
||||
t, err := tags.Next()
|
||||
|
||||
if err == io.EOF {
|
||||
break
|
||||
@ -93,15 +99,19 @@ func getLatestGitTag(options ...GetLatestGitTagOption) (tag string, err error) {
|
||||
return "", fmt.Errorf("error iterating tags %w", err)
|
||||
}
|
||||
|
||||
parts := strings.Split(string(r.Name()), "/")
|
||||
tag = strings.Join(parts[2:], "/")
|
||||
if tagDate != nil && t.Tagger.When.Before(*tagDate) {
|
||||
continue
|
||||
}
|
||||
|
||||
tagDate = &t.Tagger.When
|
||||
tag = t.Name
|
||||
}
|
||||
|
||||
if tag == "" {
|
||||
return tag, fmt.Errorf("couldn't find any git tags")
|
||||
}
|
||||
|
||||
return
|
||||
return tag, err
|
||||
}
|
||||
|
||||
func writeCard(path, schema string, card interface{}) {
|
||||
|
Loading…
Reference in New Issue
Block a user