File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,8 +28,10 @@ func parseChangelog(fileName string) (changelog.Changelog, error) {
2828func changelogWithSingleEntry (entry entry.Entry , repoName , repoOwner string ) changelog.Changelog {
2929 // Isolate the entry
3030 entry .Next = nil
31- entry .PrevTag = entry .Previous .Tag
32- entry .Previous = nil
31+ if entry .Previous != nil {
32+ entry .PrevTag = entry .Previous .Tag
33+ entry .Previous = nil
34+ }
3335
3436 cl := changelog .NewChangelog (repoOwner , repoName )
3537 cl .Insert (entry )
Original file line number Diff line number Diff line change 88)
99
1010var fileName string = "CHANGELOG.md"
11+ var singleEntryFileName string = "single_CHANGELOG.md"
1112
1213func TestGetAll (t * testing.T ) {
1314 cl , err := get .GetAll (fileName )
@@ -32,6 +33,18 @@ func TestGetLatest(t *testing.T) {
3233 assert .Equal (t , "v0.13.0" , cl .GetEntries ()[0 ].PrevTag )
3334}
3435
36+ func TestGetLatestWithNoPrevious (t * testing.T ) {
37+ cl , err := get .GetLatest (singleEntryFileName )
38+
39+ // Should not error
40+ assert .Nil (t , err )
41+
42+ // Should have 1 entry
43+ count := len (cl .GetEntries ())
44+ assert .Equal (t , 1 , count )
45+ assert .Equal (t , "" , cl .GetEntries ()[0 ].PrevTag )
46+ }
47+
3548func TestGetVersionWithAValidVersion (t * testing.T ) {
3649 // Should not error when version is found
3750 cl , err := get .GetVersion (fileName , "v0.9.0" )
You can’t perform that action at this time.
0 commit comments