Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Github/Data.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP, DeriveDataTypeable, OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

-- | This module re-exports the @Github.Data.Definitions@ module, adding
-- instances of @FromJSON@ to it. If you wish to use the data without the
Expand All @@ -13,7 +14,9 @@ module Github.Data (
module Github.Data.Teams,
) where

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad
import qualified Data.Text as T
import Data.Aeson.Compat
Expand All @@ -38,9 +41,15 @@ import Github.Data.Teams

instance FromJSON GithubDate where
parseJSON (String t) =
case parseTime defaultTimeLocale "%FT%T%Z" (T.unpack t) of
case pt defaultTimeLocale "%FT%T%Z" (T.unpack t) of
Just d -> pure $ GithubDate d
_ -> fail "could not parse Github datetime"
where
#if MIN_VERSION_time(1,5,0)
pt = parseTimeM True
#else
pt = parseTime
#endif
parseJSON _ = fail "Given something besides a String"

instance FromJSON Commit where
Expand Down
12 changes: 10 additions & 2 deletions Github/Private.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
--
module Github.Private where

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Github.Data
import Control.DeepSeq (NFData)
import Data.Aeson
import Data.Attoparsec.ByteString.Lazy
import Data.Data
import Data.Monoid
import Control.Applicative
import Data.List
import Data.CaseInsensitive (mk)
import qualified Data.ByteString.Char8 as BS
Expand Down Expand Up @@ -169,7 +171,13 @@ doHttps reqMethod url auth body = do
getOAuth (GithubOAuth token) = [(mk (BS.pack "Authorization"),
BS.pack ("token " ++ token))]
getOAuth _ = []
getResponse request = withManager $ \manager -> httpLbs request manager
getResponse request = do
manager <- newManager tlsManagerSettings
x <- httpLbs request manager
#if !MIN_VERSION_http_client(0, 4, 18)
closeManager manager
#endif
pure x
#if MIN_VERSION_http_conduit(1, 9, 0)
successOrMissing s@(Status sci _) hs cookiejar
#else
Expand Down
3 changes: 3 additions & 0 deletions Github/Repos/Webhooks/Validate.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Verification of incomming webhook payloads, as described at
Expand All @@ -7,7 +8,9 @@ module Github.Repos.Webhooks.Validate (
isValidPayload
) where

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Crypto.Hash
import qualified Data.ByteString.Char8 as BS
import Data.Byteable (constEqBytes, toBytes)
Expand Down
1 change: 1 addition & 0 deletions github.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Library
text,
old-locale,
http-conduit >= 1.8,
http-client,
http-types,
data-default,
vector,
Expand Down