MCPcopy Create free account
hub / github.com/ezyang/ghstack / _create_pull

Method _create_pull

src/ghstack/github_fake.py:369–402  ·  view source on GitHub ↗
(
        self, owner: str, name: str, input: CreatePullRequestInput
    )

Source from the content-addressed store, hash-verified

367 self.state.notify_merged(pr_resolved)
368
369 def _create_pull(
370 self, owner: str, name: str, input: CreatePullRequestInput
371 ) -> CreatePullRequestPayload:
372 state = self.state
373 id = state.next_id()
374 repo = state.repository(owner, name)
375 number = state.next_pull_request_number(repo.id)
376 baseRef = None
377 headRef = None
378 # TODO: When we support forks, this needs rewriting to stop
379 # hard coded the repo we opened the pull request on
380 if state.upstream_sh:
381 baseRef = repo._make_ref(state, input["base"])
382 headRef = repo._make_ref(state, input["head"])
383 pr = PullRequest(
384 id=id,
385 _repository=repo.id,
386 number=number,
387 closed=False,
388 url="https://github.com/{}/pull/{}".format(repo.nameWithOwner, number),
389 baseRef=baseRef,
390 baseRefName=input["base"],
391 headRef=headRef,
392 headRefName=input["head"],
393 title=input["title"],
394 body=input["body"],
395 )
396 # TODO: compute files changed
397 state.pull_requests[id] = pr
398 # This is only a subset of what the actual REST endpoint
399 # returns.
400 return {
401 "number": number,
402 }
403
404 # NB: This technically does have a payload, but we don't
405 # use it so I didn't bother constructing it.

Callers 1

restMethod · 0.95

Calls 6

PullRequestClass · 0.85
next_idMethod · 0.80
_make_refMethod · 0.80
formatMethod · 0.80
repositoryMethod · 0.45

Tested by

no test coverage detected