1
1
# Description:
2
2
# Github issue link looks for #nnn and links to that issue for your default
3
3
# repo. Eg. "Hey guys check out #273"
4
+ # Defaults to issues in HUBOT_GITHUB_REPO, unless a repo is specified Eg. "Hey guys, check out awesome-repo#273"
4
5
#
5
6
# Dependencies:
6
7
# "githubot": "0.2.0"
11
12
# HUBOT_GITHUB_API
12
13
#
13
14
# Commands:
14
- # Listens for #nnn and links to the issue for your default repo on github
15
+ # #nnn - link to GitHub issue nnn for HUBOT_GITHUB_REPO project
16
+ # repo#nnn - link to GitHub issue nnn for repo project
17
+ # user/repo#nnn - link to GitHub issue nnn for user/repo project
15
18
#
16
19
# Notes:
17
20
# HUBOT_GITHUB_API allows you to set a custom URL path (for Github enterprise users)
21
24
22
25
module .exports = (robot ) ->
23
26
github = require (" githubot" )(robot)
24
- robot .hear / . * (#(\d + )). * / , (msg ) ->
25
- issue_number = msg .match [1 ]. replace / # / , " "
27
+ robot .hear / . * ( ( \S * ) ? #(\d + )). * / , (msg ) ->
28
+ issue_number = msg .match [3 ]
26
29
if isNaN (issue_number)
27
30
return
28
-
29
- bot_github_repo = github .qualified_repo process .env .HUBOT_GITHUB_REPO
31
+
32
+ if msg .match [2 ] == undefined
33
+ bot_github_repo = github .qualified_repo process .env .HUBOT_GITHUB_REPO
34
+ else
35
+ bot_github_repo = github .qualified_repo msg .match [2 ]
36
+
30
37
issue_title = " "
31
38
base_url = process .env .HUBOT_GITHUB_API || ' https://api.github.com'
39
+
32
40
github .get " #{ base_url} /repos/#{ bot_github_repo} /issues/" + issue_number, (issue_obj ) ->
33
41
issue_title = issue_obj .title
34
42
unless process .env .HUBOT_GITHUB_API
35
- url = " https://github.com"
36
- else
37
- url = base_url .replace / \/ api\/ v3/ , ' '
38
- msg .send " Issue #{ issue_number} : #{ issue_title} #{ url} /#{ bot_github_repo} /issues/#{ issue_number} "
43
+ url = " https://github.com"
44
+ else
45
+ url = base_url .replace / \/ api\/ v3/ , ' '
46
+ msg .send " Issue #{ issue_number} : #{ issue_title} #{ url} /#{ bot_github_repo} /issues/#{ issue_number} "
0 commit comments