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
+ # Listens for #nnn or repo-name#nnn and links to the issue on github.
16
+ # Defaults to issues in HUBOT_GITHUB_REPO, unless a repo is specified
15
17
#
16
18
# Notes:
17
19
# HUBOT_GITHUB_API allows you to set a custom URL path (for Github enterprise users)
21
23
22
24
module .exports = (robot ) ->
23
25
github = require (" githubot" )(robot)
24
- robot .hear / . * (#(\d + )). * / , (msg ) ->
25
- issue_number = msg .match [1 ]. replace / # / , " "
26
+ robot .hear / . * ( ( \S * ) ? #(\d + )). * / , (msg ) ->
27
+ issue_number = msg .match [3 ]
26
28
if isNaN (issue_number)
27
29
return
28
-
29
- bot_github_repo = github .qualified_repo process .env .HUBOT_GITHUB_REPO
30
+
31
+ if msg .match [2 ] == undefined
32
+ bot_github_repo = github .qualified_repo process .env .HUBOT_GITHUB_REPO
33
+ else
34
+ bot_github_repo = github .qualified_repo msg .match [2 ]
35
+
30
36
issue_title = " "
31
37
base_url = process .env .HUBOT_GITHUB_API || ' https://api.github.com'
38
+
32
39
github .get " #{ base_url} /repos/#{ bot_github_repo} /issues/" + issue_number, (issue_obj ) ->
33
40
issue_title = issue_obj .title
34
41
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} "
42
+ url = " https://github.com"
43
+ else
44
+ url = base_url .replace / \/ api\/ v3/ , ' '
45
+ msg .send " Issue #{ issue_number} : #{ issue_title} #{ url} /#{ bot_github_repo} /issues/#{ issue_number} "
0 commit comments