packages feed

gerrit 0.1.2.0 → 0.1.3.0

raw patch · 3 files changed

+17/−10 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +## 0.1.3.0 (2021-10.21)++- Honor the authentication for get request+ ## 0.1.2.0 (2021-10-18)  - Add missing Eq and Show instances
gerrit.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                gerrit-version:             0.1.2.0+version:             0.1.3.0 synopsis:            A gerrit client library description:     Gerrit is a client library to interface with https://www.gerritcodereview.com/
src/Gerrit/Client.hs view
@@ -52,14 +52,18 @@   Left err -> error $ "Decoding of " <> show (responseBody response) <> " failed with: " <> err   Right a -> pure a +gerritRequest :: Text -> GerritClient -> IO Request+gerritRequest path GerritClient {..} =+  case auth of+    Just (user, pass) ->+      applyBasicAuth (T.encodeUtf8 user) (T.encodeUtf8 pass)+        <$> parseUrlThrow (unpack $ baseUrl <> "a/" <> path)+    Nothing -> parseUrlThrow (unpack $ baseUrl <> path)+ gerritPost :: (ToJSON a, FromJSON b) => Text -> a -> GerritClient -> IO b-gerritPost path postData GerritClient {..} =+gerritPost path postData client@GerritClient {..} =   do-    initRequest <- case auth of-      Just (user, pass) ->-        applyBasicAuth (T.encodeUtf8 user) (T.encodeUtf8 pass)-          <$> parseUrlThrow (unpack $ baseUrl <> "a/" <> path)-      Nothing -> parseUrlThrow (unpack $ baseUrl <> path)+    initRequest <- gerritRequest path client     let request =           initRequest             { method = "POST",@@ -70,9 +74,8 @@     gerritDecode response  gerritGet :: (FromJSON a) => Text -> GerritClient -> IO a-gerritGet path GerritClient {..} =+gerritGet path client@GerritClient {..} =   do-    let url = baseUrl <> path-    request <- parseUrlThrow (unpack url)+    request <- gerritRequest path client     response <- httpLbs request manager     gerritDecode response