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

Class Repository

src/ghstack/github_fake.py:198–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196
197@dataclass
198class Repository(Node):
199 name: str
200 nameWithOwner: str
201 isFork: bool
202 defaultBranchRef: Optional["Ref"]
203
204 def pullRequest(
205 self, info: GraphQLResolveInfo, number: GitHubNumber
206 ) -> "PullRequest":
207 return github_state(info).pull_request(self, number)
208
209 def pullRequests(self, info: GraphQLResolveInfo) -> "PullRequestConnection":
210 return PullRequestConnection(
211 nodes=list(
212 filter(
213 lambda pr: self == pr.repository(info),
214 github_state(info).pull_requests.values(),
215 )
216 )
217 )
218
219 # TODO: This should take which repository the ref is in
220 # This only works if you have upstream_sh
221 def _make_ref(self, state: GitHubState, refName: str) -> "Ref":
222 # TODO: Probably should preserve object identity here when
223 # you call this with refName/oid that are the same
224 assert state.upstream_sh
225 gitObject = GitObject(
226 id=state.next_id(),
227 # TODO: this upstream_sh hardcode wrong, but ok for now
228 # because we only have one repo
229 oid=GitObjectID(state.upstream_sh.git("rev-parse", refName)),
230 _repository=self.id,
231 )
232 ref = Ref(
233 id=state.next_id(),
234 name=refName,
235 _repository=self.id,
236 target=gitObject,
237 )
238 return ref
239
240
241@dataclass

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected