mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
feat: Add Next and Previous in Tag
This commit is contained in:
parent
cd9684604b
commit
d4d2a7ed80
3 changed files with 109 additions and 16 deletions
|
|
@ -61,5 +61,31 @@ func (r *tagReader) ReadAll() ([]*Tag, error) {
|
|||
})
|
||||
}
|
||||
|
||||
total := len(tags)
|
||||
|
||||
for i, tag := range tags {
|
||||
var (
|
||||
next *RelateTag
|
||||
prev *RelateTag
|
||||
)
|
||||
|
||||
if i > 0 {
|
||||
next = &RelateTag{
|
||||
Name: tags[i-1].Name,
|
||||
Date: tags[i-1].Date,
|
||||
}
|
||||
}
|
||||
|
||||
if i+1 < total {
|
||||
prev = &RelateTag{
|
||||
Name: tags[i+1].Name,
|
||||
Date: tags[i+1].Date,
|
||||
}
|
||||
}
|
||||
|
||||
tag.Next = next
|
||||
tag.Previous = prev
|
||||
}
|
||||
|
||||
return tags, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue