Skip to content

Commit

Permalink
decide that the pr command should support applying labels to an exist…
Browse files Browse the repository at this point in the history
…ing PR
  • Loading branch information
mattpolzin committed Jun 28, 2023
1 parent 5d45c05 commit df22607
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ Running `harmony branch` will print the URI for accessing the currently checked
Many operating systems have an `open` command (though the name "open" is not ubiquitous); this means you can run something like `open $(harmony branch)` to open a web browser to the current branch on GitHub.

### PR
Running `harmony pr [--draft]` with a branch checked out will reach out to GitHub to determine if there is an open PR for that branch. If there is a PR, Harmony will print a URI that can be used to view the PR. If there is not a PR, Harmony will help you create one. New PRs can be created as drafts by specifying the `--draft` flag with the `pr` command.
Running `harmony pr [--draft] [#label, ...]` with a branch checked out will reach out to GitHub to determine if there is an open PR for that branch. If there is a PR, Harmony will print a URI that can be used to view the PR. If there is not a PR, Harmony will help you create one. New PRs can be created as drafts by specifying the `--draft` flag with the `pr` command.

If you need to create a PR still, you will be prompted for a branch to open the PR against (merge into, eventually), a title for the PR, and a description for the PR. If you have an `EDITOR` environment variable set, Harmony will use that editor to get the PR description from you. If you have a PR template at `.github/PULL_REQUEST_TEMPLATE.md`, Harmony will also preload that into your editor. If you do not have an `EDITOR` environment variable set, you will still be able to enter a description from the command line but PR templates are only supported when an `EDITOR` is specified.

Specifically when creating a PR, you can also specify any number of labels to apply by prefixing them with '#'. For example, `harmony pr #backport #bugfix` would create a PR and apply the `backport` and `bugfix` labels. Note that if a PR has already been created, the command you want is `harmony label` which adds labels to PRs.
You can also specify any number of labels to apply by prefixing them with '#'. For example, `harmony pr #backport #bugfix` would create a PR and apply the `backport` and `bugfix` labels.

Many operating systems have an `open` command (though the name "open" is not ubiquitous); this means you can run something like `open $(harmony pr)` to open a web browser to an existing PR for the current branch.

### Label
Running `harmony label {<label>} [...]` will help you create a PR if one does not exist yet and then it will apply the given labels to the PR.
Running `harmony label {<label>} [...]` will help you create a PR if one does not exist yet and then it will apply the given labels to the PR. This is essentially an alias for the `harmony pr` command but without support for creating draft PRs.

### Assign
Running `harmony assign {<team> | +<user>} [#<label>] [...]` will help you create a PR if one does not exist yet and then it will assign teams and/or users to the PR.
Expand Down
10 changes: 6 additions & 4 deletions src/Commands.idr
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ label @{config} labels =
putLabels = hcat . intersperse (pretty ", ") . map putLabel

||| Print the URI for the current branch's PR or create a new PR if one
||| does not exist when the user executes `harmony pr`
||| does not exist when the user executes `harmony pr`. Supports creation
||| of draft PRs (default False) and can accept any number of labels to apply
||| to the new or current PR.
export
pr : Config => Git => Octokit =>
{default False isDraft : Bool}
Expand All @@ -90,11 +92,11 @@ pr {isDraft} labelSlugs =
then do (actionTaken, pr) <- identifyOrCreatePR {isDraft} !currentBranch
case actionTaken of
Identified => putStrLn pr.webURI
Created => when (not (null labelSlugs)) $
label labelSlugs
Created => pure ()
when (not $ null labelSlugs) $
label labelSlugs
else reject "The pr command only accepts labels prefixed with '#' and the --draft flag."


||| Assign the given teams & users as reviewers when the user executes
||| `harmony assign ...`.
export
Expand Down

0 comments on commit df22607

Please sign in to comment.