instructlab / instructlab-bot

GitHub bot to assist with the taxonomy contribution workflow
Apache License 2.0
14 stars 16 forks source link

If no required label is defined in the bot config, skip label checking #222

Closed nerdalert closed 4 months ago

nerdalert commented 4 months ago

Skip the method checkBotEnableStatus if there are no required. Something like:

    var labelPresent bool
    // Set labelPresent to true if RequiredLabels is empty
    if len(h.RequiredLabels) == 0 {
        labelPresent = true
    } else {
        labelPresent, err = h.checkRequiredLabel(ctx, client, prComment, h.RequiredLabels)
    }
    if !labelPresent {
        detailsMsg := fmt.Sprintf("Beep, boop 🤖: To proceed, the pull request must have one of the '%v' labels.", h.RequiredLabels)
        if err != nil {
            detailsMsg = fmt.Sprintf("%s\nError: %v", detailsMsg, err)
        }

Prevents a scenario like this:

Beep, boop 🤖: To proceed, the pull request must have one of the '[]' labels.
nerdalert commented 4 months ago

Correction, this might just be a confusing log message. Going to change it to, not enabled as opposed to missing label.

    if !isBotEnabled {
        detailsMsg := fmt.Sprintf("Beep, boop 🤖: To proceed, the pull request must have one of the '%v' labels.", h.RequiredLabels)
        if err != nil {
            detailsMsg = fmt.Sprintf("%s\nError: %v", detailsMsg, err)
        }