<commit_before>package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/grafana/grafana/pkg/build/config"
	"github.com/grafana/grafana/pkg/build/droneutil"
	"github.com/urfave/cli/v2"
)

func GenerateMetadata(c *cli.Context) (config.Metadata, error) {
	var metadata config.Metadata
	version := ""

	event, err := droneutil.GetDroneEventFromEnv()
	if err != nil {
		return config.Metadata{}, err
	}

	var releaseMode config.ReleaseMode
	switch event {
	case string(config.PullRequestMode):
		releaseMode = config.ReleaseMode{Mode: config.PullRequestMode}
	case config.Push:
		mode, err := config.CheckDroneTargetBranch()
		if err != nil {
			return config.Metadata{}, err
		}
		releaseMode = config.ReleaseMode{Mode: mode}
	case config.Custom:
		mode, err := config.CheckDroneTargetBranch()
		if err != nil {
			return config.Metadata{}, err
		}
		// if there is a custom event targeting the main branch, that's an enterprise downstream build
		if mode == config.MainBranch {
			releaseMode = config.ReleaseMode{Mode: config.CustomMode}
		} else {
			releaseMode = config.ReleaseMode{Mode: mode}
		}
	case config.Tag, config.Promote:
		tag, ok := os.LookupEnv("DRONE_TAG")
		if !ok || tag == "" {
			return config.Metadata{}, err
		}
		version = strings.TrimPrefix(tag, "v")
		mode, err := config.CheckSemverSuffix()
		if err != nil {
			return config.Metadata{}, err
		}
		releaseMode = mode
	}<commit_msg>Add cronjob option at switch case (#56272)<commit_after>package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/grafana/grafana/pkg/build/config"
	"github.com/grafana/grafana/pkg/build/droneutil"
	"github.com/urfave/cli/v2"
)

func GenerateMetadata(c *cli.Context) (config.Metadata, error) {
	var metadata config.Metadata
	version := ""

	event, err := droneutil.GetDroneEventFromEnv()
	if err != nil {
		return config.Metadata{}, err
	}

	var releaseMode config.ReleaseMode
	switch event {
	case string(config.PullRequestMode):
		releaseMode = config.ReleaseMode{Mode: config.PullRequestMode}
	case config.Push:
		mode, err := config.CheckDroneTargetBranch()
		if err != nil {
			return config.Metadata{}, err
		}
		releaseMode = config.ReleaseMode{Mode: mode}
	case config.Custom:
		mode, err := config.CheckDroneTargetBranch()
		if err != nil {
			return config.Metadata{}, err
		}
		// if there is a custom event targeting the main branch, that's an enterprise downstream build
		if mode == config.MainBranch {
			releaseMode = config.ReleaseMode{Mode: config.CustomMode}
		} else {
			releaseMode = config.ReleaseMode{Mode: mode}
		}
	case config.Tag, config.Promote:
		tag, ok := os.LookupEnv("DRONE_TAG")
		if !ok || tag == "" {
			return config.Metadata{}, err
		}
		version = strings.TrimPrefix(tag, "v")
		mode, err := config.CheckSemverSuffix()
		if err != nil {
			return config.Metadata{}, err
		}
		releaseMode = mode
	case config.Cronjob:
		releaseMode = config.ReleaseMode{Mode: config.CronjobMode}
	}
{'fraction_non_alphanumeric': 0.12653478854024558, 'fraction_numerical': 0.0023874488403819918, 'mean_word_length': 4.048192771084337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1436170', 'n_tokens_mistral': 1061, 'n_tokens_neox': 972, 'n_words': 237}