Skip to content

Commit 8dac3b6

Browse files
authored
Add the -fork flag to submit PRs from forks (#77)
Add a new -fork flag to the CLI which will submit a pull request from a fork, creating it if it does not exist. This avoids needing write access on the target repository. Also add the -fork-repository flag, which sets a custom name and owner for the fork. The default is to create a fork with the same name as the target, owned by the current user. Last, modify the error handler to print a hint on any 404 error that the problem might be due to permissions. It should maybe print the same message on 403 errors, but I haven't seen an example of that yet.
1 parent 5a5a367 commit 8dac3b6

File tree

3 files changed

+241
-71
lines changed

3 files changed

+241
-71
lines changed

README.md

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,45 +64,58 @@ Usage: patch2pr [options] [patch]
6464
6565
Override the commit message by using the -message flag.
6666
67+
With the -fork and -fork-repository flags, the command can submit the pull
68+
request from a fork repository. If an existing fork does not exist, the
69+
command creates a new fork, which may take up to five minutes.
70+
6771
Options:
6872
69-
-base-branch=branch The branch to target with the pull request. If unset,
70-
use the repository's default branch.
73+
-base-branch=branch The branch to target with the pull request. If unset,
74+
use the repository's default branch.
75+
76+
-draft Create a draft pull request.
77+
78+
-force Update the head branch even if it exists and is not a
79+
fast-forward.
7180
72-
-draft Create a draft pull request.
81+
-fork Submit the pull request from a fork instead of pushing
82+
directly to the repository. With no other flags, use a
83+
fork in the current account with the same name as the
84+
target repository, creating the fork if it does not exist.
7385
74-
-force Update the head branch even if it exists and is not a
75-
fast-forward.
86+
-fork-repository=repo Submit the pull request from the named fork instead of
87+
pushing directly to the repository, creating the fork
88+
if it does not exist. Implies the -fork flag.
7689
77-
-head-branch=branch The branch to create or update with the new commit. If
78-
unset, use 'patch2pr'.
90+
-head-branch=branch The branch to create or update with the new commit. If
91+
unset, use 'patch2pr'.
7992
80-
-json Output information about the new commit and pull request
81-
in JSON format.
93+
-json Output information about the new commit and pull request
94+
in JSON format.
8295
83-
-message=message Message for the commit. Overrides the patch header.
96+
-message=message Message for the commit. Overrides the patch header.
8497
85-
-no-pull-request Do not create a pull request after creating a commit.
98+
-no-pull-request Do not create a pull request after creating a commit.
8699
87-
-patch-base=base Base commit to apply the patch to. Can be a SHA1, a
88-
branch, or a tag. Branches and tags must start with
89-
'refs/heads/' or 'refs/tags/' respectively. If unset,
90-
use the repository's default branch.
100+
-patch-base=base Base commit to apply the patch to. Can be a SHA1, a
101+
branch, or a tag. Branches and tags must start with
102+
'refs/heads/' or 'refs/tags/' respectively. If unset,
103+
use the repository's default branch.
91104
92-
-pull-body=body The body for the pull request. If unset, use the body of
93-
the commit message.
105+
-pull-body=body The body for the pull request. If unset, use the body of
106+
the commit message.
94107
95-
-pull-title=title The title for the pull request. If unset, use the title
96-
of the commit message.
108+
-pull-title=title The title for the pull request. If unset, use the title
109+
of the commit message.
97110
98-
-repository=repo Repository to apply the patch to in 'owner/name' format.
99-
Required.
111+
-repository=repo Repository to apply the patch to in 'owner/name' format.
112+
Required.
100113
101-
-token=token GitHub API token with 'repo' scope for authentication.
102-
If unset, use the value of the GITHUB_TOKEN environment
103-
variable.
114+
-token=token GitHub API token with 'repo' scope for authentication.
115+
If unset, use the value of the GITHUB_TOKEN environment
116+
variable.
104117
105-
-url=url GitHub API URL. If unset, use https://api.github.com.
118+
-url=url GitHub API URL. If unset, use https://api.github.com.
106119
```
107120

108121
## Usage: Library

0 commit comments

Comments
 (0)