<commit_before>CommandRunner = require('./command-runner')
cp = require('child_process')

getBranchFromRef = (ref) ->
  refParts = ref.split("/")
  return refParts[refParts.length-1]

exports.index = (req, res) ->
  parsedPayload = JSON.parse(req.body.payload)

  console.log "Got deploy message from #{parsedPayload.ref}"
  unless getBranchFromRef(parsedPayload.ref) is "deploy"
    console.log "Ignoring, only deploys on pushes from deploy"
    return res.send 500, "Only commits from deploy branch are accepted"

  console.log "Forking #{process.cwd()}/bin/deploy.coffee"

  deployProcess = CommandRunner "coffee #{process.cwd()}/bin/deploy.coffee"

  console.log "Forked!"

  res.send 200<commit_msg>Kill the server after the deploy script finishes<commit_after>CommandRunner = require('../bin/command-runner')

getBranchFromRef = (ref) ->
  refParts = ref.split("/")
  return refParts[refParts.length-1]

exports.index = (req, res) ->
  parsedPayload = JSON.parse(req.body.payload)

  console.log "Got deploy message from #{parsedPayload.ref}"
  unless getBranchFromRef(parsedPayload.ref) is "deploy"
    console.log "Ignoring, only deploys on pushes from deploy"
    return res.send 500, "Only commits from deploy branch are accepted"

  console.log "Forking #{process.cwd()}/bin/deploy.coffee"

  deployProcess = CommandRunner.spawn "coffee #{process.cwd()}/bin/deploy.coffee"

  console.log "Forked!"

  deployProcess.on('close', ->
    console.log "deploy finished, restarting server"
    process.exit()
  )

  res.send 200
{'fraction_non_alphanumeric': 0.13120104438642297, 'fraction_numerical': 0.009138381201044387, 'mean_word_length': 4.4361702127659575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '2992791', 'n_tokens_mistral': 517, 'n_tokens_neox': 480, 'n_words': 119}