var ssbRef = require('ssb-ref') exports.new = function (baseRepo, baseBranch, headRepo, headBranch, title, text) { if (!ssbRef.isLink(baseRepo)) throw new Error('invalid base repo id') if (!baseBranch || typeof baseBranch != 'string') throw new Error('invalid base branch') if (!ssbRef.isLink(headRepo)) throw new Error('invalid head repo id') if (!headBranch || typeof headBranch != 'string') throw new Error('invalid head branch') var msg = { type: 'pull-request', repo: baseRepo, project: baseRepo, branch: baseBranch, head_repo: headRepo, head_branch: headBranch } if (title) { if (typeof title === 'string') msg.title = title else throw new Error('invalid title') } if (text) { if (typeof text === 'string') msg.text = text else throw new Error('invalid text') } return msg }