Add file-only mode to the add command

This commit is contained in:
Miguel de la Cruz 2020-03-01 13:21:10 +01:00
parent d5778abbd6
commit 61091e08e5
3 changed files with 12 additions and 4 deletions

View file

@ -10,10 +10,16 @@ type Ticket struct {
Text string `json:"text"`
}
func RemoveDuplicateTickets(tickets []*Ticket) []*Ticket {
func RemoveDuplicateTickets(tickets []*Ticket, fileOnly bool) []*Ticket {
ticketMap := map[string]*Ticket{}
for _, t := range tickets {
ticketMap[fmt.Sprintf("%s:%d", t.Filename, t.LineNo)] = t
if fileOnly {
t.Text = ""
t.LineNo = 0
ticketMap[t.Filename] = t
} else {
ticketMap[fmt.Sprintf("%s:%d", t.Filename, t.LineNo)] = t
}
}
cleanTickets := []*Ticket{}