Skip to content

Commit

Permalink
Merge pull request #121 from mattpolzin/add-rq-command-alias
Browse files Browse the repository at this point in the history
Add rq alias for request command
  • Loading branch information
mattpolzin authored Mar 8, 2024
2 parents 51c4fab + 52a7dd9 commit 9bc2b1a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 36 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ Note that labels are _not_ prefixed with '#' for this command. There is no need
### Request
Running `harmony request {<team> | +<user>} [#<label>] [...]` will help you create a PR if one does not exist yet and then it will request reviews from teams and/or users.

There is also a `harmony rq` alias for `harmony request`.

If `harmony config requestUsers` is `True` (defualt) then harmony will pick someone to review the PR (from one of the listed teams). If `harmony config requestTeams` is `True` (default) then harmony will request reviews from the teams you listed. If `harmony config commentOnRequest` is `True` then harmony will comment on the Pull Request indicating that teams & users were "harmoniously requested" -- this comment will @mention requested users so it may be useful or annoying depending on the requested user's GitHub notification settings.

You can also require that specific additional users (on top of the one Harmony will pick for you) are requested to review the PR. You do this by specifying those users' logins prefixed with '+' as arguments to Harmony. This will request review from those specific additional users regardless of the `requestUsers` setting; that setting controls whether Harmony picks users from each Team you specify to review PRs.
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
};

