update github repo information

This commit is contained in:
rnhmjoj 2017-02-27 15:35:53 +01:00
parent 7fb4039efd
commit 4bd370ee57
No known key found for this signature in database
GPG Key ID: 362BB82B7E496B7C

View File

@ -5,10 +5,11 @@
# "github": "0.2.4" # "github": "0.2.4"
# #
# Commands: # Commands:
# asjon mostra le issue - mostra le issue aperte su fazo96/asjon # asjon mostra le issue - mostra le issue aperte su rnhmjoj/asjon
# #
# Author: # Author:
# Enrico Fasoli (fazo96) # Enrico Fasoli (fazo96)
# Michele Guerini Rocco (rnhmjoj)
GitHubAPI = require 'github' GitHubAPI = require 'github'
github = new GitHubAPI version: '3.0.0' github = new GitHubAPI version: '3.0.0'
@ -16,19 +17,19 @@ github = new GitHubAPI version: '3.0.0'
module.exports = (robot) -> module.exports = (robot) ->
githubhook = (req, res) -> githubhook = (req, res) ->
res.send 200 res.send 200
dest = name: req.params.name, room: req.params.room.replace(':','#') dest = name: req.params.name, room: id: req.params.room
robot.emit 'githubhook', req.body, req.params robot.emit 'githubhook', req.body, req.params
s = 'Branch '+req.body.ref+' aggiornato!\n' s = "branch #{req.body.ref} aggiornato!\n"
cm = req.body.commits.map (c) -> cm = req.body.commits.map (c) ->
[c.committer.username,c.message].join ' -> ' [c.committer.username, c.message].join ' -> '
robot.send dest, s+cm.join('\n') robot.send dest, s + cm.join '\n'
unless process.env.TESTING_ASJON unless process.env.TESTING_ASJON
# Disabilito http route durante i test # Disabilito http route durante i test
robot.router.post '/hubot/githubhook/:room/:name?', githubhook robot.router.post '/hubot/githubhook/:room/:name?', githubhook
robot.respond /(?:(?:mostra(?:mi)?|fammi vedere) )?(?:le )?issue(?:s)?/i, (res) -> robot.respond /(?:(?:mostra(?:mi)?|fammi vedere) )?(?:le )?issue(?:s)?/i, (res) ->
msg = state: 'open', user: 'fazo96', repo: 'asjon', sort: 'updated' msg = state: 'open', user: 'rnhmjoj', repo: 'asjon', sort: 'updated'
res.send 'controllo issues...' res.send 'controllo issues...'
github.issues.repoIssues msg, (err,data) -> github.issues.repoIssues msg, (err,data) ->
if err then return res.send err if err then return res.send err
@ -40,7 +41,7 @@ module.exports = (robot) ->
res.send r.join '\n' res.send r.join '\n'
robot.respond /linkami (?:la )?issue (?:(?:n(?:°)?(?: )?)|numero )?(\d+)/i, (res) -> robot.respond /linkami (?:la )?issue (?:(?:n(?:°)?(?: )?)|numero )?(\d+)/i, (res) ->
base = 'http://github.com/fazo96/asjon/issues/' base = 'http://github.com/rnhmjoj/asjon/issues/'
res.send base+res.match[1] res.send base+res.match[1]
robot.respond /linkami (?:la )?repo (\w+\/\w+)/i, (res) -> robot.respond /linkami (?:la )?repo (\w+\/\w+)/i, (res) ->