<commit_before># Description:
#   enable communication with Phabricator via Conduit api
#
# Dependencies:
#
# Configuration:
#   PHABRICATOR_URL
#   PHABRICATOR_API_KEY
#   PHABRICATOR_PROJECTS
#   PHABRICATOR_BOT_PHID
#
# Commands:
#   hubot phab new <project> <name of the task> - creates a new task
#   hubot phab assign Txx to <user> - assigns task Txxx to comeone
#   hubot phab <user> - checks if user is known or not
#   hubot phab me as <email> - makes caller known with <email>
#   hubot phab <user> = <email> - associates user to email
#   hubot phab list projects - list known projects according to configuration
#   hubot phab version - give the version of hubot-phabs loaded
#
# Author:
#   mose

Phabricator = require '../lib/phabricator'
moment = require 'moment'
path = require 'path'

phabColumns = { }
if process.env.PHABRICATOR_PROJECTS isnt undefined
  for list in process.env.PHABRICATOR_PROJECTS.split(',')
    [code, label] = list.split ':'
    phabColumns[label] = code

humanFileSize = (size) ->
  i = Math.floor( Math.log(size) / Math.log(1024) )
  return ( size / Math.pow(1024, i) ).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]

module.exports = (robot) ->
  phab = new Phabricator robot, process.env


  robot.respond (/ph(?:ab)? list projects$/), (msg) ->
    msg.send "Known Projects: #{Object.keys(phabColumns).join(', ')}"


  robot.respond /ph(?:ab)? version/, (msg) ->
    pkg = require path.join __dirname, '..', 'package.json'
    msg.send "hubot-phabs module is version #{pkg.version}"
    msg.finish()


  robot.respond (/ph(?:ab)? new ([-_a-zA-Z0-9]+) ([^=]*)(?: = (.*))?$/), (msg) ->
    column = phabColumns[msg.match[1]]
    name = msg.match[2]
    description = msg.match[3]
    if column?
      phab.createTask msg, column, name, description, (body) ->
        if body['error_info']?
          msg.send "#{body['error_info']}"
        else
          id = body['result']['object']['id']
          url = process.env.PHABRICATOR_URL + "/T#{id}"<commit_msg>remove dupliacte code<commit_after># Description:
#   enable communication with Phabricator via Conduit api
#
# Dependencies:
#
# Configuration:
#   PHABRICATOR_URL
#   PHABRICATOR_API_KEY
#   PHABRICATOR_PROJECTS
#   PHABRICATOR_BOT_PHID
#
# Commands:
#   hubot phab new <project> <name of the task> - creates a new task
#   hubot phab assign Txx to <user> - assigns task Txxx to comeone
#   hubot phab <user> - checks if user is known or not
#   hubot phab me as <email> - makes caller known with <email>
#   hubot phab <user> = <email> - associates user to email
#   hubot phab list projects - list known projects according to configuration
#   hubot phab version - give the version of hubot-phabs loaded
#
# Author:
#   mose

Phabricator = require '../lib/phabricator'
moment = require 'moment'
path = require 'path'

phabColumns = { }
if process.env.PHABRICATOR_PROJECTS isnt undefined
  for list in process.env.PHABRICATOR_PROJECTS.split(',')
    [code, label] = list.split ':'
    phabColumns[label] = code

module.exports = (robot) ->
  phab = new Phabricator robot, process.env


  robot.respond (/ph(?:ab)? list projects$/), (msg) ->
    msg.send "Known Projects: #{Object.keys(phabColumns).join(', ')}"


  robot.respond /ph(?:ab)? version/, (msg) ->
    pkg = require path.join __dirname, '..', 'package.json'
    msg.send "hubot-phabs module is version #{pkg.version}"
    msg.finish()


  robot.respond (/ph(?:ab)? new ([-_a-zA-Z0-9]+) ([^=]*)(?: = (.*))?$/), (msg) ->
    column = phabColumns[msg.match[1]]
    name = msg.match[2]
    description = msg.match[3]
    if column?
      phab.createTask msg, column, name, description, (body) ->
        if body['error_info']?
          msg.send "#{body['error_info']}"
        else
          id = body['result']['object']['id']
          url = process.env.PHABRICATOR_URL + "/T#{id}"
{'fraction_non_alphanumeric': 0.15390604723592005, 'fraction_numerical': 0.005190760446405399, 'mean_word_length': 3.325476992143659, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 30, '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': '3353183', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1336, 'n_words': 362}