Skip to content

Commit

Permalink
Merge pull request #133 from mattpolzin/list-teams-support
Browse files Browse the repository at this point in the history
list teams when list command is not given a team name
  • Loading branch information
mattpolzin authored Jul 2, 2024
2 parents 2f577b4 + 29d306c commit c8f52e8
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ Running `harmony reflect` will show a summary of your review requests and author
![Reflect Screenshot](./docs/images/reflect.png)

### List
Running `harmony list` will list all the teams for the configured GitHub organization.

Running `harmony list <team>` will list the members of the given GitHub Team.

### Graph
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
};

harmonyPkg = buildIdris {
version = "4.3.0";
version = "4.4.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.3.0
version = 4.4.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 @@ -607,7 +607,7 @@
args = {
name = "_at_mattpolzin_slash_harmony";
packageName = "@mattpolzin/harmony";
version = "4.3.0";
version = "4.4.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.3.0",
"version": "4.4.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.3.0"
appVersion = "4.4.0"

export
printVersion : HasIO io => io ()
Expand Down
8 changes: 8 additions & 0 deletions src/Commands.idr
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ request args {dry} = do
(users, labels) = mapHom (map $ drop 1) (userArgs, labelArgs)
in (users, teams, labels)

||| List teams for the configured org.
export
listOrgTeams : Config => Octokit =>
Promise' ()
listOrgTeams @{config} =
do teamNames <- sort <$> forceListTeams config.org
renderIO . vsep $ annotate italic . pretty <$> teamNames

||| List members of a given team when the user executes
||| `harmony list <team>`.
export
Expand Down
10 changes: 10 additions & 0 deletions src/FFI/GitHub.idr
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ listTeams : Octokit => (org : String) -> Promise OrgError (List String)
listTeams @{Kit ptr} org =
lines <$> (mapOrgError . promiseIO $ prim__listTeams ptr org)

export
forceListTeams : Octokit =>
(org : String)
-> Promise' (List String)
forceListTeams = mapError errString . listTeams
where
errString : OrgError -> String
errString NotAnOrg = "You can only list teams for repositories belonging to GitHub organizations"
errString (Msg str) = str

%foreign okit_ffi "list_my_teams"
prim__listMyTeams : Ptr OctokitRef
-> (onSuccess : String -> PrimIO ())
Expand Down
2 changes: 1 addition & 1 deletion src/Help.idr
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ subcommandHelp' n@"sync" = subcommand n [] ["Synchronize local config with in
subcommandHelp' n@"branch" = subcommand n [] ["Print the GitHub URI for the currently checked out branch."]
subcommandHelp' n@"whoami" = subcommand n [] [reflow "Print information about the configured and authenticated user."]
subcommandHelp' n@"reflect" = subcommand n [] [reflow "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@"list" = subcommand n [argument False "<team-slug>"] ["List all teams or the members of the given GitHub Team."]
subcommandHelp' n@"health" = subcommand n [] [reflow "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."]
Expand Down
2 changes: 1 addition & 1 deletion src/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ handleAuthenticatedArgs ("contribute" :: args) =
Right args => Commands.contribute args
Left err => exitError err
handleAuthenticatedArgs ["list"] =
reject "The list command expects the name of a GitHub Team as an argument."
Commands.listOrgTeams
handleAuthenticatedArgs @{config} ["list", teamName] =
Commands.list teamName
handleAuthenticatedArgs @{config} ("graph" :: args) =
Expand Down
4 changes: 2 additions & 2 deletions test/expected_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Subcommands:
label {<label>} [...]
Add one or more labels to a PR, creating a new PR if one does not exist.
Labels that do not exist yet will be created automatically.
list {<team-slug>}
List the members of the given GitHub Team.
list [<team-slug>]
List all teams or the members of the given GitHub Team.
pr [--draft] [#<label>] [...]
Identify an existing PR or create a new one for the current branch.

Expand Down

0 comments on commit c8f52e8

Please sign in to comment.