harmonyPkg = buildIdris {
version = "4.0.2";
version = "4.1.0";
ipkgName = "harmony";
src = ./.;

Expand Down
2 changes: 1 addition & 1 deletion harmony.ipkg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package harmony
version = 4.0.2
version = 4.1.0
authors = "Mathew Polzin"
license = "MIT"
brief = "Harmony GitHub collaboration tool"
Expand Down
2 changes: 1 addition & 1 deletion node-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
args = {
name = "_at_mattpolzin_slash_harmony";
packageName = "@mattpolzin/harmony";
version = "4.0.2";
version = "4.1.0";
src = ./.;
dependencies = [
sources."@kwsites/file-exists-1.1.1"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mattpolzin/harmony",
"version": "4.0.2",
"version": "4.1.0",
"engines": {
"node": ">=18.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/AppVersion.idr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module AppVersion

export
appVersion : String
appVersion = "4.0.2"
appVersion = "4.1.0"

export
printVersion : HasIO io => io ()
Expand Down
57 changes: 28 additions & 29 deletions src/BashCompletion.idr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Data.String

allRootCmds : List String
allRootCmds = [ "request"
, "rq"
, "assign" -- TODO 5.0.0: <- remove this alias for the deprecated assign command.
, "branch"
, "config"
Expand Down Expand Up @@ -118,6 +119,24 @@ cmdOpts "graph" partialArg _ =
-- anything else requires configuration being loaded
cmdOpts _ _ _ = Nothing
optsForRequestCmd : Config => String -> List String
optsForRequestCmd @{config} partialArg =
if partialArg `isPrefixOf` "--dry"
then ["--dry"]
else slugsOrLoginsOrLabels
where
-- If the word being typed is prefixed with '+' return user logins
-- but otherwise return team slugs.
slugsOrLoginsOrLabels : List String
slugsOrLoginsOrLabels =
if "+" `isPrefixOf` partialArg
then (strCons '+') <$> config.orgMembers
else if isHashPrefix partialArg
then hashify . slugify <$> config.repoLabels
else config.teamSlugs
export
opts : Config => (subcommand : String) -> (curWord : String) -> (prevWord : String) -> List String
-- we assume we are not handling a root command (see @cmdOpts@ which
Expand Down Expand Up @@ -156,41 +175,21 @@ opts @{config} "pr" partialArg _ =
-- for the deprecated assign command.
opts @{config} "assign" "--" "assign" = "--dry" :: config.teamSlugs
opts @{config} "assign" "--" _ = config.teamSlugs
opts @{config} "assign" partialArg _ =
if partialArg `isPrefixOf` "--dry"
then ["--dry"]
else slugsOrLoginsOrLabels
where
-- If the word being typed is prefixed with '+' return user logins
-- but otherwise return team slugs.
slugsOrLoginsOrLabels : List String
slugsOrLoginsOrLabels =
if "+" `isPrefixOf` partialArg
then (strCons '+') <$> config.orgMembers
else if isHashPrefix partialArg
then hashify . slugify <$> config.repoLabels
else config.teamSlugs
opts "assign" partialArg _ =
optsForRequestCmd partialArg
-- finally, request auto-completes with
-- either a team slug or '+' followed by a user login:
opts @{config} "rq" "--" "rq" = "--dry" :: config.teamSlugs
opts @{config} "request" "--" "request" = "--dry" :: config.teamSlugs
opts @{config} "rq" "--" _ = config.teamSlugs
opts @{config} "request" "--" _ = config.teamSlugs
opts @{config} "request" partialArg _ =
if partialArg `isPrefixOf` "--dry"
then ["--dry"]
else slugsOrLoginsOrLabels
where
-- If the word being typed is prefixed with '+' return user logins
-- but otherwise return team slugs.
slugsOrLoginsOrLabels : List String
slugsOrLoginsOrLabels =
if "+" `isPrefixOf` partialArg
then (strCons '+') <$> config.orgMembers
else if isHashPrefix partialArg
then hashify . slugify <$> config.repoLabels
else config.teamSlugs
opts "rq" partialArg _ =
optsForRequestCmd partialArg
opts "request" partialArg _ =
optsForRequestCmd partialArg
opts @{_} _ _ _ = []
opts _ _ _ = []
||| The Bash Completion script calls to harmony with a special --bash-completion
||| flag and passes harmony the subcommand (i.e. first argument after harmony),
Expand Down
2 changes: 2 additions & 0 deletions src/Help.idr
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ subcommandHelp' n@"whoami" = subcommand n [] ["Print information about the conf
subcommandHelp' n@"reflect" = subcommand n [] ["Reflect on the current state of ones own PRs and review requests."]
subcommandHelp' n@"list" = subcommand n [argument True "<team-slug>"] ["List the members of the given GitHub Team."]
subcommandHelp' n@"health" = subcommand n [] ["Graph all open PRs grouped by the month they were created."]
subcommandHelp' n@"rq" = subcommand n [] ["Alias for 'request' command."]
subcommandHelp' n@"assign" = subcommand n [] [warning "Deprecated alias for 'request' command."]
-- TODO 5.0.0: ^ remove deprecated command help
subcommandHelp' c = pretty "Unreconized command: \{c}"
Expand Down Expand Up @@ -127,6 +128,7 @@ helpDocs = vsep
, subcommandHelp' "pr"
, subcommandHelp' "reflect"
, subcommandHelp' "request"
, subcommandHelp' "rq"
, subcommandHelp' "sync"
, subcommandHelp' "version"
, subcommandHelp' "whoami"
Expand Down
4 changes: 4 additions & 0 deletions src/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ handleAuthenticatedArgs ("assign" :: requestRest) = do
printWarning "The 'assign' command is a deprecated alias for the new 'request' command."
Commands.request requestRest

handleAuthenticatedArgs ("rq" :: "--dry" :: requestRest) =
Commands.request requestRest {dry=True}
handleAuthenticatedArgs ("request" :: "--dry" :: requestRest) =
Commands.request requestRest {dry=True}
handleAuthenticatedArgs ("rq" :: requestRest) =
Commands.request requestRest
handleAuthenticatedArgs ("request" :: requestRest) =
Commands.request requestRest
handleAuthenticatedArgs ["label"] =
Expand Down
2 changes: 2 additions & 0 deletions test/expected_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Subcommands:
these additional users by prefixing their logins with '+'.

Optionally apply any number of labels by prefixing them with '#'.
rq
Alias for 'request' command.
sync
Synchronize local config with information from GitHub.
version
Expand Down

0 comments on commit 9bc2b1a

Please sign in to comment.