const defaultConfig = require('./default-config')
const generateLabel = require('./generate-label')

/**
 * Returns the regex, labels and config object used in every handler
 * @param {object} context - Probot context object
 * @returns {object}
 */
module.exports = async context => {
  const config = await context.config('config.yml')
  const cfg = config && config.todo ? Object.assign({}, defaultConfig, config.todo) : defaultConfig
  const labels = await generateLabel(context, cfg)
  const keywords = Array.isArray(cfg.keyword) ? cfg.keyword : [cfg.keyword]
  const reg = new RegExp(`^diff --git a\\/.+ b\\/(.+)[\\s\\S]+?^@{2}.+\\+(\\d+).+@{2}([\\s\\S]+?(^(\\+).*(${keywords.join('|')})(?:[:-\\s]+)?\\s(.*))[\\s\\S]+)`, 'gm')

  return {
    config: cfg,
    regex: reg,
    labels
  }
}

const defaultConfig = require('./default-config')
const generateLabel = require('./generate-label')

/**
 * Returns the regex, labels and config object used in every handler
 * @param {object} context - Probot context object
 * @returns {object}
 */
module.exports = async context => {
  const config = await context.config('config.yml')
  const cfg = config && config.todo ? Object.assign({}, defaultConfig, config.todo) : defaultConfig
  const labels = await generateLabel(context, cfg)
  const keywords = Array.isArray(config.keyword) ? config.keyword : [config.keyword]

  return {
    config: cfg,
    regex: new RegExp(`.+()\\s(?<keyword>${keywords.join('|')})\\s(?<title>.*)`),
    labels
  }
}

Include title regex in handler setup
Include title regex in handler setup
