diff --git a/Github/All.hs b/Github/All.hs
index 07b460bc..2dd05705 100644
--- a/Github/All.hs
+++ b/Github/All.hs
@@ -203,11 +203,11 @@ module Github.All (
--
-- Missing endpoints:
--
- -- * List your repositories
-- * List all public repositories
-- * List Teams
-- * Get Branch
-- * Enabling and disabling branch protection
+ currentUserReposR,
userReposR,
-- ** Collaborators
diff --git a/Github/Repos.hs b/Github/Repos.hs
index 01ad8f7d..7ace309c 100644
--- a/Github/Repos.hs
+++ b/Github/Repos.hs
@@ -6,6 +6,8 @@
--
module Github.Repos (
-- * Querying repositories
+ currentUserRepos,
+ currentUserReposR,
userRepos,
userRepos',
userReposR,
@@ -69,6 +71,19 @@ repoPublicityQueryString Member = [("type", Just "member")]
repoPublicityQueryString Public = [("type", Just "public")]
repoPublicityQueryString Private = [("type", Just "private")]
+-- | List your repositories.
+currentUserRepos :: GithubAuth -> RepoPublicity -> IO (Either Error (Vector Repo))
+currentUserRepos auth publicity =
+ executeRequest auth $ currentUserReposR publicity Nothing
+
+-- | List your repositories.
+-- See
+currentUserReposR :: RepoPublicity -> Maybe Count -> GithubRequest k(Vector Repo)
+currentUserReposR publicity =
+ GithubPagedGet ["user", "repos"] qs
+ where
+ qs = repoPublicityQueryString publicity
+
-- | The repos for a user, by their login. Can be restricted to just repos they
-- own, are a member of, or publicize. Private repos will return empty list.
--
diff --git a/github.cabal b/github.cabal
index c6ddbe68..c9e5767c 100644
--- a/github.cabal
+++ b/github.cabal
@@ -118,6 +118,7 @@ test-suite github-test
other-modules:
Github.CommitsSpec
Github.OrganizationsSpec
+ Github.ReposSpec
Github.SearchSpec
Github.UsersSpec
main-is: Spec.hs
diff --git a/spec/Github/ReposSpec.hs b/spec/Github/ReposSpec.hs
new file mode 100644
index 00000000..6b633073
--- /dev/null
+++ b/spec/Github/ReposSpec.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE TemplateHaskell #-}
+module Github.ReposSpec where
+
+import Github.Auth (GithubAuth (..))
+import Github.Repos (currentUserRepos, userRepos', RepoPublicity(..))
+
+-- import Data.Aeson.Compat (eitherDecodeStrict)
+import Data.Either.Compat (isRight)
+-- import Data.FileEmbed (embedFile)
+import System.Environment (lookupEnv)
+import Test.Hspec (Spec, describe, it, pendingWith, shouldSatisfy)
+
+fromRightS :: Show a => Either a b -> b
+fromRightS (Right b) = b
+fromRightS (Left a) = error $ "Expected a Right and got a Left" ++ show a
+
+withAuth :: (GithubAuth -> IO ()) -> IO ()
+withAuth action = do
+ mtoken <- lookupEnv "GITHUB_TOKEN"
+ case mtoken of
+ Nothing -> pendingWith "no GITHUB_TOKEN"
+ Just token -> action (GithubOAuth token)
+
+spec :: Spec
+spec = do
+ describe "currentUserRepos" $ do
+ it "works" $ withAuth $ \auth -> do
+ cs <- currentUserRepos auth All
+ cs `shouldSatisfy` isRight
+
+ describe "userRepos" $ do
+ it "works" $ withAuth $ \auth -> do
+ cs <- userRepos' (Just auth) "phadej" All
+ cs `shouldSatisfy` isRight