Skip to content

Commit

Permalink
Add the -fork flag to submit PRs from forks (#77)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bluekeyes authored Jan 9, 2024
1 parent 5a5a367 commit 8dac3b6
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 71 deletions.
63 changes: 38 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,45 +64,58 @@ Usage: patch2pr [options] [patch]
Override the commit message by using the -message flag.
With the -fork and -fork-repository flags, the command can submit the pull
request from a fork repository. If an existing fork does not exist, the
command creates a new fork, which may take up to five minutes.
Options:
-base-branch=branch The branch to target with the pull request. If unset,
use the repository's default branch.
-base-branch=branch The branch to target with the pull request. If unset,
use the repository's default branch.
-draft Create a draft pull request.
-force Update the head branch even if it exists and is not a
fast-forward.
-draft Create a draft pull request.
-fork Submit the pull request from a fork instead of pushing
directly to the repository. With no other flags, use a
fork in the current account with the same name as the
target repository, creating the fork if it does not exist.
-force Update the head branch even if it exists and is not a
fast-forward.
-fork-repository=repo Submit the pull request from the named fork instead of
pushing directly to the repository, creating the fork
if it does not exist. Implies the -fork flag.
-head-branch=branch The branch to create or update with the new commit. If
unset, use 'patch2pr'.
-head-branch=branch The branch to create or update with the new commit. If
unset, use 'patch2pr'.
-json Output information about the new commit and pull request
in JSON format.
-json Output information about the new commit and pull request
in JSON format.
-message=message Message for the commit. Overrides the patch header.
-message=message Message for the commit. Overrides the patch header.
-no-pull-request Do not create a pull request after creating a commit.
-no-pull-request Do not create a pull request after creating a commit.
-patch-base=base Base commit to apply the patch to. Can be a SHA1, a
branch, or a tag. Branches and tags must start with
'refs/heads/' or 'refs/tags/' respectively. If unset,
use the repository's default branch.
-patch-base=base Base commit to apply the patch to. Can be a SHA1, a
branch, or a tag. Branches and tags must start with
'refs/heads/' or 'refs/tags/' respectively. If unset,
use the repository's default branch.
-pull-body=body The body for the pull request. If unset, use the body of
the commit message.
-pull-body=body The body for the pull request. If unset, use the body of
the commit message.
-pull-title=title The title for the pull request. If unset, use the title
of the commit message.
-pull-title=title The title for the pull request. If unset, use the title
of the commit message.
-repository=repo Repository to apply the patch to in 'owner/name' format.
Required.
-repository=repo Repository to apply the patch to in 'owner/name' format.
Required.
-token=token GitHub API token with 'repo' scope for authentication.
If unset, use the value of the GITHUB_TOKEN environment
variable.
-token=token GitHub API token with 'repo' scope for authentication.
If unset, use the value of the GITHUB_TOKEN environment
variable.
-url=url GitHub API URL. If unset, use https://api.github.com.
-url=url GitHub API URL. If unset, use https://api.github.com.
```

## Usage: Library
Expand Down
Loading

0 comments on commit 8dac3b6

Please sign in to comment.