don't always look for a patch

This commit is contained in:
Michael Zhang 2020-10-12 03:56:27 -05:00
parent cd3cf11078
commit 20a48b0420
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

25
bot.go
View file

@ -90,9 +90,10 @@ func (bot *Bot) NotifyNewEvent(channels []string, newMaps []Event) (err error) {
downloadedBeatmap BeatmapsetDownloaded downloadedBeatmap BeatmapsetDownloaded
// status git.Status // status git.Status
commit *object.Commit commit *object.Commit
parent *object.Commit parent *object.Commit
patch *object.Patch patch *object.Patch
foundPatch = false
// commitFiles *object.FileIter // commitFiles *object.FileIter
) )
beatmapSet, err = bot.getBeatmapsetInfo(event) beatmapSet, err = bot.getBeatmapsetInfo(event)
@ -167,12 +168,16 @@ func (bot *Bot) NotifyNewEvent(channels []string, newMaps []Event) (err error) {
return return
} }
parent, err = commit.Parent(0) parent, err = commit.Parent(0)
if err != nil { if err == object.ErrParentNotFound {
return
} } else if err != nil {
patch, err = commit.Patch(parent)
if err != nil {
return return
} else {
patch, err = commit.Patch(parent)
if err != nil {
return
}
foundPatch = true
} }
// report diffs // report diffs
@ -203,7 +208,9 @@ func (bot *Bot) NotifyNewEvent(channels []string, newMaps []Event) (err error) {
if gotDownloadedBeatmap { if gotDownloadedBeatmap {
log.Println(downloadedBeatmap) log.Println(downloadedBeatmap)
embed.Description = patch.Stats().String() if foundPatch {
embed.Description = patch.Stats().String()
}
} }
} }
for _, channelId := range channels { for _, channelId := range channels {