isClosedByBot checks the issue timeline to determine if the close event was performed by a bot.
(issueNumber int, repo string)
| 100 | |
| 101 | // isClosedByBot checks the issue timeline to determine if the close event was performed by a bot. |
| 102 | func isClosedByBot(issueNumber int, repo string) bool { |
| 103 | events, err := ghAPIGetArray(fmt.Sprintf("issues/%d/events", issueNumber), repo) |
| 104 | if err != nil { |
| 105 | return false |
| 106 | } |
| 107 | // Walk backward to find the most recent close event |
| 108 | for i := range slices.Backward(events) { |
| 109 | event, _ := events[i]["event"].(string) |
| 110 | if event == "closed" { |
| 111 | actor, _ := events[i]["actor"].(map[string]any) |
| 112 | login, _ := actor["login"].(string) |
| 113 | return isBotUser(login) |
| 114 | } |
| 115 | } |
| 116 | return false |
| 117 | } |
no test coverage detected