-
Notifications
You must be signed in to change notification settings - Fork 1
/
github-activity.coffee
43 lines (40 loc) · 1.21 KB
/
github-activity.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Description:
# None
#
# Dependencies:
# "date-utils": ">=1.2.5"
# "githubot": "0.4.x"
#
# Configuration:
# HUBOT_GITHUB_TOKEN
# HUBOT_GITHUB_USER
# HUBOT_GITHUB_API
#
# Commands:
# hubot repo show <repo> - shows activity of repository
#
# Notes:
# HUBOT_GITHUB_API allows you to set a custom URL path (for Github enterprise users)
#
# Author:
# vquaiato
require('date-utils')
module.exports = (robot) ->
github = require("githubot")(robot)
robot.respond /repo show (.*)$/i, (msg) ->
repo = github.qualified_repo msg.match[1]
base_url = process.env.HUBOT_GITHUB_API || 'https://api.github.com'
url = "#{base_url}/repos/#{repo}/commits"
github.get url, (commits) ->
if commits.message
msg.send "Achievement unlocked: [NEEDLE IN A HAYSTACK] repository #{commits.message}!"
else if commits.length == 0
msg.send "Achievement unlocked: [LIKE A BOSS] no commits found!"
else
msg.send "https://github.com/#{repo}"
send = 5
for c in commits
if send
d = new Date(Date.parse(c.commit.committer.date)).toFormat("DD/MM HH24:MI")
msg.send "[#{d} -> #{c.commit.committer.name}] #{c.commit.message}"
send -= 1