Resurrect samples/Issues/ShowRepoIssues · haskell-github/github@445c8de · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 445c8de

Browse files
committed
Resurrect samples/Issues/ShowRepoIssues
This example wasn't ported to the new API. Now it is, with some ugly `show`s still.
1 parent 568ede6 commit 445c8de

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ jobs:
203203
run: |
204204
touch cabal.project
205205
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
206-
if [ $((HCNUMVER >= 71000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/samples" >> cabal.project ; fi
206+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/samples" >> cabal.project ; fi
207207
cat cabal.project
208208
- name: sdist
209209
run: |
@@ -223,11 +223,11 @@ jobs:
223223
touch cabal.project
224224
touch cabal.project.local
225225
echo "packages: ${PKGDIR_github}" >> cabal.project
226-
if [ $((HCNUMVER >= 71000)) -ne 0 ] ; then echo "packages: ${PKGDIR_github_samples}" >> cabal.project ; fi
226+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then echo "packages: ${PKGDIR_github_samples}" >> cabal.project ; fi
227227
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package github" >> cabal.project ; fi
228228
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
229-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package github-samples" >> cabal.project ; fi
230-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
229+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then echo "package github-samples" >> cabal.project ; fi
230+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
231231
cat >> cabal.project <<EOF
232232
constraints: github +openssl
233233
constraints: github-samples +openssl
@@ -264,8 +264,8 @@ jobs:
264264
run: |
265265
cd ${PKGDIR_github} || false
266266
${CABAL} -vnormal check
267-
if [ $((HCNUMVER >= 71000)) -ne 0 ] ; then cd ${PKGDIR_github_samples} || false ; fi
268-
if [ $((HCNUMVER >= 71000)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi
267+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then cd ${PKGDIR_github_samples} || false ; fi
268+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi
269269
- name: haddock
270270
run: |
271271
if [ $((HCNUMVER >= 80600)) -ne 0 ] ; then $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all ; fi

samples/Issues/ShowRepoIssues.hs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
module ShowRepoIssue where
1+
{-# LANGUAGE OverloadedStrings #-}
22

3-
import qualified Github.Issues as Github
3+
import qualified GitHub as Github
44
import Data.List (intercalate)
5+
import Data.Foldable (toList)
56

7+
main :: IO ()
68
main = do
7-
let limitations = [Github.OnlyClosed, Github.Mentions "mike-burns", Github.AssignedTo "jyurek"]
8-
possibleIssues <- Github.issuesForRepo "thoughtbot" "paperclip" limitations
9+
let filt = Github.stateClosed <> Github.optionsMentioned "mike-burns" <> Github.optionsAssignee "jyurek"
10+
possibleIssues <- Github.github' $ Github.issuesForRepoR "thoughtbot" "paperclip" filt Github.FetchAll
911
case possibleIssues of
10-
(Left error) -> putStrLn $ "Error: " ++ show error
11-
(Right issues) ->
12-
putStrLn $ intercalate "\n\n" $ map formatIssue issues
12+
Left err -> putStrLn $ "Error: " ++ show err
13+
Right issues ->
14+
putStrLn $ intercalate "\n\n" $ map formatIssue $ toList issues
1315

14-
formatIssue issue =
15-
(Github.githubOwnerLogin $ Github.issueUser issue) ++
16-
" opened this issue " ++
17-
(show $ Github.fromDate $ Github.issueCreatedAt issue) ++ "\n" ++
18-
(Github.issueState issue) ++ " with " ++
19-
(show $ Github.issueComments issue) ++ " comments" ++ "\n\n" ++
20-
(Github.issueTitle issue)
16+
formatIssue :: Github.Issue -> String
17+
formatIssue issue = concat
2118

19+
[ show $ Github.simpleUserLogin $ Github.issueUser issue
20+
, " opened this issue "
21+
, show $ Github.issueCreatedAt issue
22+
, ".\n"
23+
24+
, "It is currently "
25+
, show $ Github.issueState issue
26+
, " with "
27+
, show $ Github.issueComments issue
28+
, " comments.\n\n"
29+
30+
, show $ Github.issueTitle issue
31+
]

samples/github-samples.cabal

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ tested-with:
1818
GHC == 8.8.4
1919
GHC == 8.6.5
2020
GHC == 8.4.4
21-
GHC == 8.2.2
22-
GHC == 8.0.2
23-
GHC == 7.10.3
2421

2522
library
2623
hs-source-dirs: src
2724
ghc-options: -Wall
2825
build-depends:
29-
, base >=4.7 && <5
26+
, base >=4.11 && <5
27+
-- require base-4.11 because then (<>) is in Prelude
3028
, base-compat-batteries
3129
, github
3230
, text
@@ -149,6 +147,11 @@ executable github-list-team-current
149147
-- main-is: ShowDeployKey.hs
150148
-- hs-source-dirs: Repos/DeployKeys
151149

150+
executable github-show-repo-issues
151+
import: deps
152+
main-is: ShowRepoIssues.hs
153+
hs-source-dirs: Issues
154+
152155
executable github-show-user
153156
import: deps
154157
main-is: ShowUser.hs

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.