Browse Source

Fix unsafe function

pull/8/head
Wesley Kerfoot 6 years ago
parent
commit
0821486b5c
  1. 19
      src/PullWatch/PullWatch.hs

19
src/PullWatch/PullWatch.hs

@ -25,7 +25,7 @@ import Data.Default
import Data.IntMap (IntMap, (\\)) import Data.IntMap (IntMap, (\\))
import Data.Maybe import Data.Maybe
import Data.Monoid import Data.Monoid
import Data.Vector ((!)) import Data.Vector ((!?))
import GitHub.Data.Id (untagId) import GitHub.Data.Id (untagId)
import GitHub.Data.Name (untagName) import GitHub.Data.Name (untagName)
import Prelude.Compat import Prelude.Compat
@ -58,11 +58,11 @@ instance Default PullRequest where
tenMinutes = 300000000*2 tenMinutes = 300000000*2
getPRId = Just . fromIntegral . untagId . simplePullRequestId . (! 0) getPRId = Just . fromIntegral . untagId . simplePullRequestId
getPRTitle = Just . simplePullRequestTitle . (! 0) getPRTitle = Just . simplePullRequestTitle
getPRBody = simplePullRequestBody . (! 0) getPRBody = simplePullRequestBody
-- Converts a pull request into a dbus notification -- Converts a pull request into a dbus notification
toNote :: PullRequest -> Note toNote :: PullRequest -> Note
@ -83,17 +83,20 @@ getLatest :: (?pat :: (Maybe Auth.Auth)) =>
(PR.Name PR.Repo) -> (PR.Name PR.Repo) ->
IO (Maybe PullRequest) IO (Maybe PullRequest)
-- TODO fix this crap
getLatest owner repo = do getLatest owner repo = do
prs <- PR.pullRequestsFor' ?pat owner repo prs <- PR.pullRequestsFor' ?pat owner repo
let pr = case prs of let pr = case prs of
(Left _) -> Nothing (Left _) -> Nothing
(Right pullreqs) -> do (Right pullreqs) -> do
id <- getPRId pullreqs firstPR <- pullreqs !? 0
title <- getPRTitle pullreqs
body <- getPRBody pullreqs id <- getPRId firstPR
title <- getPRTitle firstPR
body <- getPRBody firstPR
let repoName = untagName repo let repoName = untagName repo
let repoOwner = untagName owner let repoOwner = untagName owner
return $ PR body title repoName repoOwner id return $ PR body title repoName repoOwner id
return pr return pr

Loading…
Cancel
Save