Files: 5979212beeb4303448d8f5b77e6f6d24b3cb08d3 / lib / schemas.js
867 bytesRaw
1 | var ssbRef = require('ssb-ref') |
2 | |
3 | exports.new = function (baseRepo, baseBranch, headRepo, headBranch, |
4 | title, text) { |
5 | if (!ssbRef.isLink(baseRepo)) |
6 | throw new Error('invalid base repo id') |
7 | if (!baseBranch || typeof baseBranch != 'string') |
8 | throw new Error('invalid base branch') |
9 | if (!ssbRef.isLink(headRepo)) |
10 | throw new Error('invalid head repo id') |
11 | if (!headBranch || typeof headBranch != 'string') |
12 | throw new Error('invalid head branch') |
13 | |
14 | var msg = { |
15 | type: 'pull-request', |
16 | repo: baseRepo, |
17 | project: baseRepo, |
18 | branch: baseBranch, |
19 | head_repo: headRepo, |
20 | head_branch: headBranch |
21 | } |
22 | |
23 | if (title) { |
24 | if (typeof title === 'string') msg.title = title |
25 | else throw new Error('invalid title') |
26 | } |
27 | if (text) { |
28 | if (typeof text === 'string') msg.text = text |
29 | else throw new Error('invalid text') |
30 | } |
31 | |
32 | return msg |
33 | } |
34 |
Built with git-ssb-web