Skip to content

Commit

Permalink
fix: add all commits if previous tag is not available
Browse files Browse the repository at this point in the history
- in new repositories previous tag is not available, this will allow for iterating all unreleased commits
  • Loading branch information
fallion committed Oct 19, 2019
1 parent abbc7be commit 5b51fab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"fmt"
"strings"

"github.com/commitsar-app/git/pkg"
history "github.com/commitsar-app/git/pkg"
"github.com/commitsar-app/release-notary/internal/releaser"
"github.com/commitsar-app/release-notary/internal/text"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gopkg.in/src-d/go-git.v4/plumbing"
)

func init() {
Expand Down Expand Up @@ -44,6 +45,11 @@ var publishCmd = &cobra.Command{
return err
}

// If previous tag is not available, provide empty hash so that all commits are iterated.
if err == history.ErrPrevTagNotAvailable {
lastTag = plumbing.Hash{}
}

commits, err := repo.CommitsBetween(currentCommit.Hash, lastTag)

if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ require (
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.4.0
gopkg.in/src-d/go-git.v4 v4.13.1
)

0 comments on commit 5b51fab

Please sign in to comment.