(
pull_request: str,
*,
sh: Optional[ghstack.shell.Shell] = None,
remote_name: Optional[str] = None,
)
| 150 | |
| 151 | |
| 152 | def parse_pull_request( |
| 153 | pull_request: str, |
| 154 | *, |
| 155 | sh: Optional[ghstack.shell.Shell] = None, |
| 156 | remote_name: Optional[str] = None, |
| 157 | ) -> GitHubPullRequestParams: |
| 158 | pull_request = pull_request.lstrip("#") |
| 159 | m = RE_PR_URL.match(pull_request) |
| 160 | if not m: |
| 161 | # We can reconstruct the URL if just a PR number is passed |
| 162 | if sh is not None and remote_name is not None: |
| 163 | remote_url = sh.git("remote", "get-url", "--push", remote_name) |
| 164 | # Do not pass the shell to avoid infinite loop |
| 165 | try: |
| 166 | return parse_pull_request( |
| 167 | _normalize_remote_url(remote_url) + "/pull/" + pull_request |
| 168 | ) |
| 169 | except RuntimeError: |
| 170 | # Fall back on original error message |
| 171 | pass |
| 172 | raise RuntimeError("Did not understand PR argument. PR must be URL") |
| 173 | |
| 174 | github_url = m.group("github_url") |
| 175 | owner = m.group("owner") |
| 176 | name = m.group("name") |
| 177 | number = int(m.group("number")) |
| 178 | return {"github_url": github_url, "owner": owner, "name": name, "number": number} |
nothing calls this directly
no test coverage detected