git ssb

0+

cel / ssb-pull-requests



Tree: efa6ad97a49b5f3337174d89838e3695e691507a

Files: efa6ad97a49b5f3337174d89838e3695e691507a / lib / schemas.js

927 bytesRaw
1var ssbRef = require('ssb-ref')
2
3exports.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 (text == null) {
24 text = title
25 title = null
26 }
27 if (title) {
28 if (typeof title === 'string') msg.title = title
29 else throw new Error('invalid title')
30 }
31 if (text) {
32 if (typeof text === 'string') msg.text = text
33 else throw new Error('invalid text')
34 }
35
36 return msg
37}
38

Built with git-ssb-web