File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ branch, and start working on a fresh branch.
51
51
52
52
** WARNING.** You will NOT be able to merge these commits using the
53
53
normal GitHub UI, as their branch bases won't be master. Use
54
- ` ghstack land $PR_URL ` to land a ghstack'ed pull request.
54
+ ` ghstack land $PR_URL ` (or alternatively ` ghtstack land #PR_NUM ` ) to land
55
+ a ghstack'ed pull request.
55
56
56
57
## Structure of submitted pull requests
57
58
Original file line number Diff line number Diff line change @@ -115,9 +115,23 @@ def get_github_repo_info(
115
115
)
116
116
117
117
118
- def parse_pull_request (pull_request : str ) -> GitHubPullRequestParams :
118
+ def parse_pull_request (
119
+ pull_request : str ,
120
+ * ,
121
+ sh : Optional [ghstack .shell .Shell ] = None ,
122
+ remote_name : Optional [str ] = None ,
123
+ ) -> GitHubPullRequestParams :
119
124
m = RE_PR_URL .match (pull_request )
120
125
if not m :
126
+ # We can reconstruct the URL if just a PR number is passed
127
+ if sh is not None and remote_name is not None :
128
+ remote_url = sh .git ("remote" , "get-url" , remote_name )
129
+ # Do not pass the shell to avoid infinite loop
130
+ try :
131
+ return parse_pull_request (remote_url + "/pull/" + pull_request )
132
+ except RuntimeError :
133
+ # Fall back on original error message
134
+ pass
121
135
raise RuntimeError ("Did not understand PR argument. PR must be URL" )
122
136
123
137
github_url = m .group ("github_url" )
Original file line number Diff line number Diff line change @@ -57,7 +57,9 @@ def main(
57
57
# Furthermore, the parent commits of PR are ignored: we always
58
58
# take the canonical version of the patch from any given pr
59
59
60
- params = ghstack .github_utils .parse_pull_request (pull_request )
60
+ params = ghstack .github_utils .parse_pull_request (
61
+ pull_request , sh = sh , remote_name = remote_name
62
+ )
61
63
default_branch = ghstack .github_utils .get_github_repo_info (
62
64
github = github ,
63
65
sh = sh ,
You can’t perform that action at this time.
0 commit comments