MCPcopy Create free account
hub / github.com/backstrokeapp/server / pullRequestsCreate

Function pullRequestsCreate

src/test-helpers/create-mock-github-instance.js:98–159  ·  view source on GitHub ↗
({owner, repo, title, head, base, body, maintainer_can_modify})

Source from the content-addressed store, hash-verified

96 }
97 },
98 pullRequestsCreate({owner, repo, title, head, base, body, maintainer_can_modify}) {
99 let r = repoDirectory.find(i => i.owner.login === owner && i.name === repo);
100 if (r) {
101 let doesPRAlreadyExist = r._pullRequests.find(i => i.head.label === head && i.base.label === base);
102 if (doesPRAlreadyExist) {
103 return Promise.reject({code: 422, error: 'Pull request already exists'});
104 }
105
106 let pr = {
107 id: generateId(),
108 number: Math.floor(Math.random() * 1000),
109 state: "open",
110 title,
111 body,
112 assignee: null,
113 milestone: null,
114 locked: false,
115 created_at: (new Date()).toISOString(),
116 updated_at: (new Date()).toISOString(),
117 labels: [],
118 head: {
119 label: head,
120 ref: head.split(':').reverse()[0],
121 sha: generateSha(),
122 },
123 base: {
124 label: base,
125 ref: base.split(':').reverse()[0],
126 sha: generateSha(),
127 },
128 user: null,
129 };
130
131 r._issues = [...r._issues, {
132 id: pr.id,
133 number: pr.number,
134 state: pr.state,
135 title: pr.title,
136 body: pr.body,
137 user: null,
138 labels: [],
139 locked: false,
140 assignee: null,
141 assignees: [],
142 milestone: null,
143 comments: 0,
144 closed_at: null,
145 pull_request: {
146 url: `https://api.github.com/repos/1egoman/backstroke/pulls/${pr.number}`,
147 html_url: `https://github.com/1egoman/backstroke/pull/${pr.number}`,
148 diff_url: `https://github.com/1egoman/backstroke/pull/${pr.number}.diff`,
149 patch_url: `https://github.com/1egoman/backstroke/pull/${pr.number}.patch`
150 },
151 }];
152
153 r._pullRequests = [...r._pullRequests, pr];
154
155 return Promise.resolve(pr);

Callers

nothing calls this directly

Calls 2

generateIdFunction · 0.85
generateShaFunction · 0.85

Tested by

no test coverage detected