(self, upstream_sh: Optional[ghstack.shell.Shell])
| 140 | # TODO: model merged too |
| 141 | |
| 142 | def __init__(self, upstream_sh: Optional[ghstack.shell.Shell]) -> None: |
| 143 | self.repositories = {} |
| 144 | self.pull_requests = {} |
| 145 | self.issue_comments = {} |
| 146 | self._next_id = 5000 |
| 147 | self._next_pull_request_number = {} |
| 148 | self._next_issue_comment_full_database_id = {} |
| 149 | self.root = Root() |
| 150 | |
| 151 | # Populate it with the most important repo ;) |
| 152 | repo = Repository( |
| 153 | id=GraphQLId("1000"), |
| 154 | name="pytorch", |
| 155 | nameWithOwner="pytorch/pytorch", |
| 156 | isFork=False, |
| 157 | defaultBranchRef=None, |
| 158 | ) |
| 159 | self.repositories[GraphQLId("1000")] = repo |
| 160 | self._next_pull_request_number[GraphQLId("1000")] = 500 |
| 161 | self._next_issue_comment_full_database_id[GraphQLId("1000")] = 1500 |
| 162 | |
| 163 | self.upstream_sh = upstream_sh |
| 164 | if self.upstream_sh is not None: |
| 165 | # Setup upstream Git repository representing the |
| 166 | # pytorch/pytorch repository in the directory specified |
| 167 | # by upstream_sh. This is useful because some GitHub API |
| 168 | # operations depend on repository state (e.g., what |
| 169 | # the headRef is at the time a PR is created), so |
| 170 | # we need this information |
| 171 | self.upstream_sh.git("init", "--bare", "-b", "master") |
| 172 | tree = self.upstream_sh.git("write-tree") |
| 173 | commit = self.upstream_sh.git("commit-tree", tree, input="Initial commit") |
| 174 | self.upstream_sh.git("branch", "-f", "master", commit) |
| 175 | |
| 176 | # We only update this when a PATCH changes the default |
| 177 | # branch; hopefully that's fine? In any case, it should |
| 178 | # work for now since currently we only ever access the name |
| 179 | # of the default branch rather than other parts of its ref. |
| 180 | repo.defaultBranchRef = repo._make_ref(self, "master") |
| 181 | |
| 182 | |
| 183 | @dataclass |
nothing calls this directly
no test coverage detected