From 20a48b0420c10f813fd5aef9badf11e5e0c5711d Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 12 Oct 2020 03:56:27 -0500 Subject: [PATCH] don't always look for a patch --- bot.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bot.go b/bot.go index af45132..6dda40c 100644 --- a/bot.go +++ b/bot.go @@ -90,9 +90,10 @@ func (bot *Bot) NotifyNewEvent(channels []string, newMaps []Event) (err error) { downloadedBeatmap BeatmapsetDownloaded // status git.Status - commit *object.Commit - parent *object.Commit - patch *object.Patch + commit *object.Commit + parent *object.Commit + patch *object.Patch + foundPatch = false // commitFiles *object.FileIter ) beatmapSet, err = bot.getBeatmapsetInfo(event) @@ -167,12 +168,16 @@ func (bot *Bot) NotifyNewEvent(channels []string, newMaps []Event) (err error) { return } parent, err = commit.Parent(0) - if err != nil { - return - } - patch, err = commit.Patch(parent) - if err != nil { + if err == object.ErrParentNotFound { + + } else if err != nil { return + } else { + patch, err = commit.Patch(parent) + if err != nil { + return + } + foundPatch = true } // report diffs @@ -203,7 +208,9 @@ func (bot *Bot) NotifyNewEvent(channels []string, newMaps []Event) (err error) { if gotDownloadedBeatmap { log.Println(downloadedBeatmap) - embed.Description = patch.Stats().String() + if foundPatch { + embed.Description = patch.Stats().String() + } } } for _, channelId := range channels {