github-0.7.2/0000755000000000000000000000000012247053344011174 5ustar0000000000000000github-0.7.2/github.cabal0000644000000000000000000001601312247053344013443 0ustar0000000000000000-- github.cabal auto-generated by cabal init. For additional options, -- see -- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr. -- The name of the package. Name: github -- 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.7.2 -- A short (one-line) description of the package. Synopsis: Access to the Github API, v3. -- A longer description of the package. Description: The Github API provides programmatic access to the full Github Web site, from Issues to Gists to repos down to the underlying git data like references and trees. This library wraps all of that, exposing a basic but Haskell-friendly set of functions and data structures. . For more of an overview please see the README: -- The license under which the package is released. License: BSD3 -- The file containing the license text. License-file: LICENSE -- The package author(s). Author: Mike Burns, John Wiegley -- An email address to which users can send suggestions, bug reports, -- and patches. Maintainer: johnw@fpcomplete.com Homepage: https://github.com/fpco/github -- A copyright notice. Copyright: Copyright 2012-2013 Mike Burns, Copyright 2013 John Wiegley Category: Network APIs Build-type: Simple -- Extra files to be distributed with the package, such as examples or -- a README. Extra-source-files: README.md ,samples/Gists/Comments/ShowComment.hs ,samples/Gists/Comments/ShowComments.hs ,samples/Gists/ListGists.hs ,samples/Gists/ShowGist.hs ,samples/GitData/Commits/GitShow.hs ,samples/GitData/References/GitLsRemote.hs ,samples/GitData/References/GitLsRemoteTags.hs ,samples/GitData/References/GitLsRemoteWithRef.hs ,samples/GitData/Trees/GitLsTree.hs ,samples/GitData/Trees/GitLsTreeRecursively.hs ,samples/Issues/Comments/ShowComment.hs ,samples/Issues/Comments/ShowComments.hs ,samples/Issues/Events/ShowEvent.hs ,samples/Issues/Events/ShowIssueEvents.hs ,samples/Issues/Events/ShowRepoEvents.hs ,samples/Issues/Labels/ShowIssueLabels.hs ,samples/Issues/Labels/ShowLabel.hs ,samples/Issues/Labels/ShowMilestoneLabels.hs ,samples/Issues/Labels/ShowRepoLabels.hs ,samples/Issues/Milestones/ShowMilestone.hs ,samples/Issues/Milestones/ShowMilestones.hs ,samples/Issues/ShowIssue.hs ,samples/Issues/ShowRepoIssues.hs ,samples/Organizations/Members/ShowMembers.hs ,samples/Organizations/ShowPublicOrganization.hs ,samples/Organizations/ShowPublicOrganizations.hs ,samples/Pulls/Diff.hs ,samples/Pulls/ListPulls.hs ,samples/Pulls/ReviewComments/ListComments.hs ,samples/Pulls/ReviewComments/ShowComment.hs ,samples/Pulls/ShowCommits.hs ,samples/Pulls/ShowPull.hs ,samples/Search/SearchRepos.hs ,samples/Repos/Collaborators/IsCollaborator.hs ,samples/Repos/Collaborators/ListCollaborators.hs ,samples/Repos/Commits/CommitComment.hs ,samples/Repos/Commits/CommitComments.hs ,samples/Repos/Commits/GitDiff.hs ,samples/Repos/Commits/GitLog.hs ,samples/Repos/Commits/GitShow.hs ,samples/Repos/Commits/RepoComments.hs ,samples/Repos/Forks/ListForks.hs ,samples/Repos/ListBranches.hs ,samples/Repos/ListContributors.hs ,samples/Repos/ListContributorsWithAnonymous.hs ,samples/Repos/ListLanguages.hs ,samples/Repos/ListOrgRepos.hs ,samples/Repos/ListTags.hs ,samples/Repos/ListUserRepos.hs ,samples/Repos/ShowRepo.hs ,samples/Repos/Watching/ListWatched.hs ,samples/Repos/Watching/ListWatchers.hs ,samples/Repos/Starring/ListStarred.hs ,samples/Users/Followers/ListFollowers.hs ,samples/Users/Followers/ListFollowing.hs ,samples/Users/ShowUser.hs ,LICENSE -- Constraint on the version of Cabal needed to build this package. Cabal-version: >=1.6 source-repository head type: git location: git://github.com/fpco/github.git Library -- Modules exported by the library. Exposed-modules: Github.Data, Github.Data.Definitions, Github.Gists, Github.Gists.Comments, Github.GitData.Commits, Github.GitData.References, Github.GitData.Trees, Github.GitData.Blobs, Github.Issues, Github.Issues.Comments, Github.Issues.Events, Github.Issues.Labels, Github.Issues.Milestones, Github.Organizations, Github.Organizations.Members, Github.PullRequests, Github.Repos, Github.Repos.Collaborators, Github.Repos.Commits, Github.Repos.Forks, Github.Repos.Watching, Github.Repos.Starring, Github.Users, Github.Users.Followers Github.Search -- Packages needed in order to build this package. Build-depends: base >= 4.0 && < 5.0, time, aeson >= 0.6.1.0, attoparsec >= 0.10.3.0, bytestring, case-insensitive >= 0.4.0.4, containers, hashable, text, old-locale, HTTP, network, http-conduit >= 1.8, conduit, failure, http-types, data-default, vector, unordered-containers >= 0.2 && < 0.3 -- Modules not exported by this package. Other-modules: Github.Private -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source. -- Build-tools: GHC-Options: -Wall -fno-warn-orphans github-0.7.2/LICENSE0000644000000000000000000000275512247053344012212 0ustar0000000000000000Copyright (c)2011, Mike Burns All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Mike Burns nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. github-0.7.2/README.md0000644000000000000000000000277712247053344012470 0ustar0000000000000000Github ------ The Github API v3 for Haskell. Some functions are missing; these are functions where the Github API did not work as expected. The full Github API is in beta and constantly improving. Installation ============ In your project's cabal file: -- Packages needed in order to build this package. Build-depends: github Or from the command line: cabal install github Example Usage ============= See the samples in the [samples/](https://github.com/fpco/github/tree/master/samples) directory. Documentation ============= For details see the reference documentation on Hackage. Each module lines up with the hierarchy of [documentation from the Github API](http://developer.github.com/v3/). Each function has a sample written for it. All functions produce an `IO (Either Error a)`, where `a` is the actual thing you want. You must call the function using IO goodness, then dispatch on the possible error message. Here's an example from the samples: import Github.Users.Followers import Data.List (intercalate) main = do possibleUsers <- usersFollowing "mike-burns" putStrLn $ either (\error -> "Error: " ++ $ show error) (intercalate "\n" . map githubUserLogin) possibleUsers Contributions ============= Please see [CONTRIBUTING.md](https://github.com/fpco/github/blob/master/CONTRIBUTING.md) for details on how you can help. Copyright ========= Copyright 2011, 2012 Mike Burns. Available under the BSD 3-clause license. github-0.7.2/Setup.hs0000644000000000000000000000005612247053344012631 0ustar0000000000000000import Distribution.Simple main = defaultMain github-0.7.2/Github/0000755000000000000000000000000012247053344012416 5ustar0000000000000000github-0.7.2/Github/Data.hs0000644000000000000000000004227612247053344013636 0ustar0000000000000000{-# LANGUAGE DeriveDataTypeable, OverloadedStrings #-} -- | This module re-exports the @Github.Data.Definitions@ module, adding -- instances of @FromJSON@ to it. If you wish to use the data without the -- instances, use the @Github.Data.Definitions@ module instead. module Github.Data (module Github.Data.Definitions) where import Data.Time import Control.Applicative import Control.Monad import qualified Data.Text as T import Data.Aeson.Types import Data.Monoid import System.Locale (defaultTimeLocale) import qualified Data.Vector as V import qualified Data.HashMap.Lazy as Map import Data.Hashable (Hashable) import Github.Data.Definitions instance FromJSON GithubDate where parseJSON (String t) = case parseTime defaultTimeLocale "%FT%T%Z" (T.unpack t) of Just d -> pure $ GithubDate d _ -> fail "could not parse Github datetime" parseJSON _ = fail "Given something besides a String" instance FromJSON Commit where parseJSON (Object o) = Commit <$> o .: "sha" <*> o .: "parents" <*> o .: "url" <*> o .: "commit" <*> o .:? "committer" <*> o .:? "author" <*> o .:< "files" <*> o .:? "stats" parseJSON _ = fail "Could not build a Commit" instance FromJSON Tree where parseJSON (Object o) = Tree <$> o .: "sha" <*> o .: "url" <*> o .:< "tree" parseJSON _ = fail "Could not build a Tree" instance FromJSON GitTree where parseJSON (Object o) = GitTree <$> o .: "type" <*> o .: "sha" <*> o .: "url" <*> o .:? "size" <*> o .: "path" <*> o .: "mode" parseJSON _ = fail "Could not build a GitTree" instance FromJSON GitCommit where parseJSON (Object o) = GitCommit <$> o .: "message" <*> o .: "url" <*> o .: "committer" <*> o .: "author" <*> o .: "tree" <*> o .:? "sha" <*> o .:< "parents" parseJSON _ = fail "Could not build a GitCommit" instance FromJSON GithubOwner where parseJSON (Object o) | o `at` "gravatar_id" == Nothing = GithubOrganization <$> o .: "avatar_url" <*> o .: "login" <*> o .: "url" <*> o .: "id" | otherwise = GithubUser <$> o .: "avatar_url" <*> o .: "login" <*> o .: "url" <*> o .: "id" <*> o .: "gravatar_id" parseJSON v = fail $ "Could not build a GithubOwner out of " ++ (show v) instance FromJSON GitUser where parseJSON (Object o) = GitUser <$> o .: "name" <*> o .: "email" <*> o .: "date" parseJSON _ = fail "Could not build a GitUser" instance FromJSON File where parseJSON (Object o) = File <$> o .: "blob_url" <*> o .: "status" <*> o .: "raw_url" <*> o .: "additions" <*> o .: "sha" <*> o .: "changes" <*> o .: "patch" <*> o .: "filename" <*> o .: "deletions" parseJSON _ = fail "Could not build a File" instance FromJSON Stats where parseJSON (Object o) = Stats <$> o .: "additions" <*> o .: "total" <*> o .: "deletions" parseJSON _ = fail "Could not build a Stats" instance FromJSON Comment where parseJSON (Object o) = Comment <$> o .:? "position" <*> o .:? "line" <*> o .: "body" <*> o .: "commit_id" <*> o .: "updated_at" <*> o .:? "html_url" <*> o .: "url" <*> o .: "created_at" <*> o .: "path" <*> o .: "user" <*> o .: "id" parseJSON _ = fail "Could not build a Comment" instance ToJSON NewComment where toJSON (NewComment b) = object [ "body" .= b ] instance ToJSON EditComment where toJSON (EditComment b) = object [ "body" .= b ] instance FromJSON Diff where parseJSON (Object o) = Diff <$> o .: "status" <*> o .: "behind_by" <*> o .: "patch_url" <*> o .: "url" <*> o .: "base_commit" <*> o .:< "commits" <*> o .: "total_commits" <*> o .: "html_url" <*> o .:< "files" <*> o .: "ahead_by" <*> o .: "diff_url" <*> o .: "permalink_url" parseJSON _ = fail "Could not build a Diff" instance FromJSON Gist where parseJSON (Object o) = Gist <$> o .: "user" <*> o .: "git_push_url" <*> o .: "url" <*> o .:? "description" <*> o .: "created_at" <*> o .: "public" <*> o .: "comments" <*> o .: "updated_at" <*> o .: "html_url" <*> o .: "id" <*> o `values` "files" <*> o .: "git_push_url" parseJSON _ = fail "Could not build a Gist" instance FromJSON GistFile where parseJSON (Object o) = GistFile <$> o .: "type" <*> o .: "raw_url" <*> o .: "size" <*> o .:? "language" <*> o .: "filename" <*> o .:? "content" parseJSON _ = fail "Could not build a GistFile" instance FromJSON GistComment where parseJSON (Object o) = GistComment <$> o .: "user" <*> o .: "url" <*> o .: "created_at" <*> o .: "body" <*> o .: "updated_at" <*> o .: "id" parseJSON _ = fail "Could not build a GistComment" instance FromJSON Blob where parseJSON (Object o) = Blob <$> o .: "url" <*> o .: "encoding" <*> o .: "content" <*> o .: "sha" <*> o .: "size" parseJSON _ = fail "Could not build a Blob" instance FromJSON GitReference where parseJSON (Object o) = GitReference <$> o .: "object" <*> o .: "url" <*> o .: "ref" parseJSON _ = fail "Could not build a GitReference" instance FromJSON GitObject where parseJSON (Object o) = GitObject <$> o .: "type" <*> o .: "sha" <*> o .: "url" parseJSON _ = fail "Could not build a GitObject" instance FromJSON Issue where parseJSON (Object o) = Issue <$> o .:? "closed_at" <*> o .: "updated_at" <*> o .: "html_url" <*> o .:? "closed_by" <*> o .: "labels" <*> o .: "number" <*> o .:? "assignee" <*> o .: "user" <*> o .: "title" <*> o .: "pull_request" <*> o .: "url" <*> o .: "created_at" <*> o .: "body" <*> o .: "state" <*> o .: "id" <*> o .: "comments" <*> o .:? "milestone" parseJSON _ = fail "Could not build an Issue" instance ToJSON NewIssue where toJSON (NewIssue t b a m ls) = object [ "title" .= t , "body" .= b , "assignee" .= a , "milestone" .= m , "labels" .= ls ] instance ToJSON EditIssue where toJSON (EditIssue t b a s m ls) = object $ filter notNull $ [ "title" .= t , "body" .= b , "assignee" .= a , "state" .= s , "milestone" .= m , "labels" .= ls ] where notNull (_, Null) = False notNull (_, _) = True instance FromJSON Milestone where parseJSON (Object o) = Milestone <$> o .: "creator" <*> o .: "due_on" <*> o .: "open_issues" <*> o .: "number" <*> o .: "closed_issues" <*> o .: "description" <*> o .: "title" <*> o .: "url" <*> o .: "created_at" <*> o .: "state" parseJSON _ = fail "Could not build a Milestone" instance FromJSON IssueLabel where parseJSON (Object o) = IssueLabel <$> o .: "color" <*> o .: "url" <*> o .: "name" parseJSON _ = fail "Could not build a Milestone" instance FromJSON PullRequestReference where parseJSON (Object o) = PullRequestReference <$> o .:? "html_url" <*> o .:? "patch_url" <*> o .:? "diff_url" parseJSON _ = fail "Could not build a PullRequest" instance FromJSON IssueComment where parseJSON (Object o) = IssueComment <$> o .: "updated_at" <*> o .: "user" <*> o .: "url" <*> o .: "created_at" <*> o .: "body" <*> o .: "id" parseJSON _ = fail "Could not build an IssueComment" instance FromJSON Event where parseJSON (Object o) = Event <$> o .: "actor" <*> o .: "event" <*> o .:? "commit_id" <*> o .: "url" <*> o .: "created_at" <*> o .: "id" <*> o .:? "issue" parseJSON _ = fail "Could not build an Event" instance FromJSON EventType where parseJSON (String "closed") = pure Closed parseJSON (String "reopened") = pure Reopened parseJSON (String "subscribed") = pure Subscribed parseJSON (String "merged") = pure Merged parseJSON (String "referenced") = pure Referenced parseJSON (String "mentioned") = pure Mentioned parseJSON (String "assigned") = pure Assigned parseJSON (String "unsubscribed") = pure Unsubscribed parseJSON _ = fail "Could not build an EventType" instance FromJSON SimpleOrganization where parseJSON (Object o) = SimpleOrganization <$> o .: "url" <*> o .: "avatar_url" <*> o .: "id" <*> o .: "login" parseJSON _ = fail "Could not build a SimpleOrganization" instance FromJSON Organization where parseJSON (Object o) = Organization <$> o .: "type" <*> o .:? "blog" <*> o .:? "location" <*> o .: "login" <*> o .: "followers" <*> o .:? "company" <*> o .: "avatar_url" <*> o .: "public_gists" <*> o .: "html_url" <*> o .:? "email" <*> o .: "following" <*> o .: "public_repos" <*> o .: "url" <*> o .: "created_at" <*> o .:? "name" <*> o .: "id" parseJSON _ = fail "Could not build an Organization" instance FromJSON PullRequest where parseJSON (Object o) = PullRequest <$> o .:? "closed_at" <*> o .: "created_at" <*> o .: "user" <*> o .: "patch_url" <*> o .: "state" <*> o .: "number" <*> o .: "html_url" <*> o .: "updated_at" <*> o .: "body" <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" <*> o .: "_links" <*> o .:? "merged_at" <*> o .: "title" <*> o .: "id" parseJSON _ = fail "Could not build a PullRequest" instance FromJSON DetailedPullRequest where parseJSON (Object o) = DetailedPullRequest <$> o .:? "closed_at" <*> o .: "created_at" <*> o .: "user" <*> o .: "patch_url" <*> o .: "state" <*> o .: "number" <*> o .: "html_url" <*> o .: "updated_at" <*> o .: "body" <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" <*> o .: "_links" <*> o .:? "merged_at" <*> o .: "title" <*> o .: "id" <*> o .:? "merged_by" <*> o .: "changed_files" <*> o .: "head" <*> o .: "comments" <*> o .: "deletions" <*> o .: "additions" <*> o .: "review_comments" <*> o .: "base" <*> o .: "commits" <*> o .: "merged" <*> o .: "mergeable" parseJSON _ = fail "Could not build a DetailedPullRequest" instance FromJSON PullRequestLinks where parseJSON (Object o) = PullRequestLinks <$> o <.:> ["review_comments", "href"] <*> o <.:> ["comments", "href"] <*> o <.:> ["html", "href"] <*> o <.:> ["self", "href"] parseJSON _ = fail "Could not build a PullRequestLinks" instance FromJSON PullRequestCommit where parseJSON (Object _) = return PullRequestCommit parseJSON _ = fail "Could not build a PullRequestCommit" instance FromJSON SearchReposResult where parseJSON (Object o) = SearchReposResult <$> o .: "total_count" <*> o .:< "items" parseJSON _ = fail "Could not build a SearchReposResult" instance FromJSON Repo where parseJSON (Object o) = Repo <$> o .: "ssh_url" <*> o .: "description" <*> o .: "created_at" <*> o .: "html_url" <*> o .: "svn_url" <*> o .: "forks" <*> o .:? "homepage" <*> o .: "fork" <*> o .: "git_url" <*> o .: "private" <*> o .: "clone_url" <*> o .: "size" <*> o .: "updated_at" <*> o .: "watchers" <*> o .: "owner" <*> o .: "name" <*> o .: "language" <*> o .:? "master_branch" <*> o .: "pushed_at" <*> o .: "id" <*> o .: "url" <*> o .: "open_issues" <*> o .:? "has_wiki" <*> o .:? "has_issues" <*> o .:? "has_downloads" <*> o .:? "parent" <*> o .:? "source" parseJSON _ = fail "Could not build a Repo" instance FromJSON RepoRef where parseJSON (Object o) = RepoRef <$> o .: "owner" <*> o .: "name" parseJSON _ = fail "Could not build a RepoRef" instance FromJSON Contributor where parseJSON (Object o) | o `at` "type" == (Just "Anonymous") = AnonymousContributor <$> o .: "contributions" <*> o .: "name" | otherwise = KnownContributor <$> o .: "contributions" <*> o .: "avatar_url" <*> o .: "login" <*> o .: "url" <*> o .: "id" <*> o .: "gravatar_id" parseJSON _ = fail "Could not build a Contributor" instance FromJSON Languages where parseJSON (Object o) = Languages <$> mapM (\name -> Language (T.unpack name) <$> o .: name) (Map.keys o) parseJSON _ = fail "Could not build Languages" instance FromJSON Tag where parseJSON (Object o) = Tag <$> o .: "name" <*> o .: "zipball_url" <*> o .: "tarball_url" <*> o .: "commit" parseJSON _ = fail "Could not build a Tag" instance FromJSON Branch where parseJSON (Object o) = Branch <$> o .: "name" <*> o .: "commit" parseJSON _ = fail "Could not build a Branch" instance FromJSON BranchCommit where parseJSON (Object o) = BranchCommit <$> o .: "sha" <*> o .: "url" parseJSON _ = fail "Could not build a BranchCommit" instance FromJSON DetailedOwner where parseJSON (Object o) | o `at` "gravatar_id" == Nothing = DetailedOrganization <$> o .: "created_at" <*> o .: "type" <*> o .: "public_gists" <*> o .: "avatar_url" <*> o .: "followers" <*> o .: "following" <*> o .:? "blog" <*> o .:? "bio" <*> o .: "public_repos" <*> o .:? "name" <*> o .:? "location" <*> o .:? "company" <*> o .: "url" <*> o .: "id" <*> o .: "html_url" <*> o .: "login" | otherwise = DetailedUser <$> o .: "created_at" <*> o .: "type" <*> o .: "public_gists" <*> o .: "avatar_url" <*> o .: "followers" <*> o .: "following" <*> o .: "hireable" <*> o .: "gravatar_id" <*> o .:? "blog" <*> o .:? "bio" <*> o .: "public_repos" <*> o .:? "name" <*> o .:? "location" <*> o .:? "company" <*> o .: "email" <*> o .: "url" <*> o .: "id" <*> o .: "html_url" <*> o .: "login" parseJSON _ = fail "Could not build a DetailedOwner" -- | A slightly more generic version of Aeson's @(.:?)@, using `mzero' instead -- of `Nothing'. (.:<) :: (FromJSON a) => Object -> T.Text -> Parser [a] obj .:< key = case Map.lookup key obj of Nothing -> pure mzero Just v -> parseJSON v -- | Produce all values for the given key. values :: (Eq k, Hashable k, FromJSON v) => Map.HashMap k Value -> k -> Parser v obj `values` key = let (Object children) = findWithDefault (Object Map.empty) key obj in parseJSON $ Array $ V.fromList $ Map.elems children -- | Produce the value for the last key by traversing. (<.:>) :: (FromJSON v, Monoid v) => Object => [T.Text] -> Parser v _obj <.:> [] = pure mempty obj <.:> [key] = obj .: key obj <.:> (key:keys) = let (Object nextObj) = findWithDefault (Object Map.empty) key obj in nextObj <.:> keys -- | Produce the value for the given key, maybe. at :: Object -> T.Text -> Maybe Value obj `at` key = Map.lookup key obj -- Taken from Data.Map: findWithDefault :: (Eq k, Hashable k) => v -> k -> Map.HashMap k v -> v findWithDefault def k m = case Map.lookup k m of Nothing -> def Just x -> x github-0.7.2/Github/Gists.hs0000644000000000000000000000173012247053344014044 0ustar0000000000000000-- | The gists API as described at . module Github.Gists ( gists ,gists' ,gist ,gist' ,module Github.Data ) where import Github.Data import Github.Private -- | The list of all gists created by the user -- -- > gists' (Just ("github-username", "github-password")) "mike-burns" gists' :: Maybe GithubAuth -> String -> IO (Either Error [Gist]) gists' auth userName = githubGet' auth ["users", userName, "gists"] -- | The list of all public gists created by the user. -- -- > gists "mike-burns" gists :: String -> IO (Either Error [Gist]) gists = gists' Nothing -- | A specific gist, given its id, with authentication credentials -- -- > gist' (Just ("github-username", "github-password")) "225074" gist' :: Maybe GithubAuth -> String -> IO (Either Error Gist) gist' auth reqGistId = githubGet' auth ["gists", reqGistId] -- | A specific gist, given its id. -- -- > gist "225074" gist :: String -> IO (Either Error Gist) gist = gist' Nothing github-0.7.2/Github/Issues.hs0000644000000000000000000001126012247053344014225 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} -- | The issues API as described on . module Github.Issues ( issue ,issue' ,issuesForRepo ,issuesForRepo' ,IssueLimitation(..) -- * Modifying Issues -- | -- Only authenticated users may create and edit issues. ,GithubAuth(..) ,createIssue ,newIssue ,editIssue ,editOfIssue ,module Github.Data ) where import Github.Data import Github.Private import Data.List (intercalate) import Data.Time.Format (formatTime) import System.Locale (defaultTimeLocale) import Data.Time.Clock (UTCTime(..)) -- | A data structure for describing how to filter issues. This is used by -- @issuesForRepo@. data IssueLimitation = AnyMilestone -- ^ Issues appearing in any milestone. [default] | NoMilestone -- ^ Issues without a milestone. | MilestoneId Int -- ^ Only issues that are in the milestone with the given id. | Open -- ^ Only open issues. [default] | OnlyClosed -- ^ Only closed issues. | Unassigned -- ^ Issues to which no one has been assigned ownership. | AnyAssignment -- ^ All issues regardless of assignment. [default] | AssignedTo String -- ^ Only issues assigned to the user with the given login. | Mentions String -- ^ Issues which mention the given string, taken to be a user's login. | Labels [String] -- ^ A list of labels to filter by. | Ascending -- ^ Sort ascending. | Descending -- ^ Sort descending. [default] | Since UTCTime -- ^ Only issues created since the specified date and time. | PerPage Int -- ^ Download this many issues per query -- | Details on a specific issue, given the repo owner and name, and the issue -- number.' -- -- > issue' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" "462" issue' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error Issue) issue' auth user reqRepoName reqIssueNumber = githubGet' auth ["repos", user, reqRepoName, "issues", show reqIssueNumber] -- | Details on a specific issue, given the repo owner and name, and the issue -- number. -- -- > issue "thoughtbot" "paperclip" "462" issue :: String -> String -> Int -> IO (Either Error Issue) issue = issue' Nothing -- | All issues for a repo (given the repo owner and name), with optional -- restrictions as described in the @IssueLimitation@ data type. -- -- > issuesForRepo' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" [NoMilestone, OnlyClosed, Mentions "jyurek", Ascending] issuesForRepo' :: Maybe GithubAuth -> String -> String -> [IssueLimitation] -> IO (Either Error [Issue]) issuesForRepo' auth user reqRepoName issueLimitations = githubGetWithQueryString' auth ["repos", user, reqRepoName, "issues"] (queryStringFromLimitations issueLimitations) where queryStringFromLimitations = intercalate "&" . map convert convert AnyMilestone = "milestone=*" convert NoMilestone = "milestone=none" convert (MilestoneId n) = "milestone=" ++ show n convert Open = "state=open" convert OnlyClosed = "state=closed" convert Unassigned = "assignee=none" convert AnyAssignment = "assignee=*" convert (AssignedTo u) = "assignee=" ++ u convert (Mentions u) = "mentioned=" ++ u convert (Labels l) = "labels=" ++ intercalate "," l convert Ascending = "direction=asc" convert Descending = "direction=desc" convert (PerPage n) = "per_page=" ++ show n convert (Since t) = "since=" ++ formatTime defaultTimeLocale "%FT%TZ" t -- | All issues for a repo (given the repo owner and name), with optional -- restrictions as described in the @IssueLimitation@ data type. -- -- > issuesForRepo "thoughtbot" "paperclip" [NoMilestone, OnlyClosed, Mentions "jyurek", Ascending] issuesForRepo :: String -> String -> [IssueLimitation] -> IO (Either Error [Issue]) issuesForRepo = issuesForRepo' Nothing -- Creating new issues. newIssue :: String -> NewIssue newIssue title = NewIssue title Nothing Nothing Nothing Nothing -- | -- Create a new issue. -- -- > createIssue (GithubUser (user, password)) user repo -- > (newIssue "some_repo") {...} createIssue :: GithubAuth -> String -> String -> NewIssue -> IO (Either Error Issue) createIssue auth user repo = githubPost auth ["repos", user, repo, "issues"] -- Editing issues. editOfIssue :: EditIssue editOfIssue = EditIssue Nothing Nothing Nothing Nothing Nothing Nothing -- | -- Edit an issue. -- -- > editIssue (GithubUser (user, password)) user repo issue -- > editOfIssue {...} editIssue :: GithubAuth -> String -> String -> Int -> EditIssue -> IO (Either Error Issue) editIssue auth user repo iss = githubPatch auth ["repos", user, repo, "issues", show iss] github-0.7.2/Github/Organizations.hs0000644000000000000000000000262012247053344015601 0ustar0000000000000000-- | The orgs API as described on . module Github.Organizations ( publicOrganizationsFor ,publicOrganizationsFor' ,publicOrganization ,publicOrganization' ,module Github.Data ) where import Github.Data import Github.Private -- | The public organizations for a user, given the user's login, with authorization -- -- > publicOrganizationsFor' (Just ("github-username", "github-password")) "mike-burns" publicOrganizationsFor' :: Maybe GithubAuth -> String -> IO (Either Error [SimpleOrganization]) publicOrganizationsFor' auth userName = githubGet' auth ["users", userName, "orgs"] -- | The public organizations for a user, given the user's login. -- -- > publicOrganizationsFor "mike-burns" publicOrganizationsFor :: String -> IO (Either Error [SimpleOrganization]) publicOrganizationsFor = publicOrganizationsFor' Nothing -- | Details on a public organization. Takes the organization's login. -- -- > publicOrganization' (Just ("github-username", "github-password")) "thoughtbot" publicOrganization' :: Maybe GithubAuth -> String -> IO (Either Error Organization) publicOrganization' auth reqOrganizationName = githubGet' auth ["orgs", reqOrganizationName] -- | Details on a public organization. Takes the organization's login. -- -- > publicOrganization "thoughtbot" publicOrganization :: String -> IO (Either Error Organization) publicOrganization = publicOrganization' Nothing github-0.7.2/Github/Private.hs0000644000000000000000000001547212247053344014375 0ustar0000000000000000{-# LANGUAGE OverloadedStrings, StandaloneDeriving, DeriveDataTypeable #-} {-# LANGUAGE CPP #-} module Github.Private where import Github.Data import Data.Aeson import Data.Attoparsec.ByteString.Lazy import Data.Data import Data.Monoid import Control.Applicative import Data.List import Data.CaseInsensitive (mk) import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as LBS import Network.HTTP.Types (Method, Status(..)) import Network.HTTP.Conduit import Data.Conduit (ResourceT) import qualified Control.Exception as E import Data.Maybe (fromMaybe) -- | user/password for HTTP basic access authentication data GithubAuth = GithubBasicAuth BS.ByteString BS.ByteString | GithubOAuth String deriving (Show, Data, Typeable, Eq, Ord) githubGet :: (FromJSON b, Show b) => [String] -> IO (Either Error b) githubGet = githubGet' Nothing githubGet' :: (FromJSON b, Show b) => Maybe GithubAuth -> [String] -> IO (Either Error b) githubGet' auth paths = githubAPI (BS.pack "GET") (buildUrl paths) auth (Nothing :: Maybe Value) githubGetWithQueryString :: (FromJSON b, Show b) => [String] -> String -> IO (Either Error b) githubGetWithQueryString = githubGetWithQueryString' Nothing githubGetWithQueryString' :: (FromJSON b, Show b) => Maybe GithubAuth -> [String] -> String -> IO (Either Error b) githubGetWithQueryString' auth paths qs = githubAPI (BS.pack "GET") (buildUrl paths ++ "?" ++ qs) auth (Nothing :: Maybe Value) githubPost :: (ToJSON a, Show a, FromJSON b, Show b) => GithubAuth -> [String] -> a -> IO (Either Error b) githubPost auth paths body = githubAPI (BS.pack "POST") (buildUrl paths) (Just auth) (Just body) githubPatch :: (ToJSON a, Show a, FromJSON b, Show b) => GithubAuth -> [String] -> a -> IO (Either Error b) githubPatch auth paths body = githubAPI (BS.pack "PATCH") (buildUrl paths) (Just auth) (Just body) buildUrl :: [String] -> String buildUrl paths = "https://api.github.com/" ++ intercalate "/" paths githubAPI :: (ToJSON a, Show a, FromJSON b, Show b) => BS.ByteString -> String -> Maybe GithubAuth -> Maybe a -> IO (Either Error b) githubAPI apimethod url auth body = do result <- doHttps apimethod url auth (encodeBody body) case result of Left e -> return (Left (HTTPConnectionError e)) Right resp -> either Left (\x -> jsonResultToE (LBS.pack (show x)) (fromJSON x)) <$> handleBody resp where encodeBody = Just . RequestBodyLBS . encode . toJSON handleBody resp = either (return . Left) (handleJson resp) (parseJsonRaw (responseBody resp)) -- This is an "escaping" version of "for", which returns (Right esc) if -- the value 'v' is Nothing; otherwise, it extracts the value from the -- Maybe, applies f, and return an IO (Either Error b). forE :: b -> Maybe a -> (a -> IO (Either Error b)) -> IO (Either Error b) forE = flip . maybe . return . Right handleJson resp gotjson@(Array ary) = -- Determine whether the output was paginated, and if so, we must -- recurse to obtain the subsequent pages, and append those result -- bodies to the current one. The aggregate will then be parsed. forE gotjson (lookup "Link" (responseHeaders resp)) $ \l -> forE gotjson (getNextUrl (BS.unpack l)) $ \nu -> either (return . Left . HTTPConnectionError) (\nextResp -> do nextJson <- handleBody nextResp return $ (\(Array x) -> Array (ary <> x)) <$> nextJson) =<< doHttps apimethod nu auth Nothing handleJson _ gotjson = return (Right gotjson) getNextUrl l = if "rel=\"next\"" `isInfixOf` l then let s = l s' = Data.List.tail $ Data.List.dropWhile (/= '<') s in Just (Data.List.takeWhile (/= '>') s') else Nothing doHttps :: Method -> String -> Maybe GithubAuth -> Maybe (RequestBody (ResourceT IO)) -> IO (Either E.SomeException (Response LBS.ByteString)) doHttps reqMethod url auth body = do let reqBody = fromMaybe (RequestBodyBS $ BS.pack "") body reqHeaders = maybe [] getOAuth auth Just uri = parseUrl url request = uri { method = reqMethod , secure = True , port = 443 , requestBody = reqBody , requestHeaders = reqHeaders <> [("User-Agent", "github.hs/0.7.0")] <> [("Accept", "application/vnd.github.preview")] , checkStatus = successOrMissing } authRequest = getAuthRequest auth request (getResponse authRequest >>= return . Right) `E.catches` [ -- Re-throw AsyncException, otherwise execution will not terminate on -- SIGINT (ctrl-c). All AsyncExceptions are re-thrown (not just -- UserInterrupt) because all of them indicate severe conditions and -- should not occur during normal operation. E.Handler (\e -> E.throw (e :: E.AsyncException)), E.Handler (\e -> (return . Left) (e :: E.SomeException)) ] where getAuthRequest (Just (GithubBasicAuth user pass)) = applyBasicAuth user pass getAuthRequest _ = id getOAuth (GithubOAuth token) = [(mk (BS.pack "Authorization"), BS.pack ("token " ++ token))] getOAuth _ = [] getResponse request = withManager $ \manager -> httpLbs request manager #if MIN_VERSION_http_conduit(1, 9, 0) successOrMissing s@(Status sci _) hs cookiejar #else successOrMissing s@(Status sci _) hs #endif | (200 <= sci && sci < 300) || sci == 404 = Nothing #if MIN_VERSION_http_conduit(1, 9, 0) | otherwise = Just $ E.toException $ StatusCodeException s hs cookiejar #else | otherwise = Just $ E.toException $ StatusCodeException s hs #endif parseJsonRaw :: LBS.ByteString -> Either Error Value parseJsonRaw jsonString = let parsed = parse json jsonString in case parsed of Data.Attoparsec.ByteString.Lazy.Done _ jsonResult -> Right jsonResult (Fail _ _ e) -> Left $ ParseError e jsonResultToE :: Show b => LBS.ByteString -> Data.Aeson.Result b -> Either Error b jsonResultToE jsonString result = case result of Success s -> Right s Error e -> Left $ JsonError $ e ++ " on the JSON: " ++ LBS.unpack jsonString parseJson :: (FromJSON b, Show b) => LBS.ByteString -> Either Error b parseJson jsonString = either Left (jsonResultToE jsonString . fromJSON) (parseJsonRaw jsonString) github-0.7.2/Github/PullRequests.hs0000644000000000000000000000635012247053344015426 0ustar0000000000000000-- | The pull requests API as documented at -- . module Github.PullRequests ( pullRequestsFor' ,pullRequest' ,pullRequestCommits' ,pullRequestFiles' ,pullRequestsFor ,pullRequest ,pullRequestCommits ,pullRequestFiles ,module Github.Data ) where import Github.Data import Github.Private -- | All pull requests for the repo, by owner and repo name. -- | With authentification -- -- > pullRequestsFor' (Just ("github-username", "github-password")) "rails" "rails" pullRequestsFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [PullRequest]) pullRequestsFor' auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName, "pulls"] -- | All pull requests for the repo, by owner and repo name. -- -- > pullRequestsFor "rails" "rails" pullRequestsFor :: String -> String -> IO (Either Error [PullRequest]) pullRequestsFor = pullRequestsFor' Nothing -- | A detailed pull request, which has much more information. This takes the -- repo owner and name along with the number assigned to the pull request. -- | With authentification -- -- > pullRequest' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" 562 pullRequest' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error DetailedPullRequest) pullRequest' auth userName reqRepoName number = githubGet' auth ["repos", userName, reqRepoName, "pulls", show number] -- | A detailed pull request, which has much more information. This takes the -- repo owner and name along with the number assigned to the pull request. -- -- > pullRequest "thoughtbot" "paperclip" 562 pullRequest :: String -> String -> Int -> IO (Either Error DetailedPullRequest) pullRequest = pullRequest' Nothing -- | All the commits on a pull request, given the repo owner, repo name, and -- the number of the pull request. -- | With authentification -- -- > pullRequestCommits' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" 688 pullRequestCommits' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error [Commit]) pullRequestCommits' auth userName reqRepoName number = githubGet' auth ["repos", userName, reqRepoName, "pulls", show number, "commits"] -- | All the commits on a pull request, given the repo owner, repo name, and -- the number of the pull request. -- -- > pullRequestCommits "thoughtbot" "paperclip" 688 pullRequestCommits :: String -> String -> Int -> IO (Either Error [Commit]) pullRequestCommits = pullRequestCommits' Nothing -- | The individual files that a pull request patches. Takes the repo owner and -- name, plus the number assigned to the pull request. -- | With authentification -- -- > pullRequestFiles' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" 688 pullRequestFiles' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error [File]) pullRequestFiles' auth userName reqRepoName number = githubGet' auth ["repos", userName, reqRepoName, "pulls", show number, "files"] -- | The individual files that a pull request patches. Takes the repo owner and -- name, plus the number assigned to the pull request. -- -- > pullRequestFiles "thoughtbot" "paperclip" 688 pullRequestFiles :: String -> String -> Int -> IO (Either Error [File]) pullRequestFiles = pullRequestFiles' Nothing github-0.7.2/Github/Repos.hs0000644000000000000000000002363512247053344014053 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} -- | The Github Repos API, as documented at -- module Github.Repos ( -- * Querying repositories userRepos ,userRepos' ,userRepo ,userRepo' ,organizationRepos ,organizationRepos' ,organizationRepo ,organizationRepo' ,contributors ,contributorsWithAnonymous ,languagesFor ,tagsFor ,branchesFor ,module Github.Data ,RepoPublicity(..) -- * Modifying repositories -- | -- Only authenticated users may modify repositories. ,GithubAuth(..) -- ** Create ,createRepo ,createOrganizationRepo ,newRepo ,NewRepo(..) -- ** Edit ,editRepo ,def ,Edit(..) -- ** Delete ,deleteRepo ) where import Data.Default import Data.Aeson.Types import Github.Data import Github.Private import Network.HTTP.Conduit import Control.Applicative import qualified Control.Exception as E import Network.HTTP.Types -- | Filter the list of the user's repos using any of these constructors. data RepoPublicity = All -- ^ All repos accessible to the user. | Owner -- ^ Only repos owned by the user. | Public -- ^ Only public repos. | Private -- ^ Only private repos. | Member -- ^ Only repos to which the user is a member but not an owner. deriving (Show, Eq) -- | The repos for a user, by their login. Can be restricted to just repos they -- own, are a member of, or publicize. Private repos are currently not -- supported. -- -- > userRepos "mike-burns" All userRepos :: String -> RepoPublicity -> IO (Either Error [Repo]) userRepos = userRepos' Nothing -- | The repos for a user, by their login. -- | With authentication, but note that private repos are currently not supported. -- -- > userRepos' (Just (GithubUser (user, password))) "mike-burns" All userRepos' :: Maybe GithubAuth -> String -> RepoPublicity -> IO (Either Error [Repo]) userRepos' auth userName All = githubGetWithQueryString' auth ["users", userName, "repos"] "type=all" userRepos' auth userName Owner = githubGetWithQueryString' auth ["users", userName, "repos"] "type=owner" userRepos' auth userName Member = githubGetWithQueryString' auth ["users", userName, "repos"] "type=member" userRepos' auth userName Public = githubGetWithQueryString' auth ["users", userName, "repos"] "type=public" userRepos' _auth _userName Private = return $ Left $ UserError "Cannot access private repos using userRepos" -- | The repos for an organization, by the organization name. -- -- > organizationRepos "thoughtbot" organizationRepos :: String -> IO (Either Error [Repo]) organizationRepos = organizationRepos' Nothing -- | The repos for an organization, by the organization name. -- | With authentication -- -- > organizationRepos (Just (GithubUser (user, password))) "thoughtbot" organizationRepos' :: Maybe GithubAuth -> String -> IO (Either Error [Repo]) organizationRepos' auth orgName = githubGet' auth ["orgs", orgName, "repos"] -- | A specific organization repo, by the organization name. -- -- > organizationRepo "thoughtbot" "github" organizationRepo :: String -> String -> IO (Either Error Repo) organizationRepo = organizationRepo' Nothing -- | A specific organization repo, by the organization name. -- | With authentication -- -- > organizationRepo (Just (GithubUser (user, password))) "thoughtbot" "github" organizationRepo' :: Maybe GithubAuth -> String -> String -> IO (Either Error Repo) organizationRepo' auth orgName reqRepoName = githubGet' auth ["orgs", orgName, reqRepoName] -- | Details on a specific repo, given the owner and repo name. -- -- > userRepo "mike-burns" "github" userRepo :: String -> String -> IO (Either Error Repo) userRepo = userRepo' Nothing -- | Details on a specific repo, given the owner and repo name. -- | With authentication -- -- > userRepo' (Just (GithubUser (user, password))) "mike-burns" "github" userRepo' :: Maybe GithubAuth -> String -> String -> IO (Either Error Repo) userRepo' auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName] -- | The contributors to a repo, given the owner and repo name. -- -- > contributors "thoughtbot" "paperclip" contributors :: String -> String -> IO (Either Error [Contributor]) contributors userName reqRepoName = githubGet ["repos", userName, reqRepoName, "contributors"] -- | The contributors to a repo, including anonymous contributors (such as -- deleted users or git commits with unknown email addresses), given the owner -- and repo name. -- -- > contributorsWithAnonymous "thoughtbot" "paperclip" contributorsWithAnonymous :: String -> String -> IO (Either Error [Contributor]) contributorsWithAnonymous userName reqRepoName = githubGetWithQueryString ["repos", userName, reqRepoName, "contributors"] "anon=true" -- | The programming languages used in a repo along with the number of -- characters written in that language. Takes the repo owner and name. -- -- > languagesFor "mike-burns" "ohlaunch" languagesFor :: String -> String -> IO (Either Error [Language]) languagesFor userName reqRepoName = do result <- githubGet ["repos", userName, reqRepoName, "languages"] return $ either Left (Right . getLanguages) result -- | The git tags on a repo, given the repo owner and name. -- -- > tagsFor "thoughtbot" "paperclip" tagsFor :: String -> String -> IO (Either Error [Tag]) tagsFor userName reqRepoName = githubGet ["repos", userName, reqRepoName, "tags"] -- | The git branches on a repo, given the repo owner and name. -- -- > branchesFor "thoughtbot" "paperclip" branchesFor :: String -> String -> IO (Either Error [Branch]) branchesFor userName reqRepoName = githubGet ["repos", userName, reqRepoName, "branches"] data NewRepo = NewRepo { newRepoName :: String , newRepoDescription :: (Maybe String) , newRepoHomepage :: (Maybe String) , newRepoPrivate :: (Maybe Bool) , newRepoHasIssues :: (Maybe Bool) , newRepoHasWiki :: (Maybe Bool) , newRepoAutoInit :: (Maybe Bool) } deriving Show instance ToJSON NewRepo where toJSON (NewRepo { newRepoName = name , newRepoDescription = description , newRepoHomepage = homepage , newRepoPrivate = private , newRepoHasIssues = hasIssues , newRepoHasWiki = hasWiki , newRepoAutoInit = autoInit }) = object [ "name" .= name , "description" .= description , "homepage" .= homepage , "private" .= private , "has_issues" .= hasIssues , "has_wiki" .= hasWiki , "auto_init" .= autoInit ] newRepo :: String -> NewRepo newRepo name = NewRepo name Nothing Nothing Nothing Nothing Nothing Nothing -- | -- Create a new repository. -- -- > createRepo (GithubUser (user, password)) (newRepo "some_repo") {newRepoHasIssues = Just False} createRepo :: GithubAuth -> NewRepo -> IO (Either Error Repo) createRepo auth = githubPost auth ["user", "repos"] -- | -- Create a new repository for an organization. -- -- > createOrganizationRepo (GithubUser (user, password)) "thoughtbot" (newRepo "some_repo") {newRepoHasIssues = Just False} createOrganizationRepo :: GithubAuth -> String -> NewRepo -> IO (Either Error Repo) createOrganizationRepo auth org = githubPost auth ["orgs", org, "repos"] data Edit = Edit { editName :: Maybe String , editDescription :: Maybe String , editHomepage :: Maybe String , editPublic :: Maybe Bool , editHasIssues :: Maybe Bool , editHasWiki :: Maybe Bool , editHasDownloads :: Maybe Bool } deriving Show instance Default Edit where def = Edit def def def def def def def instance ToJSON Edit where toJSON (Edit { editName = name , editDescription = description , editHomepage = homepage , editPublic = public , editHasIssues = hasIssues , editHasWiki = hasWiki , editHasDownloads = hasDownloads }) = object [ "name" .= name , "description" .= description , "homepage" .= homepage , "public" .= public , "has_issues" .= hasIssues , "has_wiki" .= hasWiki , "has_downloads" .= hasDownloads ] -- | -- Edit an existing repository. -- -- > editRepo (GithubUser (user, password)) "some_user" "some_repo" def {editDescription = Just "some description"} editRepo :: GithubAuth -> String -- ^ owner -> String -- ^ repository name -> Edit -> IO (Either Error Repo) editRepo auth user repo body = githubPatch auth ["repos", user, repo] b where -- if no name is given, use curent name b = body {editName = editName body <|> Just repo} -- | -- Delete an existing repository. -- -- > deleteRepo (GithubUser (user, password)) "thoughtbot" "some_repo" deleteRepo :: GithubAuth -> String -- ^ owner -> String -- ^ repository name -> IO (Either Error ()) deleteRepo auth owner repo = do result <- doHttps "DELETE" url (Just auth) Nothing case result of Left e -> return (Left (HTTPConnectionError e)) Right resp -> let status = responseStatus resp headers = responseHeaders resp in if status == notFound404 -- doHttps silently absorbs 404 errors, but for this operation -- we want the user to know if they've tried to delete a -- non-existent repository then return (Left (HTTPConnectionError (E.toException (StatusCodeException status headers #if MIN_VERSION_http_conduit(1, 9, 0) (responseCookieJar resp) #endif )))) else return (Right ()) where url = "https://api.github.com/repos/" ++ owner ++ "/" ++ repo github-0.7.2/Github/Search.hs0000644000000000000000000000154612247053344014165 0ustar0000000000000000-- | The Github Search API, as described at -- . module Github.Search( searchRepos' ,searchRepos ,module Github.Data ,GithubAuth(..) ) where import Github.Data import Github.Private -- | Perform a repository search. -- | With authentication. -- -- > searchRepos' (Just $ GithubBasicAuth "github-username" "github-password') "q=a in%3Aname language%3Ahaskell created%3A>2013-10-01&per_page=100" searchRepos' :: Maybe GithubAuth -> String -> IO (Either Error SearchReposResult) searchRepos' auth queryString = githubGetWithQueryString' auth ["search/repositories"] queryString -- | Perform a repository search. -- | Without authentication. -- -- > searchRepos "q=a in%3Aname language%3Ahaskell created%3A>2013-10-01&per_page=100" searchRepos :: String -> IO (Either Error SearchReposResult) searchRepos = searchRepos' Nothing github-0.7.2/Github/Users.hs0000644000000000000000000000126512247053344014057 0ustar0000000000000000-- | The Github Users API, as described at -- . module Github.Users ( userInfoFor ,userInfoFor' ,module Github.Data ) where import Github.Data import Github.Private -- | The information for a single user, by login name. -- | With authentification -- -- > userInfoFor' (Just ("github-username", "github-password")) "mike-burns" userInfoFor' :: Maybe GithubAuth -> String -> IO (Either Error DetailedOwner) userInfoFor' auth userName = githubGet' auth ["users", userName] -- | The information for a single user, by login name. -- -- > userInfoFor "mike-burns" userInfoFor :: String -> IO (Either Error DetailedOwner) userInfoFor = userInfoFor' Nothing github-0.7.2/Github/Data/0000755000000000000000000000000012247053344013267 5ustar0000000000000000github-0.7.2/Github/Data/Definitions.hs0000644000000000000000000003500312247053344016077 0ustar0000000000000000{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} module Github.Data.Definitions where import Data.Time import Data.Data import qualified Control.Exception as E -- | Errors have been tagged according to their source, so you can more easily -- dispatch and handle them. data Error = HTTPConnectionError E.SomeException -- ^ A HTTP error occurred. The actual caught error is included. | ParseError String -- ^ An error in the parser itself. | JsonError String -- ^ The JSON is malformed or unexpected. | UserError String -- ^ Incorrect input. deriving Show -- | A date in the Github format, which is a special case of ISO-8601. newtype GithubDate = GithubDate { fromGithubDate :: UTCTime } deriving (Show, Data, Typeable, Eq, Ord) data Commit = Commit { commitSha :: String ,commitParents :: [Tree] ,commitUrl :: String ,commitGitCommit :: GitCommit ,commitCommitter :: Maybe GithubOwner ,commitAuthor :: Maybe GithubOwner ,commitFiles :: [File] ,commitStats :: Maybe Stats } deriving (Show, Data, Typeable, Eq, Ord) data Tree = Tree { treeSha :: String ,treeUrl :: String ,treeGitTrees :: [GitTree] } deriving (Show, Data, Typeable, Eq, Ord) data GitTree = GitTree { gitTreeType :: String ,gitTreeSha :: String ,gitTreeUrl :: String ,gitTreeSize :: Maybe Int ,gitTreePath :: String ,gitTreeMode :: String } deriving (Show, Data, Typeable, Eq, Ord) data GitCommit = GitCommit { gitCommitMessage :: String ,gitCommitUrl :: String ,gitCommitCommitter :: GitUser ,gitCommitAuthor :: GitUser ,gitCommitTree :: Tree ,gitCommitSha :: Maybe String ,gitCommitParents :: [Tree] } deriving (Show, Data, Typeable, Eq, Ord) data GithubOwner = GithubUser { githubOwnerAvatarUrl :: String ,githubOwnerLogin :: String ,githubOwnerUrl :: String ,githubOwnerId :: Int ,githubOwnerGravatarId :: Maybe String } | GithubOrganization { githubOwnerAvatarUrl :: String ,githubOwnerLogin :: String ,githubOwnerUrl :: String ,githubOwnerId :: Int } deriving (Show, Data, Typeable, Eq, Ord) data GitUser = GitUser { gitUserName :: String ,gitUserEmail :: String ,gitUserDate :: GithubDate } deriving (Show, Data, Typeable, Eq, Ord) data File = File { fileBlobUrl :: String ,fileStatus :: String ,fileRawUrl :: String ,fileAdditions :: Int ,fileSha :: String ,fileChanges :: Int ,filePatch :: String ,fileFilename :: String ,fileDeletions :: Int } deriving (Show, Data, Typeable, Eq, Ord) data Stats = Stats { statsAdditions :: Int ,statsTotal :: Int ,statsDeletions :: Int } deriving (Show, Data, Typeable, Eq, Ord) data Comment = Comment { commentPosition :: Maybe Int ,commentLine :: Maybe Int ,commentBody :: String ,commentCommitId :: String ,commentUpdatedAt :: UTCTime ,commentHtmlUrl :: Maybe String ,commentUrl :: String ,commentCreatedAt :: UTCTime ,commentPath :: Maybe String ,commentUser :: GithubOwner ,commentId :: Int } deriving (Show, Data, Typeable, Eq, Ord) data NewComment = NewComment { newCommentBody :: String } deriving (Show, Data, Typeable, Eq, Ord) data EditComment = EditComment { editCommentBody :: String } deriving (Show, Data, Typeable, Eq, Ord) data Diff = Diff { diffStatus :: String ,diffBehindBy :: Int ,diffPatchUrl :: String ,diffUrl :: String ,diffBaseCommit :: Commit ,diffCommits :: [Commit] ,diffTotalCommits :: Int ,diffHtmlUrl :: String ,diffFiles :: [File] ,diffAheadBy :: Int ,diffDiffUrl :: String ,diffPermalinkUrl :: String } deriving (Show, Data, Typeable, Eq, Ord) data Gist = Gist { gistUser :: GithubOwner ,gistGitPushUrl :: String ,gistUrl :: String ,gistDescription :: Maybe String ,gistCreatedAt :: GithubDate ,gistPublic :: Bool ,gistComments :: Int ,gistUpdatedAt :: GithubDate ,gistHtmlUrl :: String ,gistId :: String ,gistFiles :: [GistFile] ,gistGitPullUrl :: String } deriving (Show, Data, Typeable, Eq, Ord) data GistFile = GistFile { gistFileType :: String ,gistFileRawUrl :: String ,gistFileSize :: Int ,gistFileLanguage :: Maybe String ,gistFileFilename :: String ,gistFileContent :: Maybe String } deriving (Show, Data, Typeable, Eq, Ord) data GistComment = GistComment { gistCommentUser :: GithubOwner ,gistCommentUrl :: String ,gistCommentCreatedAt :: GithubDate ,gistCommentBody :: String ,gistCommentUpdatedAt :: GithubDate ,gistCommentId :: Int } deriving (Show, Data, Typeable, Eq, Ord) data Blob = Blob { blobUrl :: String ,blobEncoding :: String ,blobContent :: String ,blobSha :: String ,blobSize :: Int } deriving (Show, Data, Typeable, Eq, Ord) data GitReference = GitReference { gitReferenceObject :: GitObject ,gitReferenceUrl :: String ,gitReferenceRef :: String } deriving (Show, Data, Typeable, Eq, Ord) data GitObject = GitObject { gitObjectType :: String ,gitObjectSha :: String ,gitObjectUrl :: String } deriving (Show, Data, Typeable, Eq, Ord) data Issue = Issue { issueClosedAt :: Maybe GithubDate ,issueUpdatedAt :: GithubDate ,issueHtmlUrl :: Maybe String ,issueClosedBy :: Maybe GithubOwner ,issueLabels :: [IssueLabel] ,issueNumber :: Int ,issueAssignee :: Maybe GithubOwner ,issueUser :: GithubOwner ,issueTitle :: String ,issuePullRequest :: PullRequestReference ,issueUrl :: String ,issueCreatedAt :: GithubDate ,issueBody :: Maybe String ,issueState :: String ,issueId :: Int ,issueComments :: Int ,issueMilestone :: Maybe Milestone } deriving (Show, Data, Typeable, Eq, Ord) data NewIssue = NewIssue { newIssueTitle :: String , newIssueBody :: Maybe String , newIssueAssignee :: Maybe String , newIssueMilestone :: Maybe Int , newIssueLabels :: Maybe [String] } deriving (Show, Data, Typeable, Eq, Ord) data EditIssue = EditIssue { editIssueTitle :: Maybe String , editIssueBody :: Maybe String , editIssueAssignee :: Maybe String , editIssueState :: Maybe String , editIssueMilestone :: Maybe Int , editIssueLabels :: Maybe [String] } deriving (Show, Data, Typeable, Eq, Ord) data Milestone = Milestone { milestoneCreator :: GithubOwner ,milestoneDueOn :: Maybe GithubDate ,milestoneOpenIssues :: Int ,milestoneNumber :: Int ,milestoneClosedIssues :: Int ,milestoneDescription :: String ,milestoneTitle :: String ,milestoneUrl :: String ,milestoneCreatedAt :: GithubDate ,milestoneState :: String } deriving (Show, Data, Typeable, Eq, Ord) data IssueLabel = IssueLabel { labelColor :: String ,labelUrl :: String ,labelName :: String } deriving (Show, Data, Typeable, Eq, Ord) data PullRequestReference = PullRequestReference { pullRequestReferenceHtmlUrl :: Maybe String ,pullRequestReferencePatchUrl :: Maybe String ,pullRequestReferenceDiffUrl :: Maybe String } deriving (Show, Data, Typeable, Eq, Ord) data IssueComment = IssueComment { issueCommentUpdatedAt :: GithubDate ,issueCommentUser :: GithubOwner ,issueCommentUrl :: String ,issueCommentCreatedAt :: GithubDate ,issueCommentBody :: String ,issueCommentId :: Int } deriving (Show, Data, Typeable, Eq, Ord) -- | Data describing an @Event@. data EventType = Mentioned -- ^ The actor was @mentioned in an issue body. | Subscribed -- ^ The actor subscribed to receive notifications for an issue. | Unsubscribed -- ^ The issue was unsubscribed from by the actor. | Referenced -- ^ The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where that happened. | Merged -- ^ The issue was merged by the actor. The commit_id attribute is the SHA1 of the HEAD commit that was merged. | Assigned -- ^ The issue was assigned to the actor. | Closed -- ^ The issue was closed by the actor. When the commit_id is present, it identifies the commit that closed the issue using “closes / fixes #NN” syntax. | Reopened -- ^ The issue was reopened by the actor. deriving (Show, Data, Typeable, Eq, Ord) data Event = Event { eventActor :: GithubOwner ,eventType :: EventType ,eventCommitId :: Maybe String ,eventUrl :: String ,eventCreatedAt :: GithubDate ,eventId :: Int ,eventIssue :: Maybe Issue } deriving (Show, Data, Typeable, Eq, Ord) data SimpleOrganization = SimpleOrganization { simpleOrganizationUrl :: String ,simpleOrganizationAvatarUrl :: String ,simpleOrganizationId :: Int ,simpleOrganizationLogin :: String } deriving (Show, Data, Typeable, Eq, Ord) data Organization = Organization { organizationType :: String ,organizationBlog :: Maybe String ,organizationLocation :: Maybe String ,organizationLogin :: String ,organizationFollowers :: Int ,organizationCompany :: Maybe String ,organizationAvatarUrl :: String ,organizationPublicGists :: Int ,organizationHtmlUrl :: String ,organizationEmail :: Maybe String ,organizationFollowing :: Int ,organizationPublicRepos :: Int ,organizationUrl :: String ,organizationCreatedAt :: GithubDate ,organizationName :: Maybe String ,organizationId :: Int } deriving (Show, Data, Typeable, Eq, Ord) data PullRequest = PullRequest { pullRequestClosedAt :: Maybe GithubDate ,pullRequestCreatedAt :: GithubDate ,pullRequestUser :: GithubOwner ,pullRequestPatchUrl :: String ,pullRequestState :: String ,pullRequestNumber :: Int ,pullRequestHtmlUrl :: String ,pullRequestUpdatedAt :: GithubDate ,pullRequestBody :: String ,pullRequestIssueUrl :: String ,pullRequestDiffUrl :: String ,pullRequestUrl :: String ,pullRequestLinks :: PullRequestLinks ,pullRequestMergedAt :: Maybe GithubDate ,pullRequestTitle :: String ,pullRequestId :: Int } deriving (Show, Data, Typeable, Eq, Ord) data DetailedPullRequest = DetailedPullRequest { -- this is a duplication of a PullRequest detailedPullRequestClosedAt :: Maybe GithubDate ,detailedPullRequestCreatedAt :: GithubDate ,detailedPullRequestUser :: GithubOwner ,detailedPullRequestPatchUrl :: String ,detailedPullRequestState :: String ,detailedPullRequestNumber :: Int ,detailedPullRequestHtmlUrl :: String ,detailedPullRequestUpdatedAt :: GithubDate ,detailedPullRequestBody :: String ,detailedPullRequestIssueUrl :: String ,detailedPullRequestDiffUrl :: String ,detailedPullRequestUrl :: String ,detailedPullRequestLinks :: PullRequestLinks ,detailedPullRequestMergedAt :: Maybe GithubDate ,detailedPullRequestTitle :: String ,detailedPullRequestId :: Int ,detailedPullRequestMergedBy :: Maybe GithubOwner ,detailedPullRequestChangedFiles :: Int ,detailedPullRequestHead :: PullRequestCommit ,detailedPullRequestComments :: Int ,detailedPullRequestDeletions :: Int ,detailedPullRequestAdditions :: Int ,detailedPullRequestReviewComments :: Int ,detailedPullRequestBase :: PullRequestCommit ,detailedPullRequestCommits :: Int ,detailedPullRequestMerged :: Bool ,detailedPullRequestMergeable :: Bool } deriving (Show, Data, Typeable, Eq, Ord) data PullRequestLinks = PullRequestLinks { pullRequestLinksReviewComments :: String ,pullRequestLinksComments :: String ,pullRequestLinksHtml :: String ,pullRequestLinksSelf :: String } deriving (Show, Data, Typeable, Eq, Ord) data PullRequestCommit = PullRequestCommit { } deriving (Show, Data, Typeable, Eq, Ord) data SearchReposResult = SearchReposResult { searchReposTotalCount :: Int ,searchReposRepos :: [ Repo ] } deriving (Show, Data, Typeable, Eq, Ord) data Repo = Repo { repoSshUrl :: String ,repoDescription :: Maybe String ,repoCreatedAt :: GithubDate ,repoHtmlUrl :: String ,repoSvnUrl :: String ,repoForks :: Int ,repoHomepage :: Maybe String ,repoFork :: Bool ,repoGitUrl :: String ,repoPrivate :: Bool ,repoCloneUrl :: String ,repoSize :: Int ,repoUpdatedAt :: GithubDate ,repoWatchers :: Int ,repoOwner :: GithubOwner ,repoName :: String ,repoLanguage :: Maybe String ,repoMasterBranch :: Maybe String ,repoPushedAt :: Maybe GithubDate -- ^ this is Nothing for new repositories ,repoId :: Int ,repoUrl :: String ,repoOpenIssues :: Int ,repoHasWiki :: Maybe Bool ,repoHasIssues :: Maybe Bool ,repoHasDownloads :: Maybe Bool ,repoParent :: Maybe RepoRef ,repoSource :: Maybe RepoRef } deriving (Show, Data, Typeable, Eq, Ord) data RepoRef = RepoRef GithubOwner String -- Repo owner and name deriving (Show, Data, Typeable, Eq, Ord) data Contributor -- | An existing Github user, with their number of contributions, avatar -- URL, login, URL, ID, and Gravatar ID. = KnownContributor Int String String String Int String -- | An unknown Github user with their number of contributions and recorded name. | AnonymousContributor Int String deriving (Show, Data, Typeable, Eq, Ord) -- | This is only used for the FromJSON instance. data Languages = Languages { getLanguages :: [Language] } deriving (Show, Data, Typeable, Eq, Ord) -- | A programming language with the name and number of characters written in -- it. data Language = Language String Int deriving (Show, Data, Typeable, Eq, Ord) data Tag = Tag { tagName :: String ,tagZipballUrl :: String ,tagTarballUrl :: String ,tagCommit :: BranchCommit } deriving (Show, Data, Typeable, Eq, Ord) data Branch = Branch { branchName :: String ,branchCommit :: BranchCommit } deriving (Show, Data, Typeable, Eq, Ord) data BranchCommit = BranchCommit { branchCommitSha :: String ,branchCommitUrl :: String } deriving (Show, Data, Typeable, Eq, Ord) data DetailedOwner = DetailedUser { detailedOwnerCreatedAt :: GithubDate ,detailedOwnerType :: String ,detailedOwnerPublicGists :: Int ,detailedOwnerAvatarUrl :: String ,detailedOwnerFollowers :: Int ,detailedOwnerFollowing :: Int ,detailedOwnerHireable :: Bool ,detailedOwnerGravatarId :: Maybe String ,detailedOwnerBlog :: Maybe String ,detailedOwnerBio :: Maybe String ,detailedOwnerPublicRepos :: Int ,detailedOwnerName :: Maybe String ,detailedOwnerLocation :: Maybe String ,detailedOwnerCompany :: Maybe String ,detailedOwnerEmail :: String ,detailedOwnerUrl :: String ,detailedOwnerId :: Int ,detailedOwnerHtmlUrl :: String ,detailedOwnerLogin :: String } | DetailedOrganization { detailedOwnerCreatedAt :: GithubDate ,detailedOwnerType :: String ,detailedOwnerPublicGists :: Int ,detailedOwnerAvatarUrl :: String ,detailedOwnerFollowers :: Int ,detailedOwnerFollowing :: Int ,detailedOwnerBlog :: Maybe String ,detailedOwnerBio :: Maybe String ,detailedOwnerPublicRepos :: Int ,detailedOwnerName :: Maybe String ,detailedOwnerLocation :: Maybe String ,detailedOwnerCompany :: Maybe String ,detailedOwnerUrl :: String ,detailedOwnerId :: Int ,detailedOwnerHtmlUrl :: String ,detailedOwnerLogin :: String } deriving (Show, Data, Typeable, Eq, Ord) github-0.7.2/Github/Gists/0000755000000000000000000000000012247053344013507 5ustar0000000000000000github-0.7.2/Github/Gists/Comments.hs0000644000000000000000000000117112247053344015630 0ustar0000000000000000-- | The loving comments people have left on Gists, described on -- . module Github.Gists.Comments ( commentsOn ,comment ,module Github.Data ) where import Github.Data import Github.Private -- | All the comments on a Gist, given the Gist ID. -- -- > commentsOn "1174060" commentsOn :: String -> IO (Either Error [GistComment]) commentsOn reqGistId = githubGet ["gists", reqGistId, "comments"] -- | A specific comment, by the comment ID. -- -- > comment "62449" comment :: String -> IO (Either Error GistComment) comment reqCommentId = githubGet ["gists", "comments", reqCommentId] github-0.7.2/Github/GitData/0000755000000000000000000000000012247053344013733 5ustar0000000000000000github-0.7.2/Github/GitData/Blobs.hs0000644000000000000000000000074712247053344015340 0ustar0000000000000000-- | The API for dealing with git blobs from Github repos, as described in -- . module Github.GitData.Blobs ( blob ,module Github.Data ) where import Github.Data import Github.Private -- | Get a blob by SHA1. -- -- > blob "thoughtbot" "paperclip" "bc5c51d1ece1ee45f94b056a0f5a1674d7e8cba9" blob :: String -> String -> String -> IO (Either Error Blob) blob user reqRepoName sha = githubGet ["repos", user, reqRepoName, "git", "blobs", sha] github-0.7.2/Github/GitData/Commits.hs0000644000000000000000000000077712247053344015715 0ustar0000000000000000-- | The API for underlying git commits of a Github repo, as described on -- . module Github.GitData.Commits ( commit ,module Github.Data ) where import Github.Data import Github.Private -- | A single commit, by SHA1. -- -- > commit "thoughtbot" "paperclip" "bc5c51d1ece1ee45f94b056a0f5a1674d7e8cba9" commit :: String -> String -> String -> IO (Either Error GitCommit) commit user reqRepoName sha = githubGet ["repos", user, reqRepoName, "git", "commits", sha] github-0.7.2/Github/GitData/References.hs0000644000000000000000000000225012247053344016347 0ustar0000000000000000-- | The underlying git references on a Github repo, exposed for the world to -- see. The git internals documentation will also prove handy for understanding -- these. API documentation at . module Github.GitData.References ( reference ,references ,namespacedReferences ,module Github.Data ) where import Github.Data import Github.Private -- | A single reference by the ref name. -- -- > reference "mike-burns" "github" "heads/master" reference :: String -> String -> String -> IO (Either Error GitReference) reference user reqRepoName ref = githubGet ["repos", user, reqRepoName, "git", "refs", ref] -- | The history of references for a repo. -- -- > references "mike-burns" "github" references :: String -> String -> IO (Either Error [GitReference]) references user reqRepoName = githubGet ["repos", user, reqRepoName, "git", "refs"] -- | Limited references by a namespace. -- -- > namespacedReferences "thoughtbot" "paperclip" "tags" namespacedReferences :: String -> String -> String -> IO (Either Error [GitReference]) namespacedReferences user reqRepoName namespace = githubGet ["repos", user, reqRepoName, "git", "refs", namespace] github-0.7.2/Github/GitData/Trees.hs0000644000000000000000000000154212247053344015353 0ustar0000000000000000-- | The underlying tree of SHA1s and files that make up a git repo. The API is -- described on . module Github.GitData.Trees ( tree ,nestedTree ,module Github.Data ) where import Github.Data import Github.Private -- | A tree for a SHA1. -- -- > tree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" tree :: String -> String -> String -> IO (Either Error Tree) tree user reqRepoName sha = githubGet ["repos", user, reqRepoName, "git", "trees", sha] -- | A recursively-nested tree for a SHA1. -- -- > nestedTree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" nestedTree :: String -> String -> String -> IO (Either Error Tree) nestedTree user reqRepoName sha = githubGetWithQueryString ["repos", user, reqRepoName, "git", "trees", sha] "recursive=1" github-0.7.2/Github/Issues/0000755000000000000000000000000012247053344013671 5ustar0000000000000000github-0.7.2/Github/Issues/Comments.hs0000644000000000000000000000376012247053344016020 0ustar0000000000000000-- | The Github issue comments API from -- . module Github.Issues.Comments ( comment ,comments ,comments' -- * Modifying Comments -- | -- Only authenticated users may create and edit comments. ,GithubAuth(..) ,createComment ,editComment ,module Github.Data ) where import Github.Data import Github.Private -- | A specific comment, by ID. -- -- > comment "thoughtbot" "paperclip" 1468184 comment :: String -> String -> Int -> IO (Either Error IssueComment) comment user reqRepoName reqCommentId = githubGet ["repos", user, reqRepoName, "issues", "comments", show reqCommentId] -- | All comments on an issue, by the issue's number. -- -- > comments "thoughtbot" "paperclip" 635 comments :: String -> String -> Int -> IO (Either Error [IssueComment]) comments user reqRepoName reqIssueNumber = githubGet ["repos", user, reqRepoName, "issues", show reqIssueNumber, "comments"] -- | All comments on an issue, by the issue's number, using authentication. -- -- > comments' (GithubUser (user, password)) "thoughtbot" "paperclip" 635 comments' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error [IssueComment]) comments' auth user reqRepoName reqIssueNumber = githubGet' auth ["repos", user, reqRepoName, "issues", show reqIssueNumber, "comments"] -- | -- Create a new comment. -- -- > createComment (GithubUser (user, password)) user repo issue -- > "some words" createComment :: GithubAuth -> String -> String -> Int -> String -> IO (Either Error Comment) createComment auth user repo iss body = githubPost auth ["repos", user, repo, "issues", show iss, "comments"] (NewComment body) -- | -- Edit a comment. -- -- > editComment (GithubUser (user, password)) user repo commentid -- > "new words" editComment :: GithubAuth -> String -> String -> Int -> String -> IO (Either Error Comment) editComment auth user repo commid body = githubPatch auth ["repos", user, repo, "issues", "comments", show commid] (EditComment body) github-0.7.2/Github/Issues/Events.hs0000644000000000000000000000206112247053344015470 0ustar0000000000000000-- | The Github issue events API, which is described on -- module Github.Issues.Events ( eventsForIssue ,eventsForRepo ,event ,module Github.Data ) where import Github.Data import Github.Private -- | All events that have happened on an issue. -- -- > eventsForIssue "thoughtbot" "paperclip" 49 eventsForIssue :: String -> String -> Int -> IO (Either Error [Event]) eventsForIssue user reqRepoName reqIssueNumber = githubGet ["repos", user, reqRepoName, "issues", show reqIssueNumber, "events"] -- | All the events for all issues in a repo. -- -- > eventsForRepo "thoughtbot" "paperclip" eventsForRepo :: String -> String -> IO (Either Error [Event]) eventsForRepo user reqRepoName = githubGet ["repos", user, reqRepoName, "issues", "events"] -- | Details on a specific event, by the event's ID. -- -- > event "thoughtbot" "paperclip" 5335772 event :: String -> String -> Int -> IO (Either Error Event) event user reqRepoName reqEventId = githubGet ["repos", user, reqRepoName, "issues", "events", show reqEventId] github-0.7.2/Github/Issues/Labels.hs0000644000000000000000000000257512247053344015440 0ustar0000000000000000-- | The API for dealing with labels on Github issues, as described on -- . module Github.Issues.Labels ( label ,labelsOnRepo ,labelsOnIssue ,labelsOnMilestone ,module Github.Data ) where import Github.Data import Github.Private -- | All the labels available to use on any issue in the repo. -- -- > labelsOnRepo "thoughtbot" "paperclip" labelsOnRepo :: String -> String -> IO (Either Error [IssueLabel]) labelsOnRepo user reqRepoName = githubGet ["repos", user, reqRepoName, "labels"] -- | The labels on an issue in a repo. -- -- > labelsOnIssue "thoughtbot" "paperclip" 585 labelsOnIssue :: String -> String -> Int -> IO (Either Error [IssueLabel]) labelsOnIssue user reqRepoName reqIssueId = githubGet ["repos", user, reqRepoName, "issues", show reqIssueId, "labels"] -- | All the labels on a repo's milestone, given the milestone ID. -- -- > labelsOnMilestone "thoughtbot" "paperclip" 2 labelsOnMilestone :: String -> String -> Int -> IO (Either Error [IssueLabel]) labelsOnMilestone user reqRepoName milestoneId = githubGet ["repos", user, reqRepoName, "milestones", show milestoneId, "labels"] -- | A label, by name. -- -- > Github.label "thoughtbot" "paperclip" "bug" label :: String -> String -> String -> IO (Either Error IssueLabel) label user reqRepoName reqLabelName = githubGet ["repos", user, reqRepoName, "labels", reqLabelName] github-0.7.2/Github/Issues/Milestones.hs0000644000000000000000000000200712247053344016346 0ustar0000000000000000-- | The milestones API as described on -- . module Github.Issues.Milestones ( milestones ,milestones' ,milestone ,module Github.Data ) where import Github.Data import Github.Private -- | All milestones in the repo. -- -- > milestones "thoughtbot" "paperclip" milestones :: String -> String -> IO (Either Error [Milestone]) milestones = milestones' Nothing -- | All milestones in the repo, using authentication. -- -- > milestones' (GithubUser (user, password)) "thoughtbot" "paperclip" milestones' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Milestone]) milestones' auth user reqRepoName = githubGet' auth ["repos", user, reqRepoName, "milestones"] -- | Details on a specific milestone, given it's milestone number. -- -- > milestone "thoughtbot" "paperclip" 2 milestone :: String -> String -> Int -> IO (Either Error Milestone) milestone user reqRepoName reqMilestoneNumber = githubGet ["repos", user, reqRepoName, "milestones", show reqMilestoneNumber] github-0.7.2/Github/Organizations/0000755000000000000000000000000012247053344015245 5ustar0000000000000000github-0.7.2/Github/Organizations/Members.hs0000644000000000000000000000067212247053344017200 0ustar0000000000000000-- | The organization members API as described on -- . module Github.Organizations.Members ( membersOf ,module Github.Data ) where import Github.Data import Github.Private -- | All the users who are members of the specified organization. -- -- > membersOf "thoughtbot" membersOf :: String -> IO (Either Error [GithubOwner]) membersOf organization = githubGet ["orgs", organization, "members"] github-0.7.2/Github/Repos/0000755000000000000000000000000012247053344013506 5ustar0000000000000000github-0.7.2/Github/Repos/Collaborators.hs0000644000000000000000000000255212247053344016654 0ustar0000000000000000-- | The repo collaborators API as described on -- . module Github.Repos.Collaborators ( collaboratorsOn ,isCollaboratorOn ,module Github.Data ) where import Github.Data import Github.Private import Data.ByteString.Char8 (pack) import qualified Network.HTTP.Conduit as C (responseStatus) import qualified Network.HTTP.Types as T (statusCode) -- | All the users who have collaborated on a repo. -- -- > collaboratorsOn "thoughtbot" "paperclip" collaboratorsOn :: String -> String -> IO (Either Error [GithubOwner]) collaboratorsOn userName reqRepoName = githubGet ["repos", userName, reqRepoName, "collaborators"] -- | Whether the user is collaborating on a repo. Takes the user in question, -- the user who owns the repo, and the repo name. -- -- > isCollaboratorOn "mike-burns" "thoughtbot" "paperclip" -- > isCollaboratorOn "johnson" "thoughtbot" "paperclip" isCollaboratorOn :: String -> String -> String -> IO (Either Error Bool) isCollaboratorOn userName repoOwnerName reqRepoName = do result <- doHttps (pack "GET") (buildUrl ["repos", repoOwnerName, reqRepoName, "collaborators", userName]) Nothing Nothing return $ either (Left . HTTPConnectionError) (Right . (204 ==) . T.statusCode . C.responseStatus) result github-0.7.2/Github/Repos/Commits.hs0000644000000000000000000000354712247053344015466 0ustar0000000000000000-- | The repo commits API as described on -- . module Github.Repos.Commits ( commitsFor ,commit ,commentsFor ,commitCommentsFor ,commitCommentFor ,diff ,module Github.Data ) where import Github.Data import Github.Private -- | The commit history for a repo. -- -- > commitsFor "mike-burns" "github" commitsFor :: String -> String -> IO (Either Error [Commit]) commitsFor user repo = githubGet ["repos", user, repo, "commits"] -- | Details on a specific SHA1 for a repo. -- -- > commit "mike-burns" "github" "9d1a9a361266c3c890b1108ad2fdf52f824b1b81" commit :: String -> String -> String -> IO (Either Error Commit) commit user repo sha1 = githubGet ["repos", user, repo, "commits", sha1] -- | All the comments on a Github repo. -- -- > commentsFor "thoughtbot" "paperclip" commentsFor :: String -> String -> IO (Either Error [Comment]) commentsFor user repo = githubGet ["repos", user, repo, "comments"] -- | Just the comments on a specific SHA for a given Github repo. -- -- > commitCommentsFor "thoughtbot" "paperclip" "41f685f6e01396936bb8cd98e7cca517e2c7d96b" commitCommentsFor :: String -> String -> String -> IO (Either Error [Comment]) commitCommentsFor user repo sha1 = githubGet ["repos", user, repo, "commits", sha1, "comments"] -- | A comment, by its ID, relative to the Github repo. -- -- > commitCommentFor "thoughtbot" "paperclip" "669575" commitCommentFor :: String -> String -> String -> IO (Either Error Comment) commitCommentFor user repo reqCommentId = githubGet ["repos", user, repo, "comments", reqCommentId] -- | The diff between two treeishes on a repo. -- -- > diff "thoughtbot" "paperclip" "41f685f6e01396936bb8cd98e7cca517e2c7d96b" "HEAD" diff :: String -> String -> String -> String -> IO (Either Error Diff) diff user repo base headref = githubGet ["repos", user, repo, "compare", base ++ "..." ++ headref] github-0.7.2/Github/Repos/Forks.hs0000644000000000000000000000133312247053344015126 0ustar0000000000000000-- | Hot forking action, as described at -- . module Github.Repos.Forks ( forksFor ,forksFor' ,module Github.Data ) where import Github.Data import Github.Private -- | All the repos that are forked off the given repo. -- -- > forksFor "thoughtbot" "paperclip" forksFor :: String -> String -> IO (Either Error [Repo]) forksFor = forksFor' Nothing -- | All the repos that are forked off the given repo. -- | With authentication -- -- > forksFor' (Just (GithubUser (user, password))) "thoughtbot" "paperclip" forksFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Repo]) forksFor' auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName, "forks"] github-0.7.2/Github/Repos/Starring.hs0000644000000000000000000000170212247053344015633 0ustar0000000000000000-- | The repo starring API as described on -- . module Github.Repos.Starring ( stargazersFor ,reposStarredBy ,myStarred ,module Github.Data ) where import Github.Data import Github.Private -- | The list of users that have starred the specified Github repo. -- -- > userInfoFor' Nothing "mike-burns" stargazersFor :: Maybe GithubAuth -> String -> String -> IO (Either Error [GithubOwner]) stargazersFor auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName, "stargazers"] -- | All the public repos starred by the specified user. -- -- > reposStarredBy Nothing "croaky" reposStarredBy :: Maybe GithubAuth -> String -> IO (Either Error [Repo]) reposStarredBy auth userName = githubGet' auth ["users", userName, "starred"] -- | All the repos starred by the authenticated user. myStarred :: GithubAuth -> IO (Either Error [Repo]) myStarred auth = githubGet' (Just auth) ["user", "starred"] github-0.7.2/Github/Repos/Watching.hs0000644000000000000000000000246412247053344015614 0ustar0000000000000000-- | The repo watching API as described on -- . module Github.Repos.Watching ( watchersFor ,watchersFor' ,reposWatchedBy ,reposWatchedBy' ,module Github.Data ) where import Github.Data import Github.Private -- | The list of users that are watching the specified Github repo. -- -- > watchersFor "thoughtbot" "paperclip" watchersFor :: String -> String -> IO (Either Error [GithubOwner]) watchersFor = watchersFor' Nothing -- | The list of users that are watching the specified Github repo. -- | With authentication -- -- > watchersFor' (Just (GithubUser (user, password))) "thoughtbot" "paperclip" watchersFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [GithubOwner]) watchersFor' auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName, "watchers"] -- | All the public repos watched by the specified user. -- -- > reposWatchedBy "croaky" reposWatchedBy :: String -> IO (Either Error [Repo]) reposWatchedBy = reposWatchedBy' Nothing -- | All the public repos watched by the specified user. -- | With authentication -- -- > reposWatchedBy' (Just (GithubUser (user, password))) "croaky" reposWatchedBy' :: Maybe GithubAuth -> String -> IO (Either Error [Repo]) reposWatchedBy' auth userName = githubGet' auth ["users", userName, "watched"] github-0.7.2/Github/Users/0000755000000000000000000000000012247053344013517 5ustar0000000000000000github-0.7.2/Github/Users/Followers.hs0000644000000000000000000000122512247053344016027 0ustar0000000000000000-- | The user followers API as described on -- . module Github.Users.Followers ( usersFollowing ,usersFollowedBy ,module Github.Data ) where import Github.Data import Github.Private -- | All the users following the given user. -- -- > usersFollowing "mike-burns" usersFollowing :: String -> IO (Either Error [GithubOwner]) usersFollowing userName = githubGet ["users", userName, "followers"] -- | All the users that the given user follows. -- -- > usersFollowedBy "mike-burns" usersFollowedBy :: String -> IO (Either Error [GithubOwner]) usersFollowedBy userName = githubGet ["users", userName, "following"] github-0.7.2/samples/0000755000000000000000000000000012247053344012640 5ustar0000000000000000github-0.7.2/samples/Gists/0000755000000000000000000000000012247053344013731 5ustar0000000000000000github-0.7.2/samples/Gists/ListGists.hs0000644000000000000000000000071612247053344016216 0ustar0000000000000000module ListGists where import qualified Github.Gists as Github import Data.List (intercalate) main = do possibleGists <- Github.gists "mike-burns" case possibleGists of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right gists) -> putStrLn $ intercalate "\n\n" $ map formatGist gists formatGist gist = (Github.gistId gist) ++ "\n" ++ (maybe "indescribable" id $ Github.gistDescription gist) ++ "\n" ++ (Github.gistHtmlUrl gist) github-0.7.2/samples/Gists/ShowGist.hs0000644000000000000000000000120212247053344016027 0ustar0000000000000000module ShowGist where import qualified Github.Gists as Github import Data.List (intercalate) main = do possibleGist <- Github.gist "23084" case possibleGist of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right gist) -> putStrLn $ formatGist gist formatGist gist = (Github.gistId gist) ++ "\n" ++ (maybe "indescribable" id $ Github.gistDescription gist) ++ "\n" ++ (Github.gistHtmlUrl gist) ++ "\n\n" ++ (intercalate "\n\n" $ map formatGistFile $ Github.gistFiles gist) formatGistFile gistFile = (Github.gistFileFilename gistFile) ++ ":\n" ++ maybe "[empty]" id (Github.gistFileContent gistFile) github-0.7.2/samples/Gists/Comments/0000755000000000000000000000000012247053344015516 5ustar0000000000000000github-0.7.2/samples/Gists/Comments/ShowComment.hs0000644000000000000000000000101712247053344020314 0ustar0000000000000000module ShowComment where import qualified Github.Gists.Comments as Github main = do possibleComment <- Github.comment "62449" case possibleComment of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comment) -> putStrLn $ formatComment comment formatComment comment = (Github.githubOwnerLogin $ Github.gistCommentUser comment) ++ "\n" ++ (formatGithubDate $ Github.gistCommentUpdatedAt comment) ++ "\n\n" ++ (Github.gistCommentBody comment) formatGithubDate = show . Github.fromGithubDate github-0.7.2/samples/Gists/Comments/ShowComments.hs0000644000000000000000000000112112247053344020473 0ustar0000000000000000module ShowComments where import qualified Github.Gists.Comments as Github import Data.List (intercalate) main = do possibleComments <- Github.commentsOn "1174060" case possibleComments of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comments) -> putStrLn $ intercalate "\n\n" $ map formatComment comments formatComment comment = (Github.githubOwnerLogin $ Github.gistCommentUser comment) ++ "\n" ++ (formatGithubDate $ Github.gistCommentUpdatedAt comment) ++ "\n\n" ++ (Github.gistCommentBody comment) formatGithubDate = show . Github.fromGithubDate github-0.7.2/samples/GitData/0000755000000000000000000000000012247053344014155 5ustar0000000000000000github-0.7.2/samples/GitData/Commits/0000755000000000000000000000000012247053344015570 5ustar0000000000000000github-0.7.2/samples/GitData/Commits/GitShow.hs0000644000000000000000000000152112247053344017507 0ustar0000000000000000module GitShow where import qualified Github.GitData.Commits as Github import Data.Maybe (fromJust) main = do possibleCommit <- Github.commit "thoughtbot" "paperclip" "bc5c51d1ece1ee45f94b056a0f5a1674d7e8cba9" case possibleCommit of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right commit) -> putStrLn $ formatCommit commit formatCommit :: Github.GitCommit -> String formatCommit commit = "commit " ++ (fromJust $ Github.gitCommitSha commit) ++ "\nAuthor: " ++ (formatAuthor author) ++ "\nDate: " ++ (show $ Github.fromGithubDate $ Github.gitUserDate author) ++ "\n\n\t" ++ (Github.gitCommitMessage commit) ++ "\n" where author = Github.gitCommitAuthor commit formatAuthor :: Github.GitUser -> String formatAuthor author = (Github.gitUserName author) ++ " <" ++ (Github.gitUserEmail author) ++ ">" github-0.7.2/samples/GitData/References/0000755000000000000000000000000012247053344016236 5ustar0000000000000000github-0.7.2/samples/GitData/References/GitLsRemote.hs0000644000000000000000000000110712247053344020767 0ustar0000000000000000module GitLsRemote where import qualified Github.GitData.References as Github import Data.List (intercalate) main = do possibleReferences <- Github.references "mike-burns" "github" case possibleReferences of (Left error) -> putStrLn $ "Error: " ++ show error (Right references) -> do putStrLn "From git@github.com:mike-burns/github.git" putStrLn $ intercalate "\n" $ map formatReference references formatReference reference = (Github.gitObjectSha $ Github.gitReferenceObject reference) ++ "\t" ++ (Github.gitReferenceRef reference) github-0.7.2/samples/GitData/References/GitLsRemoteTags.hs0000644000000000000000000000114312247053344021606 0ustar0000000000000000module GitLsRemoteTags where import qualified Github.GitData.References as Github import Data.List (intercalate) main = do possibleReferences <- Github.namespacedReferences "thoughtbot" "paperclip" "tags" case possibleReferences of (Left error) -> putStrLn $ "Error: " ++ show error (Right references) -> do putStrLn "From git@github.com:thoughtbot/paperclip.git" putStrLn $ intercalate "\n" $ map formatReference references formatReference reference = (Github.gitObjectSha $ Github.gitReferenceObject reference) ++ "\t" ++ (Github.gitReferenceRef reference) github-0.7.2/samples/GitData/References/GitLsRemoteWithRef.hs0000644000000000000000000000066512247053344022270 0ustar0000000000000000module GitLsRemoteWithRef where import qualified Github.GitData.References as Github main = do possibleReference <- Github.reference "mike-burns" "github" "heads/master" putStrLn $ either (\e -> "Error: " ++ show e) formatReference possibleReference formatReference reference = (Github.gitObjectSha $ Github.gitReferenceObject reference) ++ "\t" ++ (Github.gitReferenceRef reference) github-0.7.2/samples/GitData/Trees/0000755000000000000000000000000012247053344015237 5ustar0000000000000000github-0.7.2/samples/GitData/Trees/GitLsTree.hs0000644000000000000000000000114612247053344017437 0ustar0000000000000000module GitLsTree where import qualified Github.GitData.Trees as Github import Data.List (intercalate) main = do possibleTree <- Github.tree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" case possibleTree of (Left error) -> putStrLn $ "Error: " ++ show error (Right tree) -> putStrLn $ formatTree tree formatTree tree = intercalate "\n" $ map formatGitTree $ Github.treeGitTrees tree formatGitTree gitTree = (Github.gitTreeMode gitTree) ++ " " ++ (Github.gitTreeType gitTree) ++ " " ++ (Github.gitTreeSha gitTree) ++ "\t" ++ (Github.gitTreePath gitTree) github-0.7.2/samples/GitData/Trees/GitLsTreeRecursively.hs0000644000000000000000000000116712247053344021677 0ustar0000000000000000module GitLsTreeRecursively where import qualified Github.GitData.Trees as Github import Data.List (intercalate) main = do possibleTree <- Github.nestedTree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" case possibleTree of (Left error) -> putStrLn $ "Error: " ++ show error (Right tree) -> putStrLn $ formatTree tree formatTree tree = intercalate "\n" $ map formatGitTree $ Github.treeGitTrees tree formatGitTree gitTree = (Github.gitTreeMode gitTree) ++ " " ++ (Github.gitTreeType gitTree) ++ " " ++ (Github.gitTreeSha gitTree) ++ "\t" ++ (Github.gitTreePath gitTree) github-0.7.2/samples/Issues/0000755000000000000000000000000012247053344014113 5ustar0000000000000000github-0.7.2/samples/Issues/ShowIssue.hs0000644000000000000000000000110012247053344016370 0ustar0000000000000000module ShowIssue where import qualified Github.Issues as Github main = do possibleIssue <- Github.issue "thoughtbot" "paperclip" 549 putStrLn $ either (\e -> "Error: " ++ show e) formatIssue possibleIssue formatIssue issue = (Github.githubOwnerLogin $ Github.issueUser issue) ++ " opened this issue " ++ (show $ Github.fromGithubDate $ Github.issueCreatedAt issue) ++ "\n" ++ (Github.issueState issue) ++ " with " ++ (show $ Github.issueComments issue) ++ " comments" ++ "\n\n" ++ (Github.issueTitle issue) github-0.7.2/samples/Issues/ShowRepoIssues.hs0000644000000000000000000000142112247053344017407 0ustar0000000000000000module ShowRepoIssue where import qualified Github.Issues as Github import Data.List (intercalate) main = do let limitations = [Github.OnlyClosed, Github.Mentions "mike-burns", Github.AssignedTo "jyurek"] possibleIssues <- Github.issuesForRepo "thoughtbot" "paperclip" limitations case possibleIssues of (Left error) -> putStrLn $ "Error: " ++ show error (Right issues) -> putStrLn $ intercalate "\n\n" $ map formatIssue issues formatIssue issue = (Github.githubOwnerLogin $ Github.issueUser issue) ++ " opened this issue " ++ (show $ Github.fromGithubDate $ Github.issueCreatedAt issue) ++ "\n" ++ (Github.issueState issue) ++ " with " ++ (show $ Github.issueComments issue) ++ " comments" ++ "\n\n" ++ (Github.issueTitle issue) github-0.7.2/samples/Issues/Comments/0000755000000000000000000000000012247053344015700 5ustar0000000000000000github-0.7.2/samples/Issues/Comments/ShowComment.hs0000644000000000000000000000077412247053344020507 0ustar0000000000000000module ShowComment where import qualified Github.Issues.Comments as Github main = do possibleComment <- Github.comment "thoughtbot" "paperclip" 1468184 putStrLn $ either (\e -> "Error: " ++ show e) formatComment possibleComment formatComment comment = (Github.githubOwnerLogin $ Github.issueCommentUser comment) ++ " commented " ++ (show $ Github.fromGithubDate $ Github.issueCommentUpdatedAt comment) ++ "\n" ++ (Github.issueCommentBody comment) github-0.7.2/samples/Issues/Comments/ShowComments.hs0000644000000000000000000000112412247053344020660 0ustar0000000000000000module ShowComments where import qualified Github.Issues.Comments as Github import Data.List (intercalate) main = do possibleComments <- Github.comments "thoughtbot" "paperclip" 635 case possibleComments of (Left error) -> putStrLn $ "Error: " ++ show error (Right issues) -> putStrLn $ intercalate "\n\n" $ map formatComment issues formatComment comment = (Github.githubOwnerLogin $ Github.issueCommentUser comment) ++ " commented " ++ (show $ Github.fromGithubDate $ Github.issueCommentUpdatedAt comment) ++ "\n" ++ (Github.issueCommentBody comment) github-0.7.2/samples/Issues/Events/0000755000000000000000000000000012247053344015357 5ustar0000000000000000github-0.7.2/samples/Issues/Events/ShowEvent.hs0000644000000000000000000000316312247053344017640 0ustar0000000000000000module ShowEvents where import qualified Github.Issues.Events as Github import Data.List (intercalate) import Data.Maybe (fromJust) main = do possibleEvent <- Github.event "thoughtbot" "paperclip" 5335772 case possibleEvent of (Left error) -> putStrLn $ "Error: " ++ show error (Right event) -> do putStrLn $ formatEvent event formatEvent event = formatEvent' event (Github.eventType event) where formatEvent' event Github.Closed = "Closed on " ++ createdAt event ++ " by " ++ loginName event ++ withCommitId event (\commitId -> " in the commit " ++ commitId) formatEvent' event Github.Reopened = "Reopened on " ++ createdAt event ++ " by " ++ loginName event formatEvent' event Github.Subscribed = loginName event ++ " is subscribed to receive notifications" formatEvent' event Github.Unsubscribed = loginName event ++ " is unsubscribed from notifications" formatEvent' event Github.Merged = "Issue merged by " ++ loginName event ++ " on " ++ createdAt event ++ (withCommitId event $ \commitId -> " in the commit " ++ commitId) formatEvent' event Github.Referenced = withCommitId event $ \commitId -> "Issue referenced from " ++ commitId ++ " by " ++ loginName event formatEvent' event Github.Mentioned = loginName event ++ " was mentioned in the issue's body" formatEvent' event Github.Assigned = "Issue assigned to " ++ loginName event ++ " on " ++ createdAt event loginName = Github.githubOwnerLogin . Github.eventActor createdAt = show . Github.fromGithubDate . Github.eventCreatedAt withCommitId event f = maybe "" f (Github.eventCommitId event) github-0.7.2/samples/Issues/Events/ShowIssueEvents.hs0000644000000000000000000000323312247053344021032 0ustar0000000000000000module ShowIssueEvents where import qualified Github.Issues.Events as Github import Data.List (intercalate) main = do possibleEvents <- Github.eventsForIssue "thoughtbot" "paperclip" 49 case possibleEvents of (Left error) -> putStrLn $ "Error: " ++ show error (Right events) -> do putStrLn "Issue #49:\n" putStrLn $ intercalate "\n" $ map formatEvent events formatEvent event = formatEvent' event (Github.eventType event) where formatEvent' event Github.Closed = "Closed on " ++ createdAt event ++ " by " ++ loginName event ++ withCommitId event (\commitId -> " in the commit " ++ commitId) formatEvent' event Github.Reopened = "Reopened on " ++ createdAt event ++ " by " ++ loginName event formatEvent' event Github.Subscribed = loginName event ++ " is subscribed to receive notifications" formatEvent' event Github.Unsubscribed = loginName event ++ " is unsubscribed from notifications" formatEvent' event Github.Merged = "Issue merged by " ++ loginName event ++ " on " ++ createdAt event ++ (withCommitId event $ \commitId -> " in the commit " ++ commitId) formatEvent' event Github.Referenced = withCommitId event $ \commitId -> "Issue referenced from " ++ commitId ++ " by " ++ loginName event formatEvent' event Github.Mentioned = loginName event ++ " was mentioned in the issue's body" formatEvent' event Github.Assigned = "Issue assigned to " ++ loginName event ++ " on " ++ createdAt event loginName = Github.githubOwnerLogin . Github.eventActor createdAt = show . Github.fromGithubDate . Github.eventCreatedAt withCommitId event f = maybe "" f (Github.eventCommitId event) github-0.7.2/samples/Issues/Events/ShowRepoEvents.hs0000644000000000000000000000336712247053344020657 0ustar0000000000000000module ShowRepoEvents where import qualified Github.Issues.Events as Github import Data.List (intercalate) import Data.Maybe (fromJust) main = do possibleEvents <- Github.eventsForRepo "thoughtbot" "paperclip" case possibleEvents of (Left error) -> putStrLn $ "Error: " ++ show error (Right events) -> do putStrLn $ intercalate "\n" $ map formatEvent events formatEvent event = "Issue #" ++ issueNumber event ++ ": " ++ formatEvent' event (Github.eventType event) where formatEvent' event Github.Closed = "closed on " ++ createdAt event ++ " by " ++ loginName event ++ withCommitId event (\commitId -> " in the commit " ++ commitId) formatEvent' event Github.Reopened = "reopened on " ++ createdAt event ++ " by " ++ loginName event formatEvent' event Github.Subscribed = loginName event ++ " is subscribed to receive notifications" formatEvent' event Github.Unsubscribed = loginName event ++ " is unsubscribed from notifications" formatEvent' event Github.Merged = "merged by " ++ loginName event ++ " on " ++ createdAt event ++ (withCommitId event $ \commitId -> " in the commit " ++ commitId) formatEvent' event Github.Referenced = withCommitId event $ \commitId -> "referenced from " ++ commitId ++ " by " ++ loginName event formatEvent' event Github.Mentioned = loginName event ++ " was mentioned in the issue's body" formatEvent' event Github.Assigned = "assigned to " ++ loginName event ++ " on " ++ createdAt event loginName = Github.githubOwnerLogin . Github.eventActor createdAt = show . Github.fromGithubDate . Github.eventCreatedAt withCommitId event f = maybe "" f (Github.eventCommitId event) issueNumber = show . Github.issueNumber . fromJust . Github.eventIssue github-0.7.2/samples/Issues/Labels/0000755000000000000000000000000012247053344015315 5ustar0000000000000000github-0.7.2/samples/Issues/Labels/ShowIssueLabels.hs0000644000000000000000000000071012247053344020723 0ustar0000000000000000module ShowIssueLabels where import qualified Github.Issues.Labels as Github import Data.List (intercalate) main = do possibleLabels <- Github.labelsOnIssue "thoughtbot" "paperclip" 585 case possibleLabels of (Left error) -> putStrLn $ "Error: " ++ show error (Right labels) -> do putStrLn $ intercalate "\n" $ map formatLabel labels formatLabel label = (Github.labelName label) ++ ", colored " ++ (Github.labelColor label) github-0.7.2/samples/Issues/Labels/ShowLabel.hs0000644000000000000000000000056712247053344017541 0ustar0000000000000000module ShowLabel where import qualified Github.Issues.Labels as Github main = do possibleLabel <- Github.label "thoughtbot" "paperclip" "bug" case possibleLabel of (Left error) -> putStrLn $ "Error: " ++ show error (Right label) -> putStrLn $ formatLabel label formatLabel label = (Github.labelName label) ++ ", colored " ++ (Github.labelColor label) github-0.7.2/samples/Issues/Labels/ShowMilestoneLabels.hs0000644000000000000000000000071712247053344021601 0ustar0000000000000000module ShowMilestoneLabels where import qualified Github.Issues.Labels as Github import Data.List (intercalate) main = do possibleLabels <- Github.labelsOnMilestone "thoughtbot" "paperclip" 2 case possibleLabels of (Left error) -> putStrLn $ "Error: " ++ show error (Right labels) -> do putStrLn $ intercalate "\n" $ map formatLabel labels formatLabel label = (Github.labelName label) ++ ", colored " ++ (Github.labelColor label) github-0.7.2/samples/Issues/Labels/ShowRepoLabels.hs0000644000000000000000000000070212247053344020541 0ustar0000000000000000module ShowRepoLabels where import qualified Github.Issues.Labels as Github import Data.List (intercalate) main = do possibleLabels <- Github.labelsOnRepo "thoughtbot" "paperclip" case possibleLabels of (Left error) -> putStrLn $ "Error: " ++ show error (Right labels) -> do putStrLn $ intercalate "\n" $ map formatLabel labels formatLabel label = (Github.labelName label) ++ ", colored " ++ (Github.labelColor label) github-0.7.2/samples/Issues/Milestones/0000755000000000000000000000000012247053344016235 5ustar0000000000000000github-0.7.2/samples/Issues/Milestones/ShowMilestone.hs0000644000000000000000000000157612247053344021402 0ustar0000000000000000module ShowMilestone where import qualified Github.Issues.Milestones as Github import Data.List (intercalate) main = do possibleMilestone <- Github.milestone "thoughtbot" "paperclip" 2 case possibleMilestone of (Left error) -> putStrLn $ "Error: " ++ show error (Right milestone) -> putStrLn $ formatMilestone milestone formatMilestone milestone = (Github.milestoneTitle milestone) ++ ", as created by " ++ (loginName milestone) ++ " on " ++ (createdAt milestone) ++ formatDueOn (Github.milestoneDueOn milestone) ++ " and has the " ++ (Github.milestoneState milestone) ++ " status" formatDueOn Nothing = "" formatDueOn (Just milestoneDate) = ", is due on " ++ dueOn milestoneDate loginName = Github.githubOwnerLogin . Github.milestoneCreator createdAt = show . Github.fromGithubDate . Github.milestoneCreatedAt dueOn = show . Github.fromGithubDate github-0.7.2/samples/Issues/Milestones/ShowMilestones.hs0000644000000000000000000000163312247053344021557 0ustar0000000000000000module ShowMilestones where import qualified Github.Issues.Milestones as Github import Data.List (intercalate) main = do possibleMilestones <- Github.milestones "thoughtbot" "paperclip" case possibleMilestones of (Left error) -> putStrLn $ "Error: " ++ show error (Right milestones) -> putStrLn $ intercalate "\n\n" $ map formatMilestone milestones formatMilestone milestone = (Github.milestoneTitle milestone) ++ ", as created by " ++ (loginName milestone) ++ " on " ++ (createdAt milestone) ++ formatDueOn (Github.milestoneDueOn milestone) ++ " and has the " ++ (Github.milestoneState milestone) ++ " status" formatDueOn Nothing = "" formatDueOn (Just milestoneDate) = ", is due on " ++ dueOn milestoneDate loginName = Github.githubOwnerLogin . Github.milestoneCreator createdAt = show . Github.fromGithubDate . Github.milestoneCreatedAt dueOn = show . Github.fromGithubDate github-0.7.2/samples/Organizations/0000755000000000000000000000000012247053344015467 5ustar0000000000000000github-0.7.2/samples/Organizations/ShowPublicOrganization.hs0000644000000000000000000000106512247053344022471 0ustar0000000000000000module ShowPublicOrganization where import qualified Github.Organizations as Github main = do possibleOrganization <- Github.publicOrganization "thoughtbot" case possibleOrganization of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right organization) -> putStrLn $ formatOrganization organization formatOrganization organization = (maybe "" (\s -> s ++ "\n") (Github.organizationName organization)) ++ (Github.organizationHtmlUrl organization) ++ (maybe "" (\s -> "\n" ++ s) (Github.organizationBlog organization)) github-0.7.2/samples/Organizations/ShowPublicOrganizations.hs0000644000000000000000000000070412247053344022653 0ustar0000000000000000module ShowPublicOrganizations where import qualified Github.Organizations as Github import Data.List (intercalate) main = do possibleOrganizations <- Github.publicOrganizationsFor "mike-burns" case possibleOrganizations of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right organizations) -> putStrLn $ intercalate "\n" $ map formatOrganization organizations formatOrganization = Github.simpleOrganizationLogin github-0.7.2/samples/Organizations/Members/0000755000000000000000000000000012247053344017061 5ustar0000000000000000github-0.7.2/samples/Organizations/Members/ShowMembers.hs0000644000000000000000000000055312247053344021653 0ustar0000000000000000module ShowMembers where import qualified Github.Organizations.Members as Github import Data.List (intercalate) main = do possibleMembers <- Github.membersOf "thoughtbot" case possibleMembers of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right members) -> putStrLn $ intercalate "\n" $ map Github.githubOwnerLogin members github-0.7.2/samples/Pulls/0000755000000000000000000000000012247053344013737 5ustar0000000000000000github-0.7.2/samples/Pulls/Diff.hs0000644000000000000000000000065712247053344015153 0ustar0000000000000000module Diff where import qualified Github.PullRequests as Github import Data.List main = do possiblePullRequestFiles <- Github.pullRequestFiles "thoughtbot" "paperclip" 575 case possiblePullRequestFiles of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right files) -> putStrLn $ intercalate "\n\n" $ map formatFile files formatFile file = Github.fileFilename file ++ "\n" ++ Github.filePatch file github-0.7.2/samples/Pulls/ListPulls.hs0000644000000000000000000000157012247053344016231 0ustar0000000000000000module ListPulls where import qualified Github.PullRequests as Github import Data.List main = do possiblePullRequests <- Github.pullRequestsFor "thoughtbot" "paperclip" case possiblePullRequests of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right pullRequests) -> putStrLn $ intercalate "\n\n" $ map formatPullRequest pullRequests formatPullRequest pullRequest = (Github.pullRequestTitle pullRequest) ++ "\n" ++ (take 80 $ Github.pullRequestBody pullRequest) ++ "\n" ++ (Github.githubOwnerLogin $ Github.pullRequestUser pullRequest) ++ " submitted to thoughtbot/paperclip " ++ (formatGithubDate $ Github.pullRequestCreatedAt pullRequest) ++ " updated " ++ (formatGithubDate $ Github.pullRequestUpdatedAt pullRequest) ++ "\n" ++ (Github.pullRequestHtmlUrl pullRequest) formatGithubDate = show . Github.fromGithubDate github-0.7.2/samples/Pulls/ShowCommits.hs0000644000000000000000000000141012247053344016543 0ustar0000000000000000module ShowCommits where import qualified Github.PullRequests as Github import Data.List import Data.Maybe main = do possiblePullRequestCommits <- Github.pullRequestCommits "thoughtbot" "paperclip" 575 case possiblePullRequestCommits of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right commits) -> putStrLn $ intercalate "\n" $ map formatCommit commits formatCommit commit = (formatAuthor $ Github.gitCommitAuthor gitCommit) ++ "\n" ++ (maybe "unknown SHA" id $ Github.gitCommitSha gitCommit) ++ "\n" ++ (Github.gitCommitMessage gitCommit) where gitCommit = Github.commitGitCommit commit formatAuthor :: Github.GitUser -> String formatAuthor author = (Github.gitUserName author) ++ " <" ++ (Github.gitUserEmail author) ++ ">" github-0.7.2/samples/Pulls/ShowPull.hs0000644000000000000000000000175212247053344016055 0ustar0000000000000000module ShowPull where import qualified Github.PullRequests as Github import Data.List main = do possiblePullRequest <- Github.pullRequest "thoughtbot" "paperclip" 575 case possiblePullRequest of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right pullRequest) -> putStrLn $ formatPullRequest pullRequest formatPullRequest p = (Github.githubOwnerLogin $ Github.detailedPullRequestUser p) ++ " opened this pull request " ++ (formatGithubDate $ Github.detailedPullRequestCreatedAt p) ++ "\n" ++ (Github.detailedPullRequestTitle p) ++ "\n" ++ (Github.detailedPullRequestBody p) ++ "\n" ++ (Github.detailedPullRequestState p) ++ "\n" ++ "+" ++ (show $ Github.detailedPullRequestAdditions p) ++ " additions\n" ++ "-" ++ (show $ Github.detailedPullRequestDeletions p) ++ " deletions\n" ++ (show $ Github.detailedPullRequestComments p) ++ " comments\n" ++ (Github.detailedPullRequestHtmlUrl p) formatGithubDate = show . Github.fromGithubDate github-0.7.2/samples/Pulls/ReviewComments/0000755000000000000000000000000012247053344016706 5ustar0000000000000000github-0.7.2/samples/Pulls/ReviewComments/ListComments.hs0000644000000000000000000000152312247053344021664 0ustar0000000000000000module ListComments where import qualified Github.PullRequests.ReviewComments as Github import Data.List main = do possiblePullRequestComments <- Github.pullRequestReviewComments "thoughtbot" "factory_girl" 256 case possiblePullRequestComments of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comments) -> putStrLn $ intercalate "\n\n" $ map formatComment comments formatComment :: Github.Comment -> String formatComment comment = "Author: " ++ (formatAuthor $ Github.commentUser comment) ++ "\nUpdated: " ++ (show $ Github.commentUpdatedAt comment) ++ (maybe "" ("\nURL: "++) $ Github.commentHtmlUrl comment) ++ "\n\n" ++ (Github.commentBody comment) formatAuthor :: Github.GithubOwner -> String formatAuthor user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Pulls/ReviewComments/ShowComment.hs0000644000000000000000000000147112247053344021510 0ustar0000000000000000module ShowComments where import qualified Github.PullRequests.ReviewComments as Github import Data.List main = do possiblePullRequestComment <- Github.pullRequestReviewComment "thoughtbot" "factory_girl" 301819 case possiblePullRequestComment of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comment) -> putStrLn $ formatComment comment formatComment :: Github.Comment -> String formatComment comment = "Author: " ++ (formatAuthor $ Github.commentUser comment) ++ "\nUpdated: " ++ (show $ Github.commentUpdatedAt comment) ++ (maybe "" ("\nURL: "++) $ Github.commentHtmlUrl comment) ++ "\n\n" ++ (Github.commentBody comment) formatAuthor :: Github.GithubOwner -> String formatAuthor user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Repos/0000755000000000000000000000000012247053344013730 5ustar0000000000000000github-0.7.2/samples/Repos/ListBranches.hs0000644000000000000000000000053112247053344016644 0ustar0000000000000000module ListBranches where import qualified Github.Repos as Github import Data.List main = do possibleBranches <- Github.branchesFor "thoughtbot" "paperclip" case possibleBranches of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right branches) -> putStrLn $ intercalate "\n" $ map Github.branchName branches github-0.7.2/samples/Repos/ListContributors.hs0000644000000000000000000000112112247053344017610 0ustar0000000000000000module ListContributors where import qualified Github.Repos as Github import Data.List main = do possibleContributors <- Github.contributors "thoughtbot" "paperclip" case possibleContributors of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right contributors) -> putStrLn $ intercalate "\n" $ map formatContributor contributors formatContributor (Github.KnownContributor contributions _ login _ _ _) = (show $ contributions) ++ "\t" ++ login formatContributor (Github.AnonymousContributor contributions name) = (show $ contributions) ++ "\t" ++ name github-0.7.2/samples/Repos/ListContributorsWithAnonymous.hs0000644000000000000000000000115312247053344022362 0ustar0000000000000000module ListContributorsWithAnonymous where import qualified Github.Repos as Github import Data.List main = do possibleContributors <- Github.contributorsWithAnonymous "thoughtbot" "paperclip" case possibleContributors of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right contributors) -> putStrLn $ intercalate "\n" $ map formatContributor contributors formatContributor (Github.KnownContributor contributions _ login _ _ _) = (show $ contributions) ++ "\t" ++ login formatContributor (Github.AnonymousContributor contributions name) = (show $ contributions) ++ "\t" ++ name github-0.7.2/samples/Repos/ListLanguages.hs0000644000000000000000000000067112247053344017032 0ustar0000000000000000module ListLanguages where import qualified Github.Repos as Github import Data.List main = do possibleLanguages <- Github.languagesFor "mike-burns" "ohlaunch" case possibleLanguages of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right languages) -> putStrLn $ intercalate "\n" $ map formatLanguage languages formatLanguage (Github.Language name characterCount) = name ++ "\t" ++ show characterCount github-0.7.2/samples/Repos/ListOrgRepos.hs0000644000000000000000000000156612247053344016670 0ustar0000000000000000module ListOrgRepos where import qualified Github.Repos as Github import Data.List import Data.Maybe main = do possibleRepos <- Github.organizationRepos "thoughtbot" case possibleRepos of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right repos) -> putStrLn $ intercalate "\n\n" $ map formatRepo repos formatRepo repo = (Github.repoName repo) ++ "\t" ++ (fromMaybe "" $ Github.repoDescription repo) ++ "\n" ++ (Github.repoHtmlUrl repo) ++ "\n" ++ (Github.repoCloneUrl repo) ++ "\t" ++ (formatDate $ Github.repoUpdatedAt repo) ++ "\n" ++ formatLanguage (Github.repoLanguage repo) ++ "watchers: " ++ (show $ Github.repoWatchers repo) ++ "\t" ++ "forks: " ++ (show $ Github.repoForks repo) formatDate = show . Github.fromGithubDate formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.7.2/samples/Repos/ListTags.hs0000644000000000000000000000047612247053344016025 0ustar0000000000000000module ListTags where import qualified Github.Repos as Github import Data.List main = do possibleTags <- Github.tagsFor "thoughtbot" "paperclip" case possibleTags of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right tags) -> putStrLn $ intercalate "\n" $ map Github.tagName tags github-0.7.2/samples/Repos/ListUserRepos.hs0000644000000000000000000000157412247053344017056 0ustar0000000000000000module ListUserRepos where import qualified Github.Repos as Github import Data.List import Data.Maybe main = do possibleRepos <- Github.userRepos "mike-burns" Github.Owner case possibleRepos of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right repos) -> putStrLn $ intercalate "\n\n" $ map formatRepo repos formatRepo repo = (Github.repoName repo) ++ "\t" ++ (fromMaybe "" $ Github.repoDescription repo) ++ "\n" ++ (Github.repoHtmlUrl repo) ++ "\n" ++ (Github.repoCloneUrl repo) ++ "\t" ++ (formatDate $ Github.repoUpdatedAt repo) ++ "\n" ++ formatLanguage (Github.repoLanguage repo) ++ "watchers: " ++ (show $ Github.repoWatchers repo) ++ "\t" ++ "forks: " ++ (show $ Github.repoForks repo) formatDate = show . Github.fromGithubDate formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.7.2/samples/Repos/ShowRepo.hs0000644000000000000000000000152712247053344016037 0ustar0000000000000000module ShowRepo where import qualified Github.Repos as Github import Data.List import Data.Maybe main = do possibleRepo <- Github.userRepo "mike-burns" "trylambda" case possibleRepo of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right repo) -> putStrLn $ formatRepo repo formatRepo repo = (Github.repoName repo) ++ "\t" ++ (fromMaybe "" $ Github.repoDescription repo) ++ "\n" ++ (Github.repoHtmlUrl repo) ++ "\n" ++ (Github.repoCloneUrl repo) ++ "\t" ++ (formatDate $ Github.repoUpdatedAt repo) ++ "\n" ++ formatLanguage (Github.repoLanguage repo) ++ "watchers: " ++ (show $ Github.repoWatchers repo) ++ "\t" ++ "forks: " ++ (show $ Github.repoForks repo) formatDate = show . Github.fromGithubDate formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.7.2/samples/Repos/Collaborators/0000755000000000000000000000000012247053344016536 5ustar0000000000000000github-0.7.2/samples/Repos/Collaborators/IsCollaborator.hs0000644000000000000000000000077712247053344022024 0ustar0000000000000000module IsCollaborator where import qualified Github.Repos.Collaborators as Github import Data.List main = do let userName = "ubuwaits" possiblyIsCollaborator <- Github.isCollaboratorOn userName "thoughtbot" "paperclip" case possiblyIsCollaborator of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right True) -> putStrLn $ userName ++ " is a collaborator on thoughtbot's paperclip" (Right False) -> putStrLn $ userName ++ " does not collaborate on thoughtbot's paperclip" github-0.7.2/samples/Repos/Collaborators/ListCollaborators.hs0000644000000000000000000000101012247053344022524 0ustar0000000000000000module ListCollaborators where import qualified Github.Repos.Collaborators as Github import Data.List main = do possibleCollaborators <- Github.collaboratorsOn "thoughtbot" "paperclip" case possibleCollaborators of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right collaborators) -> putStrLn $ intercalate "\n" $ map formatAuthor collaborators formatAuthor :: Github.GithubOwner -> String formatAuthor user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Repos/Commits/0000755000000000000000000000000012247053344015343 5ustar0000000000000000github-0.7.2/samples/Repos/Commits/CommitComment.hs0000644000000000000000000000141612247053344020454 0ustar0000000000000000module CommitComment where import qualified Github.Repos.Commits as Github import Data.Maybe (maybe) main = do possibleComment <- Github.commitCommentFor "thoughtbot" "paperclip" "669575" case possibleComment of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comment) -> putStrLn $ formatComment comment formatComment :: Github.Comment -> String formatComment comment = "Author: " ++ (formatAuthor $ Github.commentUser comment) ++ "\nUpdated: " ++ (show $ Github.commentUpdatedAt comment) ++ (maybe "" ("\nURL: "++) $ Github.commentHtmlUrl comment) ++ "\n\n" ++ (Github.commentBody comment) formatAuthor :: Github.GithubOwner -> String formatAuthor user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Repos/Commits/CommitComments.hs0000644000000000000000000000154112247053344020636 0ustar0000000000000000module CommitComments where import qualified Github.Repos.Commits as Github import Data.List import Data.Maybe (maybe) main = do possibleComments <- Github.commitCommentsFor "thoughtbot" "paperclip" "41f685f6e01396936bb8cd98e7cca517e2c7d96b" case possibleComments of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comments) -> putStrLn $ intercalate "\n\n" $ map formatComment comments formatComment :: Github.Comment -> String formatComment comment = "Author: " ++ (formatAuthor $ Github.commentUser comment) ++ "\nUpdated: " ++ (show $ Github.commentUpdatedAt comment) ++ (maybe "" ("\nURL: "++) $ Github.commentHtmlUrl comment) ++ "\n\n" ++ (Github.commentBody comment) formatAuthor :: Github.GithubOwner -> String formatAuthor user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Repos/Commits/GitDiff.hs0000644000000000000000000000061612247053344017216 0ustar0000000000000000module GitDiff where import qualified Github.Repos.Commits as Github import Data.List main = do possibleDiff <- Github.diff "thoughtbot" "paperclip" "41f685f6e01396936bb8cd98e7cca517e2c7d96b" "HEAD" either (\error -> putStrLn $ "Error: " ++ (show error)) (putStrLn . showDiff) possibleDiff showDiff diff = intercalate "\n\n" $ map Github.filePatch $ Github.diffFiles diff github-0.7.2/samples/Repos/Commits/GitLog.hs0000644000000000000000000000152612247053344017070 0ustar0000000000000000module GitLog where import qualified Github.Repos.Commits as Github import Data.List main = do possibleCommits <- Github.commitsFor "thoughtbot" "paperclip" case possibleCommits of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right commits) -> putStrLn $ intercalate "\n\n" $ map formatCommit commits formatCommit :: Github.Commit -> String formatCommit commit = "commit " ++ (Github.commitSha commit) ++ "\nAuthor: " ++ (formatAuthor author) ++ "\nDate: " ++ (show $ Github.fromGithubDate $ Github.gitUserDate author) ++ "\n\n\t" ++ (Github.gitCommitMessage gitCommit) where author = Github.gitCommitAuthor gitCommit gitCommit = Github.commitGitCommit commit formatAuthor :: Github.GitUser -> String formatAuthor author = (Github.gitUserName author) ++ " <" ++ (Github.gitUserEmail author) ++ ">" github-0.7.2/samples/Repos/Commits/GitShow.hs0000644000000000000000000000173212247053344017266 0ustar0000000000000000module GitShow where import qualified Github.Repos.Commits as Github import Data.List main = do possibleCommit <- Github.commit "thoughtbot" "paperclip" "bc5c51d1ece1ee45f94b056a0f5a1674d7e8cba9" case possibleCommit of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right commit) -> putStrLn $ formatCommit commit formatCommit :: Github.Commit -> String formatCommit commit = "commit " ++ (Github.commitSha commit) ++ "\nAuthor: " ++ (formatAuthor author) ++ "\nDate: " ++ (show $ Github.fromGithubDate $ Github.gitUserDate author) ++ "\n\n\t" ++ (Github.gitCommitMessage gitCommit) ++ "\n" ++ patches where author = Github.gitCommitAuthor gitCommit gitCommit = Github.commitGitCommit commit patches = intercalate "\n" $ map Github.filePatch $ Github.commitFiles commit formatAuthor :: Github.GitUser -> String formatAuthor author = (Github.gitUserName author) ++ " <" ++ (Github.gitUserEmail author) ++ ">" github-0.7.2/samples/Repos/Commits/RepoComments.hs0000644000000000000000000000145612247053344020320 0ustar0000000000000000module RepoComments where import qualified Github.Repos.Commits as Github import Data.List import Data.Maybe (maybe) main = do possibleComments <- Github.commentsFor "thoughtbot" "paperclip" case possibleComments of (Left error) -> putStrLn $ "Error: " ++ (show error) (Right comments) -> putStrLn $ intercalate "\n\n" $ map formatComment comments formatComment :: Github.Comment -> String formatComment comment = "Author: " ++ (formatAuthor $ Github.commentUser comment) ++ "\nUpdated: " ++ (show $ Github.commentUpdatedAt comment) ++ (maybe "" ("\nURL: "++) $ Github.commentHtmlUrl comment) ++ "\n\n" ++ (Github.commentBody comment) formatAuthor :: Github.GithubOwner -> String formatAuthor user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Repos/Forks/0000755000000000000000000000000012247053344015014 5ustar0000000000000000github-0.7.2/samples/Repos/Forks/ListForks.hs0000644000000000000000000000107112247053344017267 0ustar0000000000000000module ListForks where import qualified Github.Repos.Forks as Github import Data.List main = do possibleForks <- Github.forksFor "thoughtbot" "paperclip" putStrLn $ either (("Error: "++) . show) (intercalate "\n\n" . map formatFork) possibleForks formatFork fork = (Github.githubOwnerLogin $ Github.repoOwner fork) ++ "\t" ++ (formatPushedAt $ Github.repoPushedAt fork) ++ "\n" ++ (Github.repoCloneUrl fork) formatPushedAt Nothing = "" formatPushedAt (Just pushedAt) = show $ Github.fromGithubDate pushedAt github-0.7.2/samples/Repos/Starring/0000755000000000000000000000000012247053344015521 5ustar0000000000000000github-0.7.2/samples/Repos/Starring/ListStarred.hs0000644000000000000000000000141612247053344020317 0ustar0000000000000000module ListStarred where import qualified Github.Repos.Starring as Github import Data.List (intercalate) import Data.Maybe (fromMaybe) main = do possibleRepos <- Github.reposStarredBy Nothing "mike-burns" putStrLn $ either (("Error: "++) . show) (intercalate "\n\n" . map formatRepo) possibleRepos formatRepo repo = (Github.repoName repo) ++ "\t" ++ (fromMaybe "" $ Github.repoDescription repo) ++ "\n" ++ (Github.repoHtmlUrl repo) ++ "\n" ++ (Github.repoCloneUrl repo) ++ "\t" ++ (formatDate $ Github.repoUpdatedAt repo) ++ "\n" ++ formatLanguage (Github.repoLanguage repo) formatDate = show . Github.fromGithubDate formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.7.2/samples/Repos/Watching/0000755000000000000000000000000012247053344015474 5ustar0000000000000000github-0.7.2/samples/Repos/Watching/ListWatched.hs0000644000000000000000000000157212247053344020250 0ustar0000000000000000module ListWatched where import qualified Github.Repos.Watching as Github import Data.List (intercalate) import Data.Maybe (fromMaybe) main = do possibleRepos <- Github.reposWatchedBy "mike-burns" putStrLn $ either (("Error: "++) . show) (intercalate "\n\n" . map formatRepo) possibleRepos formatRepo repo = (Github.repoName repo) ++ "\t" ++ (fromMaybe "" $ Github.repoDescription repo) ++ "\n" ++ (Github.repoHtmlUrl repo) ++ "\n" ++ (Github.repoCloneUrl repo) ++ "\t" ++ (formatDate $ Github.repoUpdatedAt repo) ++ "\n" ++ formatLanguage (Github.repoLanguage repo) ++ "watchers: " ++ (show $ Github.repoWatchers repo) ++ "\t" ++ "forks: " ++ (show $ Github.repoForks repo) formatDate = show . Github.fromGithubDate formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.7.2/samples/Repos/Watching/ListWatchers.hs0000644000000000000000000000073112247053344020445 0ustar0000000000000000module ListWatchers where import qualified Github.Repos.Watching as Github import Data.List (intercalate) main = do possibleWatchers <- Github.watchersFor "doubledrones" "git-annex" putStrLn $ either (("Error: "++) . show) (intercalate "\n" . map formatWatcher) possibleWatchers formatWatcher :: Github.GithubOwner -> String formatWatcher user = (Github.githubOwnerLogin user) ++ " (" ++ (Github.githubOwnerUrl user) ++ ")" github-0.7.2/samples/Search/0000755000000000000000000000000012247053344014045 5ustar0000000000000000github-0.7.2/samples/Search/SearchRepos.hs0000644000000000000000000000370712247053344016626 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} module SearchRepos where import qualified Github.Search as Github import qualified Github.Data as Github import Control.Monad (forM,forM_) import Data.Maybe (fromMaybe) import Data.List (intercalate) import System.Environment (getArgs) import Text.Printf (printf) import Data.Time.Clock (getCurrentTime, UTCTime(..)) import Data.Time.LocalTime (utc,utcToLocalTime,localDay,localTimeOfDay,TimeOfDay(..)) import Data.Time.Calendar (toGregorian) main = do args <- getArgs date <- case args of (x:_) -> return x otherwise -> today let query = "q=language%3Ahaskell created%3A>" ++ date ++ "&per_page=100" let auth = Nothing result <- Github.searchRepos' auth query case result of Left e -> putStrLn $ "Error: " ++ show e Right r -> do forM_ (Github.searchReposRepos r) (\r -> do putStrLn $ formatRepo r putStrLn "" ) putStrLn $ "Count: " ++ show n ++ " Haskell repos created since " ++ date where n = Github.searchReposTotalCount r -- | return today (in UTC) formatted as YYYY-MM-DD today :: IO String today = do now <- getCurrentTime let day = localDay $ utcToLocalTime utc now (y,m,d) = toGregorian day in return $ printf "%d-%02d-%02d" y m d formatRepo :: Github.Repo -> String formatRepo r = let fields = [ ("Name", Github.repoName) ,("URL", Github.repoHtmlUrl) ,("Description", orEmpty . Github.repoDescription) ,("Created-At", formatDate . Github.repoCreatedAt) ,("Pushed-At", formatMaybeDate . Github.repoPushedAt) ] in intercalate "\n" $ map fmt fields where fmt (s,f) = fill 12 (s ++ ":") ++ " " ++ f r orEmpty = fromMaybe "" fill n s = s ++ replicate n' ' ' where n' = max 0 (n - length s) formatMaybeDate = maybe "???" formatDate formatDate = show . Github.fromGithubDate github-0.7.2/samples/Users/0000755000000000000000000000000012247053344013741 5ustar0000000000000000github-0.7.2/samples/Users/ShowUser.hs0000644000000000000000000000361112247053344016055 0ustar0000000000000000module ShowUser where import qualified Github.Users as Github import Data.Maybe (fromMaybe) main = do possibleUser <- Github.userInfoFor "mike-burns" putStrLn $ either (("Error: "++) . show) formatUser possibleUser formatUser user@(Github.DetailedOrganization {}) = "Organization: " ++ (formatName userName login) ++ "\t" ++ (fromMaybe "" company) ++ "\t" ++ (fromMaybe "" location) ++ "\n" ++ (fromMaybe "" blog) ++ "\t" ++ "\n" ++ htmlUrl ++ "\t" ++ (formatDate createdAt) ++ "\n\n" ++ (fromMaybe "" bio) where userName = Github.detailedOwnerName user login = Github.detailedOwnerLogin user company = Github.detailedOwnerCompany user location = Github.detailedOwnerLocation user blog = Github.detailedOwnerBlog user htmlUrl = Github.detailedOwnerHtmlUrl user createdAt = Github.detailedOwnerCreatedAt user bio = Github.detailedOwnerBio user formatUser user@(Github.DetailedUser {}) = (formatName userName login) ++ "\t" ++ (fromMaybe "" company) ++ "\t" ++ (fromMaybe "" location) ++ "\n" ++ (fromMaybe "" blog) ++ "\t" ++ "<" ++ email ++ ">" ++ "\n" ++ htmlUrl ++ "\t" ++ (formatDate createdAt) ++ "\n" ++ "hireable: " ++ (formatHireable isHireable) ++ "\n\n" ++ (fromMaybe "" bio) where userName = Github.detailedOwnerName user login = Github.detailedOwnerLogin user company = Github.detailedOwnerCompany user location = Github.detailedOwnerLocation user blog = Github.detailedOwnerBlog user email = Github.detailedOwnerEmail user htmlUrl = Github.detailedOwnerHtmlUrl user createdAt = Github.detailedOwnerCreatedAt user isHireable = Github.detailedOwnerHireable user bio = Github.detailedOwnerBio user formatName Nothing login = login formatName (Just name) login = name ++ "(" ++ login ++ ")" formatHireable True = "yes" formatHireable False = "no" formatDate = show . Github.fromGithubDate github-0.7.2/samples/Users/Followers/0000755000000000000000000000000012247053344015715 5ustar0000000000000000github-0.7.2/samples/Users/Followers/ListFollowers.hs0000644000000000000000000000053112247053344021060 0ustar0000000000000000module ListFollowers where import qualified Github.Users.Followers as Github import Data.List (intercalate) main = do possibleUsers <- Github.usersFollowing "mike-burns" putStrLn $ either (("Error: "++) . show) (intercalate "\n" . map formatUser) possibleUsers formatUser = Github.githubOwnerLogin github-0.7.2/samples/Users/Followers/ListFollowing.hs0000644000000000000000000000053312247053344021046 0ustar0000000000000000module ListFollowing where import qualified Github.Users.Followers as Github import Data.List (intercalate) main = do possibleUsers <- Github.usersFollowedBy "mike-burns" putStrLn $ either (("Error: "++) . show) (intercalate "\n" . map formatUser) possibleUsers formatUser = Github.githubOwnerLogin