|
@ -1,20 +1,32 @@ |
|
|
{-# LANGUAGE OverloadedStrings #-} |
|
|
{-# LANGUAGE OverloadedStrings #-} |
|
|
{-# LANGUAGE FlexibleInstances #-} |
|
|
{-# LANGUAGE FlexibleInstances #-} |
|
|
|
|
|
|
|
|
module PullWatch.Types where |
|
|
module PullWatch.Types |
|
|
|
|
|
( |
|
|
|
|
|
Repo(..) |
|
|
|
|
|
, PullRequest(..) |
|
|
|
|
|
, PullRequests |
|
|
|
|
|
, RepoArgs(..) |
|
|
|
|
|
) where |
|
|
|
|
|
|
|
|
import Data.Default |
|
|
import Data.Default |
|
|
import GitHub.Data.Name |
|
|
import GitHub.Data.Name |
|
|
|
|
|
import Data.Yaml (FromJSON, withObject, (.:)) |
|
|
import System.Console.ArgParser.QuickParams (RawRead, rawParse) |
|
|
import System.Console.ArgParser.QuickParams (RawRead, rawParse) |
|
|
|
|
|
|
|
|
import qualified GitHub.Endpoints.PullRequests as PR |
|
|
import qualified GitHub.Endpoints.PullRequests as G |
|
|
import qualified Data.IntMap as IntMap |
|
|
import qualified Data.IntMap as IntMap |
|
|
import qualified Data.Text as T |
|
|
import qualified Data.Text as T |
|
|
|
|
|
import qualified Data.Yaml as Y |
|
|
|
|
|
|
|
|
-- Type definitions |
|
|
-- Type definitions |
|
|
|
|
|
|
|
|
type PullRequests = IntMap.IntMap PullRequest |
|
|
type PullRequests = IntMap.IntMap PullRequest |
|
|
|
|
|
|
|
|
|
|
|
data Repo = Repo (G.Name G.Owner) |
|
|
|
|
|
(G.Name G.Repo) |
|
|
|
|
|
deriving (Show, Eq) |
|
|
|
|
|
|
|
|
data PullRequest = PR { |
|
|
data PullRequest = PR { |
|
|
prText :: T.Text |
|
|
prText :: T.Text |
|
|
, prTitle :: T.Text |
|
|
, prTitle :: T.Text |
|
@ -23,10 +35,10 @@ data PullRequest = PR { |
|
|
, prID :: Integer |
|
|
, prID :: Integer |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
deriving (Show) |
|
|
deriving (Show, Eq) |
|
|
|
|
|
|
|
|
data RepoArgs = RepoArgs (PR.Name PR.Owner) |
|
|
data RepoArgs = RepoArgs (G.Name G.Owner) |
|
|
(PR.Name PR.Repo) |
|
|
(G.Name G.Repo) |
|
|
deriving (Show) |
|
|
deriving (Show) |
|
|
|
|
|
|
|
|
instance Default PullRequest where |
|
|
instance Default PullRequest where |
|
@ -38,5 +50,15 @@ instance Default PullRequest where |
|
|
, prID = 0 |
|
|
, prID = 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
instance RawRead (PR.Name a) where |
|
|
instance RawRead (G.Name a) where |
|
|
rawParse x = Just (N $ T.pack x, x) |
|
|
rawParse x = Just (N $ T.pack x, x) |
|
|
|
|
|
|
|
|
|
|
|
instance FromJSON Repo where |
|
|
|
|
|
parseJSON = withObject "Repo" $ \v -> makeRepo |
|
|
|
|
|
<$> v .: "owner" |
|
|
|
|
|
<*> v .: "repo" |
|
|
|
|
|
|
|
|
|
|
|
-- Smart constructor for Repo type |
|
|
|
|
|
makeRepo owner repo = Repo (c owner) |
|
|
|
|
|
(c repo) where |
|
|
|
|
|
c = N . T.pack |
|
|