packages feed

github-tools 0.1.0 → 0.1.1

raw patch · 4 files changed

+16/−10 lines, 4 files

Files

github-tools.cabal view
@@ -1,5 +1,5 @@ name:                github-tools-version:             0.1.0+version:             0.1.1 synopsis:            Various Github helper utilities. homepage:            https://toktok.github.io/ license:             AGPL-3
src/Requests.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DataKinds #-} module Requests where  import           Control.Monad.Catch (throwM)@@ -6,12 +7,18 @@   request-  :: GitHub.Auth+  :: Maybe GitHub.Auth   -> Manager-  -> GitHub.Request k a+  -> GitHub.Request GitHub.RO a   -> IO a request auth mgr req = do-  response <- GitHub.executeRequestWithMgr mgr auth req+  response <- executeRequest   case response of     Left  err -> throwM err     Right res -> return res++  where+    executeRequest =+      case auth of+        Nothing -> GitHub.executeRequestWithMgr' mgr req+        Just tk -> GitHub.executeRequestWithMgr mgr tk req
src/changelog.hs view
@@ -16,7 +16,7 @@ import qualified GitHub import           Network.HTTP.Client     (newManager) import           Network.HTTP.Client.TLS (tlsManagerSettings)-import           System.Environment      (getArgs, getEnv)+import           System.Environment      (getArgs, lookupEnv) -- import           Text.Groom              (groom)  import           Requests@@ -129,8 +129,7 @@ fetchChangeLog :: GitHub.Name GitHub.Owner -> GitHub.Name GitHub.Repo -> IO ChangeLog fetchChangeLog ownerName repoName = do   -- Get auth token from the $GITHUB_TOKEN environment variable.-  token <- BS8.pack <$> getEnv "GITHUB_TOKEN"-  let auth = GitHub.OAuth token+  auth <- fmap (GitHub.OAuth . BS8.pack) <$> lookupEnv "GITHUB_TOKEN"    -- Initialise HTTP manager so we can benefit from keep-alive connections.   mgr <- newManager tlsManagerSettings
src/pull-status.hs view
@@ -26,7 +26,7 @@   -> GitHub.SimplePullRequest   -> IO GitHub.PullRequest getFullPr auth mgr owner repo simplePr = do-  request auth mgr+  request (Just auth) mgr     . GitHub.pullRequestR owner repo     . GitHub.Id     . GitHub.simplePullRequestNumber@@ -59,7 +59,7 @@   -> IO [PullRequestInfo] getPrsForRepo auth mgr ownerName repoName = do   -- Get PR list.-  simplePRs <- V.toList <$> request auth mgr (GitHub.pullRequestsForR ownerName repoName GitHub.stateOpen GitHub.FetchAll)+  simplePRs <- V.toList <$> request (Just auth) mgr (GitHub.pullRequestsForR ownerName repoName GitHub.stateOpen GitHub.FetchAll)    prInfos <- Parallel.mapM (getPrInfo auth mgr ownerName repoName) simplePRs @@ -82,7 +82,7 @@   mgr <- newManager tlsManagerSettings    -- Get repo list.-  repos <- V.toList <$> request auth mgr (GitHub.organizationReposR orgName GitHub.RepoPublicityAll GitHub.FetchAll)+  repos <- V.toList <$> request (Just auth) mgr (GitHub.organizationReposR orgName GitHub.RepoPublicityAll GitHub.FetchAll)   let repoNames = map GitHub.repoName repos    infos <- Parallel.mapM (getPrsForRepo auth mgr ownerName) repoNames