1 | Configuration = require './configuration'
|
2 | _ = require('underscore')._
|
3 |
|
4 | XRegExp = require('xregexp').XRegExp
|
5 | XRegExp.install 'natives'
|
6 |
|
7 | ghUrlPattern = XRegExp "(http|https):\/\/github.com+(?<url>[a-z0-9\-\.,@\?^=%&;:\/~\+#]*[a-z0-9\-@\?^=%&;\/~\+#])?", 'i'
|
8 |
|
9 | githubPRUrlMatching = (url) ->
|
10 | prs = XRegExp.forEach url, ghUrlPattern, (matching) ->
|
11 | if (matching and _.str.include(url, 'pull'))
|
12 | pull = matching.url.split('\/')
|
13 | this.push {
|
14 | org: pull[1]
|
15 | repo: pull[2]
|
16 | number: pull[4]
|
17 | }
|
18 | , []
|
19 | prs if not _.isEmpty(prs)
|
20 |
|
21 | buildStatus = (statuses) ->
|
22 | status = statuses[0] if statuses?
|
23 | if not status? or not status.state? or status.state is 'pending'
|
24 | undefined
|
25 | else status.state is 'success'
|
26 |
|
27 | module.exports = {
|
28 | githubPRUrlMatching: githubPRUrlMatching,
|
29 | buildStatus: buildStatus
|
30 | }
|