github 0.12 → 0.13
raw patch · 5 files changed
+34/−1 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Github.Data: instance ToJSON NewGitReference
+ Github.Data.Definitions: NewGitReference :: String -> String -> NewGitReference
+ Github.Data.Definitions: data NewGitReference
+ Github.Data.Definitions: instance Data NewGitReference
+ Github.Data.Definitions: instance Eq NewGitReference
+ Github.Data.Definitions: instance Ord NewGitReference
+ Github.Data.Definitions: instance Show NewGitReference
+ Github.Data.Definitions: instance Typeable NewGitReference
+ Github.Data.Definitions: newGitReferenceRef :: NewGitReference -> String
+ Github.Data.Definitions: newGitReferenceSha :: NewGitReference -> String
+ Github.GitData.References: createReference :: GithubAuth -> String -> String -> NewGitReference -> IO (Either Error GitReference)
Files
- Github/Data.hs +3/−0
- Github/Data/Definitions.hs +5/−0
- Github/GitData/References.hs +5/−0
- github.cabal +2/−1
- samples/GitData/References/GitCreateReference.hs +19/−0
Github/Data.hs view
@@ -189,6 +189,9 @@ <*> o .: "size" parseJSON _ = fail "Could not build a Blob" +instance ToJSON NewGitReference where+ toJSON (NewGitReference r s) = object [ "ref" .= r, "sha" .= s ]+ instance FromJSON GitReference where parseJSON (Object o) = GitReference <$> o .: "object"
Github/Data/Definitions.hs view
@@ -173,6 +173,11 @@ ,blobSize :: Int } deriving (Show, Data, Typeable, Eq, Ord) +data NewGitReference = NewGitReference {+ newGitReferenceRef :: String+ ,newGitReferenceSha :: String+} deriving (Show, Data, Typeable, Eq, Ord)+ data GitReference = GitReference { gitReferenceObject :: GitObject ,gitReferenceUrl :: String
Github/GitData/References.hs view
@@ -4,6 +4,7 @@ module Github.GitData.References ( reference ,references+,createReference ,namespacedReferences ,module Github.Data ) where@@ -24,6 +25,10 @@ references :: String -> String -> IO (Either Error [GitReference]) references user reqRepoName = githubGet ["repos", user, reqRepoName, "git", "refs"]++createReference :: GithubAuth -> String -> String -> NewGitReference -> IO (Either Error GitReference)+createReference auth owner reqRepoName newRef =+ githubPost auth ["repos", owner, reqRepoName, "git", "refs"] newRef -- | Limited references by a namespace. --
github.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.12+Version: 0.13 -- A short (one-line) description of the package. Synopsis: Access to the Github API, v3.@@ -50,6 +50,7 @@ ,samples/Gists/ListGists.hs ,samples/Gists/ShowGist.hs ,samples/GitData/Commits/GitShow.hs+ ,samples/GitData/References/GitCreateReference.hs ,samples/GitData/References/GitLsRemote.hs ,samples/GitData/References/GitLsRemoteTags.hs ,samples/GitData/References/GitLsRemoteWithRef.hs
+ samples/GitData/References/GitCreateReference.hs view
@@ -0,0 +1,19 @@+module GitCreateRef where++import qualified Github.Auth as Auth+import Github.GitData.References++main :: IO ()+main = do+ let auth = Auth.GithubOAuth "oauthtoken"+ newlyCreatedGitRef <- createReference auth "myrepo" "myowner" NewGitReference {+ newGitReferenceRef = "refs/heads/fav_tag"+ ,newGitReferenceSha = "aa218f56b14c9653891f9e74264a383fa43fefbd"+ }+ case newlyCreatedGitRef of+ (Left err) -> putStrLn $ "Error: " ++ show err+ (Right newRef) -> putStrLn . formatReference $ newRef+ +formatReference :: GitReference -> String+formatReference ref =+ (gitObjectSha $ gitReferenceObject ref) ++ "\t" ++ (gitReferenceRef ref)