Skip to content

Commit

Permalink
cache tags
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 21, 2020
1 parent b47e49c commit 585445d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ A cli to generate changelog
> The project is in development
feature:

- [x] Cross-platform support
- [x] Template Support
- [ ] Custom template
- [x] Conventional Commits Parser
- [ ] Generate multiple versions of change logs

### Usage

Expand Down
6 changes: 6 additions & 0 deletions internal/client/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewGitClient(dir string) (*GitClient, error) {

type GitClient struct {
repository *git.Repository
tags []*Tag
}

func (g *GitClient) TagN(offset int) (*Tag, error) {
Expand Down Expand Up @@ -92,6 +93,9 @@ func (g *GitClient) TagName(name string) (*Tag, error) {
}

func (g *GitClient) Tags() ([]*Tag, error) {
if g.tags != nil {
return g.tags, nil
}
tags := make([]*Tag, 0)

tt, _ := g.repository.References()
Expand Down Expand Up @@ -142,6 +146,8 @@ func (g *GitClient) Tags() ([]*Tag, error) {
return prevVersion.GT(*nextVersion)
})

g.tags = tags

return tags, nil
}

Expand Down

0 comments on commit 585445d

Please sign in to comment.