Skip to content

Commit

Permalink
Merge pull request #52 from mattpolzin/harmony-branch-command
Browse files Browse the repository at this point in the history
Add a `branch` command
  • Loading branch information
mattpolzin authored Jul 13, 2022
2 parents 29a47ea + ae28bd1 commit be877af
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ diff-repo
Creating config...
```

Once configured, Harmony supports the following commands: `pr`, `assign`, `contribute`, `reflect`, `list`, `graph`, `config`, and `sync`.
Once configured, Harmony supports the following commands: `branch`, `pr`, `assign`, `contribute`, `reflect`, `list`, `graph`, `config`, and `sync`.

### Branch
Running `harmony branch` will print the URI for accessing the currently checked out branch on GitHub.

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` 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.
Expand Down
1 change: 1 addition & 0 deletions src/BashCompletion.idr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Debug.Trace
allRootCmds : List String
allRootCmds = [
"assign"
, "branch"
, "config"
, "contribute"
, "graph"
Expand Down
2 changes: 2 additions & 0 deletions src/Help.idr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ harmony \{subcommand "<subcommand>"}
\{argument "properties"}: \{join ", " $ option <$> settableProps}.
\{subcommand "sync"}
- Synchronize local config with information from GitHub.
\{subcommand "branch"}
- Print the GitHub URI for the currently checked out branch.
\{subcommand "pr"}
- Identify an existing PR or create a new one for the current branch.
\{subcommand "contribute"} [\{argument "-c/--checkout"}] [\{argument "-<num>"}]
Expand Down
10 changes: 10 additions & 0 deletions src/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ parseContributeArgs args =
('-' :: skip) => map (Skip . cast) . parsePositive $ pack skip
_ => Nothing

printCurrentBranchURI : Config => Git => Promise ()
printCurrentBranchURI @{config} = do
branch <- currentBranch
let org = config.org
let repo = config.repo
let uri = "https://github.com/\{org}/\{repo}/tree/\{branch}"
putStrLn uri

handleConfiguredArgs : Config => Git => Octokit =>
List String
-> Promise ()
Expand Down Expand Up @@ -176,6 +184,8 @@ handleConfiguredArgs @{config} ["user", "--json", username] =
-- user-facing commands:
handleConfiguredArgs ["sync"] =
ignore $ syncConfig True
handleConfiguredArgs ["branch"] =
printCurrentBranchURI
handleConfiguredArgs ["pr"] =
do (Identified, pr) <- identifyOrCreatePR !currentBranch
| _ => pure ()
Expand Down

0 comments on commit be877af

Please sign in to comment.