mercari / tfnotify

A CLI command to parse Terraform execution result and notify it to GitHub
MIT License
619 stars 91 forks source link

Fix error when there is only 1 commit #82

Open lucapino-kobalt opened 3 years ago

lucapino-kobalt commented 3 years ago

WHAT

Fix by 1 error in extracting previous commit

WHY

When the repository contains only 1 commit, the extraction of the previous commit fails:

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/mercari/tfnotify/notifier/github.(*CommitsService).lastOne(...)
    /home/runner/work/tfnotify/tfnotify/notifier/github/commits.go:48
github.com/mercari/tfnotify/notifier/github.(*NotifyService).Notify(0xc000102ad0, 0xc00018e480, 0x441, 0xc00000e018, 0xc000190000, 0x32e)
    /home/runner/work/tfnotify/tfnotify/notifier/github/notify.go:94 +0x875
main.(*tfnotify).Run(0xc000147380, 0xc000172d90, 0x8)
    /home/runner/work/tfnotify/tfnotify/main.go:188 +0x5e2
main.cmdApply(0xc000102840, 0x0, 0xc0000109a0)
    /home/runner/work/tfnotify/tfnotify/main.go:320 +0x1e8