Skip to content

Commit

Permalink
[#151] Print issue link when create the issue (#166)
Browse files Browse the repository at this point in the history
Resolves #151
  • Loading branch information
vrom911 authored Jun 25, 2020
1 parent 95980e6 commit 5333b70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ The changelog is available [on GitHub][2].
* [#133](https://github.com/kowainik/hit-on/pull/133):
Move to GHC-8.8.2.
* Use `colourista` for terminal output formatting.
* [#151](https://github.com/kowainik/hit-on/issues/151):
Print the issue link with `hit new NUM` and `hit new --issue` commands.
* [#156](https://github.com/kowainik/hit-on/issues/156):
Strip `[RFC]` prefix from issues in branch names and commit messages.
* [#152](https://github.com/kowainik/hit-on/issues/152):
Filter out PRs from the list of all issues in the `hit issue` command.

### 0.1.0.0 — Aug 3, 2019

Expand Down
9 changes: 8 additions & 1 deletion src/Hit/Git/New.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module Hit.Git.New
import Data.Char (isAlphaNum, isDigit, isSpace)

import Colourista (errorMessage, infoMessage, successMessage)
import GitHub (Issue (issueNumber, issueTitle), IssueNumber (..), unIssueNumber)
import GitHub (Issue (issueHtmlUrl, issueNumber, issueTitle), IssueNumber (..), getUrl,
unIssueNumber)

import Hit.Formatting (stripRfc)
import Hit.Git.Common (getUsername)
Expand Down Expand Up @@ -38,6 +39,7 @@ runNew isIssue issueOrName = do
let issueNum = issueNumber issue
successMessage $ "Successfully created issue number #"
<> show (unIssueNumber issueNum)
showIssueLink issue
pure $ Just issueNum

{- | This data type represents all cases on how to create short branch
Expand Down Expand Up @@ -76,6 +78,7 @@ assignAndDisplayBranchDescription username = \case
FromIssueNumber issueNum -> do
issue <- fetchIssue $ mkIssueId issueNum
assignIssue issue username
showIssueLink issue
pure $ nameWithNumber issueNum $ issueTitle issue
where
nameWithNumber :: Int -> Text -> Text
Expand All @@ -93,3 +96,7 @@ assignAndDisplayBranchDescription username = \case
|| c `elem` ("_-./" :: String)
)
. stripRfc

showIssueLink :: Issue -> IO ()
showIssueLink issue = whenJust (issueHtmlUrl issue) $ \url ->
infoMessage $ " Issue link: " <> getUrl url

0 comments on commit 5333b70

Please sign in to comment.