Skip to content

Commit

Permalink
list.Latest returns Semv
Browse files Browse the repository at this point in the history
  • Loading branch information
linyows committed Nov 27, 2018
1 parent bcc78fe commit d96fbef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
12 changes: 4 additions & 8 deletions git/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ func (l *List) String() string {
}

// Latest gets latest version from List
func (l *List) Latest() semver.Version {
if len(l.data) > 0 {
return l.data[len(l.data)-1]
func (l *List) Latest() *Semv {
if l.data.Len() > 0 {
return &Semv{data: l.data[len(l.data)-1]}
}
v, err := semver.Parse(defaultVersion)
if err != nil {
panic(err)
}
return v
return &Semv{data: semver.MustParse(defaultVersion)}
}

// WithoutPreRelease excludes pre-release
Expand Down
13 changes: 6 additions & 7 deletions git/semv.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@ func Latest() (*Semv, error) {
if err != nil {
return nil, err
}
return &Semv{
data: list.WithoutPreRelease().Latest(),
list: list,
}, nil
semv := list.WithoutPreRelease().Latest()
semv.list = list
return semv, nil
}

// String to string
func (v *Semv) String() string {
vv := defaultTagPrefix + v.data.String()
if vv == "v0.0.0" {
vv := v.data.String()
if vv == defaultVersion {
return ""
}
return vv
return defaultTagPrefix + vv
}

// IsEmpty checks empty
Expand Down

0 comments on commit d96fbef

Please sign in to comment.