<commit_before>'use strict'

const config = require(__dirname + '/../config')
const GitHubApi = require('github')
const Staticman = require('../lib/Staticman')

module.exports = (repo, data) => {
  const ua = config.get('analytics.uaTrackingId') ? require('universal-analytics')(config.get('analytics.uaTrackingId')) : null

  if (data.number) {
    const github = new GitHubApi({
      debug: false,
      protocol: 'https',
      host: 'api.github.com',
      pathPrefix: '',
      headers: {
        'user-agent': 'Staticman agent'
      },
      timeout: 5000,
      Promise: Promise
    })

    github.authenticate({
      type: 'oauth',
      token: config.get('githubToken')
    })

    github.pullRequests.get({
      user: data.repository.owner.login,
      repo: data.repository.name,
      number: data.number
    }).then(response => {
      if (response.head.ref.indexOf('staticman_')) {
        return null
      }

      if (response.merged) {
        const bodyMatch = response.body.match(/(?:.*?)<!--staticman_notification:(.+?)-->(?:.*?)/i)

        if (bodyMatch.length === 2) {
          try {
            const parsedBody = JSON.parse(bodyMatch[1])
            const staticman = new Staticman(parsedBody.parameters)

            staticman.setConfigPath(parsedBody.configPath)
            staticman.processMerge(parsedBody.fields, parsedBody.options).catch(err => {
              return Promise.reject(err)
            })
          } catch (err) {
            return Promise.reject(err)
          }
        }
      }

      if (response.state === 'closed') {<commit_msg>Add check around comment check<commit_after>'use strict'

const config = require(__dirname + '/../config')
const GitHubApi = require('github')
const Staticman = require('../lib/Staticman')

module.exports = (repo, data) => {
  const ua = config.get('analytics.uaTrackingId') ? require('universal-analytics')(config.get('analytics.uaTrackingId')) : null

  if (data.number) {
    const github = new GitHubApi({
      debug: false,
      protocol: 'https',
      host: 'api.github.com',
      pathPrefix: '',
      headers: {
        'user-agent': 'Staticman agent'
      },
      timeout: 5000,
      Promise: Promise
    })

    github.authenticate({
      type: 'oauth',
      token: config.get('githubToken')
    })

    github.pullRequests.get({
      user: data.repository.owner.login,
      repo: data.repository.name,
      number: data.number
    }).then(response => {
      if (response.head.ref.indexOf('staticman_')) {
        return null
      }

      if (response.merged) {
        const bodyMatch = response.body.match(/(?:.*?)<!--staticman_notification:(.+?)-->(?:.*?)/i)

        if (bodyMatch && (bodyMatch.length === 2)) {
          try {
            const parsedBody = JSON.parse(bodyMatch[1])
            const staticman = new Staticman(parsedBody.parameters)

            staticman.setConfigPath(parsedBody.configPath)
            staticman.processMerge(parsedBody.fields, parsedBody.options).catch(err => {
              return Promise.reject(err)
            })
          } catch (err) {
            return Promise.reject(err)
          }
        }
      }

      if (response.state === 'closed') {
{'fraction_non_alphanumeric': 0.15077881619937694, 'fraction_numerical': 0.003738317757009346, 'mean_word_length': 2.3205791106514995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2063045', 'n_tokens_mistral': 967, 'n_tokens_neox': 928, 'n_words': 177}