github-0.13.2/0000755000000000000000000000000012517241563011253 5ustar0000000000000000github-0.13.2/github.cabal0000644000000000000000000002136112517241563013524 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.13.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@newartisans.com Homepage: https://github.com/jwiegley/github -- A copyright notice. Copyright: Copyright 2012-2013 Mike Burns, Copyright 2013-2015 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/GitCreateReference.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/Repos/Webhooks/CreateWebhook.hs ,samples/Repos/Webhooks/DeleteWebhook.hs ,samples/Repos/Webhooks/EditWebhook.hs ,samples/Repos/Webhooks/ListWebhook.hs ,samples/Repos/Webhooks/ListWebhooks.hs ,samples/Repos/Webhooks/PingWebhook.hs ,samples/Repos/Webhooks/TestPushWebhook.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.10 source-repository head type: git location: git://github.com/jwiegley/github.git Library -- Modules exported by the library. Default-Language: Haskell2010 Exposed-modules: Github.Auth, Github.Data, Github.Data.Definitions, Github.Events, 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.Repos.Subscribing, Github.Repos.Webhooks Github.Repos.Webhooks.Validate, 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, cryptohash >= 0.11, byteable >= 0.1.0, base16-bytestring >= 0.1.1.6 -- 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 test-suite github-test default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: spec, . main-is: Spec.hs 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, cryptohash >= 0.11, byteable >= 0.1.0, base16-bytestring >= 0.1.1.6 , hspec ghc-options: -Wall -fno-warn-orphans github-0.13.2/LICENSE0000644000000000000000000000275512517241563012271 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.13.2/README.md0000644000000000000000000000312312517241563012531 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 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 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. Copyright 2013-2014 John Wiegley. Available under the BSD 3-clause license. github-0.13.2/Setup.hs0000644000000000000000000000005612517241563012710 0ustar0000000000000000import Distribution.Simple main = defaultMain github-0.13.2/Github/0000755000000000000000000000000012517241563012475 5ustar0000000000000000github-0.13.2/Github/Auth.hs0000644000000000000000000000016112517241563013730 0ustar0000000000000000-- | The Github auth data type module Github.Auth (P.GithubAuth(..)) where import qualified Github.Private as P github-0.13.2/Github/Data.hs0000644000000000000000000006004712517241563013711 0ustar0000000000000000{-# LANGUAGE CPP, 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 Control.Applicative import Control.Monad import qualified Data.Text as T import Data.Aeson.Types import qualified Data.Vector as V import qualified Data.HashMap.Lazy as Map import Data.Hashable (Hashable) #if MIN_VERSION_base(4,8,0) import Data.Time #else import Data.Time import System.Locale (defaultTimeLocale) #endif 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 ToJSON NewGitReference where toJSON (NewGitReference r s) = object [ "ref" .= r, "sha" .= s ] 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 .: "events_url" <*> 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 (String "unassigned") = pure ActorUnassigned parseJSON (String "labeled") = pure Labeled parseJSON (String "unlabeled") = pure Unlabeled parseJSON (String "milestoned") = pure Milestoned parseJSON (String "demilestoned") = pure Demilestoned parseJSON (String "renamed") = pure Renamed parseJSON (String "locked") = pure Locked parseJSON (String "unlocked") = pure Unlocked parseJSON (String "head_ref_deleted") = pure HeadRefDeleted parseJSON (String "head_ref_restored") = pure HeadRefRestored 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 ToJSON EditPullRequestState where toJSON (EditPullRequestStateOpen) = String "open" toJSON (EditPullRequestStateClosed) = String "closed" instance ToJSON EditPullRequest where toJSON (EditPullRequest t b s) = object $ filter notNull [ "title" .= t, "body" .= b, "state" .= s ] where notNull (_, Null) = False notNull (_, _) = True instance ToJSON CreatePullRequest where toJSON (CreatePullRequest t b headPR basePR) = object [ "title" .= t, "body" .= b, "head" .= headPR, "base" .= basePR ] toJSON (CreatePullRequestIssue issueNum headPR basePR) = object [ "issue" .= issueNum, "head" .= headPR, "base" .= basePR] 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 o) = PullRequestCommit <$> o .: "label" <*> o .: "ref" <*> o .: "sha" <*> o .: "user" <*> o .: "repo" parseJSON _ = fail "Could not build a PullRequestCommit" instance FromJSON PullRequestEvent where parseJSON (Object o) = PullRequestEvent <$> o .: "action" <*> o .: "number" <*> o .: "pull_request" <*> o .: "repository" <*> o .: "sender" parseJSON _ = fail "Could not build a PullRequestEvent" instance FromJSON PullRequestEventType where parseJSON (String "opened") = pure PullRequestOpened parseJSON (String "closed") = pure PullRequestClosed parseJSON (String "synchronize") = pure PullRequestSynchronized parseJSON (String "reopened") = pure PullRequestReopened parseJSON (String "assigned") = pure PullRequestAssigned parseJSON (String "unassigned") = pure PullRequestUnassigned parseJSON (String "labeled") = pure PullRequestLabeled parseJSON (String "unlabeled") = pure PullRequestUnlabeled parseJSON _ = fail "Could not build a PullRequestEventType" instance FromJSON RepoWebhookEvent where parseJSON (String "*") = pure WebhookWildcardEvent parseJSON (String "commit_comment") = pure WebhookCommitCommentEvent parseJSON (String "create") = pure WebhookCreateEvent parseJSON (String "delete") = pure WebhookDeleteEvent parseJSON (String "deployment") = pure WebhookDeploymentEvent parseJSON (String "deployment_status") = pure WebhookDeploymentStatusEvent parseJSON (String "fork") = pure WebhookForkEvent parseJSON (String "gollum") = pure WebhookGollumEvent parseJSON (String "issue_comment") = pure WebhookIssueCommentEvent parseJSON (String "issues") = pure WebhookIssuesEvent parseJSON (String "member") = pure WebhookMemberEvent parseJSON (String "page_build") = pure WebhookPageBuildEvent parseJSON (String "public") = pure WebhookPublicEvent parseJSON (String "pull_request_review_comment") = pure WebhookPullRequestReviewCommentEvent parseJSON (String "pull_request") = pure WebhookPullRequestEvent parseJSON (String "push") = pure WebhookPushEvent parseJSON (String "release") = pure WebhookReleaseEvent parseJSON (String "status") = pure WebhookStatusEvent parseJSON (String "team_add") = pure WebhookTeamAddEvent parseJSON (String "watch") = pure WebhookWatchEvent parseJSON _ = fail "Could not build a Webhook event" instance ToJSON RepoWebhookEvent where toJSON (WebhookWildcardEvent) = String "*" toJSON (WebhookCommitCommentEvent) = String "commit_comment" toJSON (WebhookCreateEvent) = String "create" toJSON (WebhookDeleteEvent) = String "delete" toJSON (WebhookDeploymentEvent) = String "deployment" toJSON (WebhookDeploymentStatusEvent) = String "deployment_status" toJSON (WebhookForkEvent) = String "fork" toJSON (WebhookGollumEvent) = String "gollum" toJSON (WebhookIssueCommentEvent) = String "issue_comment" toJSON (WebhookIssuesEvent) = String "issues" toJSON (WebhookMemberEvent) = String "member" toJSON (WebhookPageBuildEvent) = String "page_build" toJSON (WebhookPublicEvent) = String "public" toJSON (WebhookPullRequestReviewCommentEvent) = String "pull_request_review_comment" toJSON (WebhookPullRequestEvent) = String "pull_request" toJSON (WebhookPushEvent) = String "push" toJSON (WebhookReleaseEvent) = String "release" toJSON (WebhookStatusEvent) = String "status" toJSON (WebhookTeamAddEvent) = String "team_add" toJSON (WebhookWatchEvent) = String "watch" instance FromJSON PingEvent where parseJSON (Object o) = PingEvent <$> o .: "zen" <*> o .: "hook" <*> o .: "hook_id" parseJSON _ = fail "Could not build a PingEvent" 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" <*> o .: "hooks_url" parseJSON _ = fail "Could not build a Repo" instance FromJSON SearchCodeResult where parseJSON (Object o) = SearchCodeResult <$> o .: "total_count" <*> o .:< "items" parseJSON _ = fail "Could not build a SearchCodeResult" instance FromJSON Code where parseJSON (Object o ) = Code <$> o .: "name" <*> o .: "path" <*> o .: "sha" <*> o .: "url" <*> o .: "git_url" <*> o .: "html_url" <*> o .: "repository" parseJSON _ = fail "Could not build a Code" 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" instance FromJSON RepoWebhook where parseJSON (Object o) = RepoWebhook <$> o .: "url" <*> o .: "test_url" <*> o .: "id" <*> o .: "name" <*> o .: "active" <*> o .: "events" <*> o .: "config" <*> o .: "last_response" <*> o .: "updated_at" <*> o .: "created_at" parseJSON _ = fail "Could not build a RepoWebhook" instance FromJSON RepoWebhookResponse where parseJSON (Object o) = RepoWebhookResponse <$> o .: "code" <*> o .: "status" <*> o .: "message" parseJSON _ = fail "Could not build a RepoWebhookResponse" instance FromJSON Content where parseJSON o@(Object _) = ContentFile <$> parseJSON o parseJSON (Array os) = ContentDirectory <$> (mapM parseJSON $ V.toList os) parseJSON _ = fail "Could not build a Content" instance FromJSON ContentData where parseJSON (Object o) = ContentData <$> o .: "type" <*> o .: "encoding" <*> o .: "size" <*> o .: "name" <*> o .: "path" <*> o .: "content" <*> o .: "sha" <*> o .: "url" <*> o .: "git_url" <*> o .: "html_url" parseJSON _ = fail "Could not build a ContentData" -- | 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) => Object -> [T.Text] -> Parser v obj <.:> [key] = obj .: key obj <.:> (key:keys) = let (Object nextObj) = findWithDefault (Object Map.empty) key obj in nextObj <.:> keys _ <.:> [] = fail "must have a pair" -- | 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.13.2/Github/Events.hs0000644000000000000000000000045212517241563014276 0ustar0000000000000000module Github.Events ( parseEvent ) where import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Aeson (FromJSON) import Github.Data.Definitions (Error(..)) import Github.Private (parseJson) parseEvent :: (FromJSON b, Show b) => LBS.ByteString -> Either Error b parseEvent = parseJson github-0.13.2/Github/Gists.hs0000644000000000000000000000173012517241563014123 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.13.2/Github/Issues.hs0000644000000000000000000001124112517241563014303 0ustar0000000000000000{-# LANGUAGE CPP, OverloadedStrings #-} -- | The issues API as described on . module Github.Issues ( issue ,issue' ,issuesForRepo ,issuesForRepo' ,IssueLimitation(..) ,createIssue ,newIssue ,editIssue ,editOfIssue ,module Github.Data ) where import Github.Data import Github.Private import Data.List (intercalate) #if MIN_VERSION_base(4, 8, 0) import Data.Time (defaultTimeLocale) #else import System.Locale (defaultTimeLocale) #endif import Data.Time.Format (formatTime) 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.13.2/Github/Organizations.hs0000644000000000000000000000262012517241563015660 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.13.2/Github/Private.hs0000644000000000000000000001747612517241563014462 0ustar0000000000000000{-# LANGUAGE OverloadedStrings, StandaloneDeriving, DeriveDataTypeable #-} {-# LANGUAGE CPP, FlexibleContexts #-} 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 (Status(..), notFound404) 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 :: BS.ByteString -> [Char] -> Maybe GithubAuth -> Maybe RequestBody -> 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 , responseTimeout = Just 20000000 , requestHeaders = reqHeaders <> [("User-Agent", "github.hs/0.7.4")] <> [("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 doHttpsStatus :: BS.ByteString -> String -> GithubAuth -> Maybe RequestBody -> IO (Either Error Status) doHttpsStatus reqMethod url auth payload = do result <- doHttps reqMethod url (Just auth) payload 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 status) 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.13.2/Github/PullRequests.hs0000644000000000000000000001203212517241563015477 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} -- | The pull requests API as documented at -- . module Github.PullRequests ( pullRequestsFor' ,pullRequest' ,pullRequestCommits' ,pullRequestFiles' ,pullRequestsFor ,pullRequest ,pullRequestCommits ,pullRequestFiles ,isPullRequestMerged ,mergePullRequest ,createPullRequest ,updatePullRequest ,module Github.Data ) where import Github.Data import Github.Private import Network.HTTP.Types import qualified Data.Map as M import Network.HTTP.Conduit (RequestBody(RequestBodyLBS)) import Data.Aeson -- | 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 -- | Check if pull request has been merged isPullRequestMerged :: GithubAuth -> String -> String -> Int -> IO(Either Error Status) isPullRequestMerged auth reqRepoOwner reqRepoName reqPullRequestNumber = doHttpsStatus "GET" (buildUrl ["repos", reqRepoOwner, reqRepoName, "pulls", (show reqPullRequestNumber), "merge"]) auth Nothing -- | Merge a pull request mergePullRequest :: GithubAuth -> String -> String -> Int -> Maybe String -> IO(Either Error Status) mergePullRequest auth reqRepoOwner reqRepoName reqPullRequestNumber commitMessage = doHttpsStatus "PUT" (buildUrl ["repos", reqRepoOwner, reqRepoName, "pulls", (show reqPullRequestNumber), "merge"]) auth (Just . RequestBodyLBS . encode . toJSON $ (buildCommitMessageMap commitMessage)) -- | Update a pull request updatePullRequest :: GithubAuth -> String -> String -> Int -> EditPullRequest -> IO (Either Error DetailedPullRequest) updatePullRequest auth reqRepoOwner reqRepoName reqPullRequestNumber editPullRequest = githubPatch auth ["repos", reqRepoOwner, reqRepoName, "pulls", show reqPullRequestNumber] editPullRequest buildCommitMessageMap :: Maybe String -> M.Map String String buildCommitMessageMap (Just commitMessage) = M.singleton "commit_message" commitMessage buildCommitMessageMap _ = M.empty createPullRequest :: GithubAuth -> String -> String -> CreatePullRequest -> IO (Either Error DetailedPullRequest) createPullRequest auth reqUserName reqRepoName createPR = githubPost auth ["repos", reqUserName, reqRepoName, "pulls"] createPR github-0.13.2/Github/Repos.hs0000644000000000000000000003072312517241563014126 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 ,contributors' ,contributorsWithAnonymous ,contributorsWithAnonymous' ,languagesFor ,languagesFor' ,tagsFor ,tagsFor' ,branchesFor ,branchesFor' ,contentsFor ,contentsFor' ,module Github.Data ,RepoPublicity(..) -- ** 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 (GithubBasicAuth (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 (GithubBasicAuth (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 (GithubBasicAuth (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 (GithubBasicAuth (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 = contributors' Nothing -- | The contributors to a repo, given the owner and repo name. -- With authentication. -- -- > contributors' (Just (GithubBasicAuth (user, password))) "thoughtbot" "paperclip" contributors' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Contributor]) contributors' auth userName reqRepoName = githubGet' auth ["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 = contributorsWithAnonymous' Nothing -- | 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. -- With authentication. -- -- > contributorsWithAnonymous' (Just (GithubBasicAuth (user, password))) "thoughtbot" "paperclip" contributorsWithAnonymous' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Contributor]) contributorsWithAnonymous' auth userName reqRepoName = githubGetWithQueryString' auth ["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 = languagesFor' Nothing -- | The programming languages used in a repo along with the number of -- characters written in that language. Takes the repo owner and name. -- With authentication. -- -- > languagesFor' (Just (GithubBasicAuth (user, password))) "mike-burns" "ohlaunch" languagesFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Language]) languagesFor' auth userName reqRepoName = do result <- githubGet' auth ["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 = tagsFor' Nothing -- | The git tags on a repo, given the repo owner and name. -- With authentication. -- -- > tagsFor' (Just (GithubBasicAuth (user, password))) "thoughtbot" "paperclip" tagsFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Tag]) tagsFor' auth userName reqRepoName = githubGet' auth ["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 = branchesFor' Nothing -- | The git branches on a repo, given the repo owner and name. -- With authentication. -- -- > branchesFor' (Just (GithubBasicAuth (user, password))) "thoughtbot" "paperclip" branchesFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Branch]) branchesFor' auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName, "branches"] -- | The contents of a file or directory in a repo, given the repo owner, name, and path to the file -- -- > contentsFor "thoughtbot" "paperclip" "README.md" contentsFor :: String -> String -> String -> Maybe String -> IO (Either Error Content) contentsFor = contentsFor' Nothing -- | The contents of a file or directory in a repo, given the repo owner, name, and path to the file -- With Authentication -- -- > contentsFor' (Just (GithubBasicAuth (user, password))) "thoughtbot" "paperclip" "README.md" contentsFor' :: Maybe GithubAuth -> String -> String -> String -> Maybe String -> IO (Either Error Content) contentsFor' auth userName reqRepoName reqContentPath ref = githubGetWithQueryString' auth ["repos", userName, reqRepoName, "contents", reqContentPath] $ maybe "" ("ref="++) ref 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 (GithubBasicAuth (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 (GithubBasicAuth (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 (GithubBasicAuth (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 (GithubBasicAuth (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.13.2/Github/Search.hs0000644000000000000000000000271412517241563014242 0ustar0000000000000000-- | The Github Search API, as described at -- . module Github.Search( searchRepos' ,searchRepos ,searchCode' ,searchCode ,module Github.Data ) 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 -- | Perform a code search. -- | With authentication. -- -- > searchCode' (Just $ GithubBasicAuth "github-username" "github-password') "q=a in%3Aname language%3Ahaskell created%3A>2013-10-01&per_page=100" searchCode' :: Maybe GithubAuth -> String -> IO (Either Error SearchCodeResult) searchCode' auth queryString = githubGetWithQueryString' auth ["search", "code"] queryString -- | Perform a code search. -- | Without authentication. -- -- > searchCode "q=addClass+in:file+language:js+repo:jquery/jquery" searchCode :: String -> IO (Either Error SearchCodeResult) searchCode = searchCode' Nothing github-0.13.2/Github/Users.hs0000644000000000000000000000126512517241563014136 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.13.2/Github/Data/0000755000000000000000000000000012517241563013346 5ustar0000000000000000github-0.13.2/Github/Data/Definitions.hs0000644000000000000000000004600112517241563016156 0ustar0000000000000000{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} module Github.Data.Definitions where import Data.Time import Data.Data import qualified Control.Exception as E import qualified Data.Map as M -- | 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 -- Can be empty for submodule ,gitTreeUrl :: Maybe 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 :: Maybe String ,commentUpdatedAt :: UTCTime ,commentHtmlUrl :: Maybe String ,commentUrl :: String ,commentCreatedAt :: Maybe 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 NewGitReference = NewGitReference { newGitReferenceRef :: String ,newGitReferenceSha :: String } 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 ,issueEventsUrl :: String ,issueHtmlUrl :: Maybe String ,issueClosedBy :: Maybe GithubOwner ,issueLabels :: [IssueLabel] ,issueNumber :: Int ,issueAssignee :: Maybe GithubOwner ,issueUser :: GithubOwner ,issueTitle :: String ,issuePullRequest :: Maybe 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 :: Maybe 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. | ActorUnassigned -- ^ The issue was unassigned to the actor | Labeled -- ^ A label was added to the issue. | Unlabeled -- ^ A label was removed from the issue. | Milestoned -- ^ The issue was added to a milestone. | Demilestoned -- ^ The issue was removed from a milestone. | Renamed -- ^ The issue title was changed. | Locked -- ^ The issue was locked by the actor. | Unlocked -- ^ The issue was unlocked by the actor. | HeadRefDeleted -- ^ The pull request’s branch was deleted. | HeadRefRestored -- ^ The pull request’s branch was restored. 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 :: Maybe Bool } deriving (Show, Data, Typeable, Eq, Ord) data EditPullRequest = EditPullRequest { editPullRequestTitle :: Maybe String ,editPullRequestBody :: Maybe String ,editPullRequestState :: Maybe EditPullRequestState } deriving (Show) data CreatePullRequest = CreatePullRequest { createPullRequestTitle :: String , createPullRequestBody :: String , createPullRequestHead :: String , createPullRequestBase :: String } | CreatePullRequestIssue { createPullRequestIssueNum :: Int , createPullRequestHead :: String , createPullRequestBase :: String } deriving (Show) data PullRequestLinks = PullRequestLinks { pullRequestLinksReviewComments :: String ,pullRequestLinksComments :: String ,pullRequestLinksHtml :: String ,pullRequestLinksSelf :: String } deriving (Show, Data, Typeable, Eq, Ord) data PullRequestCommit = PullRequestCommit { pullRequestCommitLabel :: String ,pullRequestCommitRef :: String ,pullRequestCommitSha :: String ,pullRequestCommitUser :: GithubOwner ,pullRequestCommitRepo :: Repo } deriving (Show, Data, Typeable, Eq, Ord) data SearchReposResult = SearchReposResult { searchReposTotalCount :: Int ,searchReposRepos :: [Repo] } deriving (Show, Data, Typeable, Eq, Ord) data Repo = Repo { repoSshUrl :: Maybe String ,repoDescription :: Maybe String ,repoCreatedAt :: Maybe GithubDate ,repoHtmlUrl :: String ,repoSvnUrl :: Maybe String ,repoForks :: Maybe Int ,repoHomepage :: Maybe String ,repoFork :: Maybe Bool ,repoGitUrl :: Maybe String ,repoPrivate :: Bool ,repoCloneUrl :: Maybe String ,repoSize :: Maybe Int ,repoUpdatedAt :: Maybe GithubDate ,repoWatchers :: Maybe 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 :: Maybe Int ,repoHasWiki :: Maybe Bool ,repoHasIssues :: Maybe Bool ,repoHasDownloads :: Maybe Bool ,repoParent :: Maybe RepoRef ,repoSource :: Maybe RepoRef ,repoHooksUrl :: String } deriving (Show, Data, Typeable, Eq, Ord) data RepoRef = RepoRef GithubOwner String -- Repo owner and name deriving (Show, Data, Typeable, Eq, Ord) data SearchCodeResult = SearchCodeResult { searchCodeTotalCount :: Int ,searchCodeCodes :: [Code] } deriving (Show, Data, Typeable, Eq, Ord) data Code = Code { codeName :: String ,codePath :: String ,codeSha :: String ,codeUrl :: String ,codeGitUrl :: String ,codeHtmlUrl :: String ,codeRepo :: Repo } deriving (Show, Data, Typeable, Eq, Ord) data Content = ContentFile ContentData | ContentDirectory [ContentData] deriving (Show, Data, Typeable, Eq, Ord) data ContentData = ContentData { contentType :: String ,contentEncoding :: String ,contentSize :: Int ,contentName :: String ,contentPath :: String ,contentData :: String ,contentSha :: String ,contentUrl :: String ,contentGitUrl :: String ,contentHtmlUrl :: String } 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 :: Maybe Bool ,detailedOwnerGravatarId :: Maybe String ,detailedOwnerBlog :: Maybe String ,detailedOwnerBio :: Maybe String ,detailedOwnerPublicRepos :: Int ,detailedOwnerName :: Maybe String ,detailedOwnerLocation :: Maybe String ,detailedOwnerCompany :: Maybe String ,detailedOwnerEmail :: Maybe 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) data RepoWebhook = RepoWebhook { repoWebhookUrl :: String ,repoWebhookTestUrl :: String ,repoWebhookId :: Integer ,repoWebhookName :: String ,repoWebhookActive :: Bool ,repoWebhookEvents :: [RepoWebhookEvent] ,repoWebhookConfig :: M.Map String String ,repoWebhookLastResponse :: RepoWebhookResponse ,repoWebhookUpdatedAt :: GithubDate ,repoWebhookCreatedAt :: GithubDate } deriving (Show, Data, Typeable, Eq, Ord) data RepoWebhookEvent = WebhookWildcardEvent | WebhookCommitCommentEvent | WebhookCreateEvent | WebhookDeleteEvent | WebhookDeploymentEvent | WebhookDeploymentStatusEvent | WebhookForkEvent | WebhookGollumEvent | WebhookIssueCommentEvent | WebhookIssuesEvent | WebhookMemberEvent | WebhookPageBuildEvent | WebhookPublicEvent | WebhookPullRequestReviewCommentEvent | WebhookPullRequestEvent | WebhookPushEvent | WebhookReleaseEvent | WebhookStatusEvent | WebhookTeamAddEvent | WebhookWatchEvent deriving (Show, Data, Typeable, Eq, Ord) data RepoWebhookResponse = RepoWebhookResponse { repoWebhookResponseCode :: Maybe Int ,repoWebhookResponseStatus :: String ,repoWebhookResponseMessage :: Maybe String } deriving (Show, Data, Typeable, Eq, Ord) data PullRequestEvent = PullRequestEvent { pullRequestEventAction :: PullRequestEventType ,pullRequestEventNumber :: Int ,pullRequestEventPullRequest :: DetailedPullRequest ,pullRequestRepository :: Repo ,pullRequestSender :: GithubOwner } deriving (Show, Data, Typeable, Eq, Ord) data PullRequestEventType = PullRequestOpened | PullRequestClosed | PullRequestSynchronized | PullRequestReopened | PullRequestAssigned | PullRequestUnassigned | PullRequestLabeled | PullRequestUnlabeled deriving (Show, Data, Typeable, Eq, Ord) data PingEvent = PingEvent { pingEventZen :: String ,pingEventHook :: RepoWebhook ,pingEventHookId :: Int } deriving (Show, Data, Typeable, Eq, Ord) data EditPullRequestState = EditPullRequestStateOpen | EditPullRequestStateClosed deriving Show github-0.13.2/Github/Gists/0000755000000000000000000000000012517241563013566 5ustar0000000000000000github-0.13.2/Github/Gists/Comments.hs0000644000000000000000000000117112517241563015707 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.13.2/Github/GitData/0000755000000000000000000000000012517241563014012 5ustar0000000000000000github-0.13.2/Github/GitData/Blobs.hs0000644000000000000000000000074712517241563015417 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.13.2/Github/GitData/Commits.hs0000644000000000000000000000077712517241563015774 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.13.2/Github/GitData/References.hs0000644000000000000000000000262712517241563016436 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 ,createReference ,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"] createReference :: GithubAuth -> String -> String -> NewGitReference -> IO (Either Error GitReference) createReference auth owner reqRepoName newRef = githubPost auth ["repos", owner, reqRepoName, "git", "refs"] newRef -- | Limited references by a namespace. -- -- > 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.13.2/Github/GitData/Trees.hs0000644000000000000000000000265212517241563015435 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 (Just ("github-username", "github-password")) "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" tree' :: Maybe GithubAuth -> String -> String -> String -> IO (Either Error Tree) tree' auth user reqRepoName sha = githubGet' auth ["repos", user, reqRepoName, "git", "trees", sha] -- | A tree for a SHA1. -- -- > tree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" tree :: String -> String -> String -> IO (Either Error Tree) tree = tree' Nothing -- | A recursively-nested tree for a SHA1. -- -- > nestedTree' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" nestedTree' :: Maybe GithubAuth -> String -> String -> String -> IO (Either Error Tree) nestedTree' auth user reqRepoName sha = githubGetWithQueryString' auth ["repos", user, reqRepoName, "git", "trees", sha] "recursive=1" -- | A recursively-nested tree for a SHA1. -- -- > nestedTree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844" nestedTree :: String -> String -> String -> IO (Either Error Tree) nestedTree = nestedTree' Nothing github-0.13.2/Github/Issues/0000755000000000000000000000000012517241563013750 5ustar0000000000000000github-0.13.2/Github/Issues/Comments.hs0000644000000000000000000000360712517241563016077 0ustar0000000000000000-- | The Github issue comments API from -- . module Github.Issues.Comments ( comment ,comments ,comments' ,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.13.2/Github/Issues/Events.hs0000644000000000000000000000423012517241563015547 0ustar0000000000000000-- | The Github issue events API, which is described on -- module Github.Issues.Events ( eventsForIssue ,eventsForIssue' ,eventsForRepo ,eventsForRepo' ,event ,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 events that have happened on an issue, using authentication. -- -- > eventsForIssue' (GithubUser (user, password)) "thoughtbot" "paperclip" 49 eventsForIssue' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error [Event]) eventsForIssue' auth user reqRepoName reqIssueNumber = githubGet' auth ["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"] -- | All the events for all issues in a repo, using authentication. -- -- > eventsForRepo' (GithubUser (user, password)) "thoughtbot" "paperclip" eventsForRepo' :: Maybe GithubAuth -> String -> String -> IO (Either Error [Event]) eventsForRepo' auth user reqRepoName = githubGet' auth ["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] -- | Details on a specific event, by the event's ID, using authentication. -- -- > event' (GithubUser (user, password)) "thoughtbot" "paperclip" 5335772 event' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error Event) event' auth user reqRepoName reqEventId = githubGet' auth ["repos", user, reqRepoName, "issues", "events", show reqEventId] github-0.13.2/Github/Issues/Labels.hs0000644000000000000000000000257512517241563015517 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.13.2/Github/Issues/Milestones.hs0000644000000000000000000000200712517241563016425 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.13.2/Github/Organizations/0000755000000000000000000000000012517241563015324 5ustar0000000000000000github-0.13.2/Github/Organizations/Members.hs0000644000000000000000000000067212517241563017257 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.13.2/Github/Repos/0000755000000000000000000000000012517241563013565 5ustar0000000000000000github-0.13.2/Github/Repos/Collaborators.hs0000644000000000000000000000255212517241563016733 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.13.2/Github/Repos/Commits.hs0000644000000000000000000000354712517241563015545 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.13.2/Github/Repos/Forks.hs0000644000000000000000000000133312517241563015205 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.13.2/Github/Repos/Starring.hs0000644000000000000000000000170212517241563015712 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.13.2/Github/Repos/Subscribing.hs0000644000000000000000000000264112517241563016376 0ustar0000000000000000-- | The repo subscribing API as described on -- . module Github.Repos.Subscribing ( subscribersFor ,subscribersFor' ,reposSubscribedToBy ,reposSubscribedToBy' ,module Github.Data ) where import Github.Data import Github.Private -- | The list of users that are subscribed to the specified Github repo. -- -- > subscribersFor "thoughtbot" "paperclip" subscribersFor :: String -> String -> IO (Either Error [GithubOwner]) subscribersFor = subscribersFor' Nothing -- | The list of users that are subscribed to the specified Github repo. -- | With authentication -- -- > subscribersFor' (Just (GithubUser (user, password))) "thoughtbot" "paperclip" subscribersFor' :: Maybe GithubAuth -> String -> String -> IO (Either Error [GithubOwner]) subscribersFor' auth userName reqRepoName = githubGet' auth ["repos", userName, reqRepoName, "subscribers"] -- | All the public repos subscribed to by the specified user. -- -- > reposSubscribedToBy "croaky" reposSubscribedToBy :: String -> IO (Either Error [Repo]) reposSubscribedToBy = reposSubscribedToBy' Nothing -- | All the public repos subscribed to by the specified user. -- | With authentication -- -- > reposSubscribedToBy' (Just (GithubUser (user, password))) "croaky" reposSubscribedToBy' :: Maybe GithubAuth -> String -> IO (Either Error [Repo]) reposSubscribedToBy' auth userName = githubGet' auth ["users", userName, "subscriptions"] github-0.13.2/Github/Repos/Watching.hs0000644000000000000000000000246412517241563015673 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.13.2/Github/Repos/Webhooks.hs0000644000000000000000000001112112517241563015676 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} -- | The webhooks API, as described at -- -- module Github.Repos.Webhooks ( -- * Querying repositories webhooksFor' ,webhookFor' -- ** Create ,createRepoWebhook' -- ** Edit ,editRepoWebhook' -- ** Test ,testPushRepoWebhook' ,pingRepoWebhook' -- ** Delete ,deleteRepoWebhook' ,NewRepoWebhook(..) ,EditRepoWebhook(..) ,RepoOwner ,RepoName ,RepoWebhookId ) where import Github.Data import Github.Private import qualified Data.Map as M import Network.HTTP.Conduit import Network.HTTP.Types import Data.Aeson type RepoOwner = String type RepoName = String type RepoWebhookId = Int data NewRepoWebhook = NewRepoWebhook { newRepoWebhookName :: String ,newRepoWebhookConfig :: M.Map String String ,newRepoWebhookEvents :: Maybe [RepoWebhookEvent] ,newRepoWebhookActive :: Maybe Bool } deriving Show data EditRepoWebhook = EditRepoWebhook { editRepoWebhookConfig :: Maybe (M.Map String String) ,editRepoWebhookEvents :: Maybe [RepoWebhookEvent] ,editRepoWebhookAddEvents :: Maybe [RepoWebhookEvent] ,editRepoWebhookRemoveEvents :: Maybe [RepoWebhookEvent] ,editRepoWebhookActive :: Maybe Bool } deriving Show instance ToJSON NewRepoWebhook where toJSON (NewRepoWebhook { newRepoWebhookName = name , newRepoWebhookConfig = config , newRepoWebhookEvents = events , newRepoWebhookActive = active }) = object [ "name" .= name , "config" .= config , "events" .= events , "active" .= active ] instance ToJSON EditRepoWebhook where toJSON (EditRepoWebhook { editRepoWebhookConfig = config , editRepoWebhookEvents = events , editRepoWebhookAddEvents = addEvents , editRepoWebhookRemoveEvents = removeEvents , editRepoWebhookActive = active }) = object [ "config" .= config , "events" .= events , "add_events" .= addEvents , "remove_events" .= removeEvents , "active" .= active ] webhooksFor' :: GithubAuth -> RepoOwner -> RepoName -> IO (Either Error [RepoWebhook]) webhooksFor' auth owner reqRepoName = githubGet' (Just auth) ["repos", owner, reqRepoName, "hooks"] webhookFor' :: GithubAuth -> RepoOwner -> RepoName -> RepoWebhookId -> IO (Either Error RepoWebhook) webhookFor' auth owner reqRepoName webhookId = githubGet' (Just auth) ["repos", owner, reqRepoName, "hooks", (show webhookId)] createRepoWebhook' :: GithubAuth -> RepoOwner -> RepoName -> NewRepoWebhook -> IO (Either Error RepoWebhook) createRepoWebhook' auth owner reqRepoName = githubPost auth ["repos", owner, reqRepoName, "hooks"] editRepoWebhook' :: GithubAuth -> RepoOwner -> RepoName -> RepoWebhookId -> EditRepoWebhook -> IO (Either Error RepoWebhook) editRepoWebhook' auth owner reqRepoName webhookId edit = githubPatch auth ["repos", owner, reqRepoName, "hooks", (show webhookId)] edit testPushRepoWebhook' :: GithubAuth -> RepoOwner -> RepoName -> RepoWebhookId -> IO (Either Error Status) testPushRepoWebhook' auth owner reqRepoName webhookId = doHttpsStatus "POST" (createWebhookOpUrl owner reqRepoName webhookId (Just "tests")) auth (Just . RequestBodyLBS . encode $ (decode "{}" :: Maybe (M.Map String Int))) pingRepoWebhook' :: GithubAuth -> RepoOwner -> RepoName -> RepoWebhookId -> IO (Either Error Status) pingRepoWebhook' auth owner reqRepoName webhookId = doHttpsStatus "POST" (createWebhookOpUrl owner reqRepoName webhookId (Just "pings")) auth Nothing deleteRepoWebhook' :: GithubAuth -> RepoOwner -> RepoName -> RepoWebhookId -> IO (Either Error Status) deleteRepoWebhook' auth owner reqRepoName webhookId = doHttpsStatus "DELETE" (createWebhookOpUrl owner reqRepoName webhookId Nothing) auth Nothing createBaseWebhookUrl :: RepoOwner -> RepoName -> RepoWebhookId -> String createBaseWebhookUrl owner reqRepoName webhookId = "https://api.github.com/repos/" ++ owner ++ "/" ++ reqRepoName ++ "/hooks/" ++ (show webhookId) createWebhookOpUrl :: RepoOwner -> RepoName -> RepoWebhookId -> Maybe String -> String createWebhookOpUrl owner reqRepoName webhookId Nothing = createBaseWebhookUrl owner reqRepoName webhookId createWebhookOpUrl owner reqRepoName webhookId (Just operation) = createBaseWebhookUrl owner reqRepoName webhookId ++ "/" ++ operation github-0.13.2/Github/Repos/Webhooks/0000755000000000000000000000000012517241563015346 5ustar0000000000000000github-0.13.2/Github/Repos/Webhooks/Validate.hs0000644000000000000000000000220612517241563017433 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} -- | Verification of incomming webhook payloads, as described at -- module Github.Repos.Webhooks.Validate ( isValidPayload ) where import Control.Applicative import Crypto.Hash import qualified Data.ByteString.Char8 as BS import Data.Byteable (constEqBytes, toBytes) import qualified Data.ByteString.Base16 as Hex import Data.Monoid -- | Validates a given payload against a given HMAC hexdigest using a given -- secret. -- Returns 'True' iff the given hash is non-empty and it's a valid signature of -- the payload. isValidPayload :: String -- ^ the secret -> Maybe String -- ^ the hash provided by the remote party -- in @X-Hub-Signature@ (if any), -- including the 'sha1=...' prefix -> BS.ByteString -- ^ the body -> Bool isValidPayload secret shaOpt payload = maybe False (constEqBytes sign) shaOptBS where shaOptBS = BS.pack <$> shaOpt hexDigest = Hex.encode . toBytes . hmacGetDigest hm = hmac (BS.pack secret) payload :: HMAC SHA1 sign = "sha1=" <> hexDigest hm github-0.13.2/Github/Users/0000755000000000000000000000000012517241563013576 5ustar0000000000000000github-0.13.2/Github/Users/Followers.hs0000644000000000000000000000122512517241563016106 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.13.2/samples/0000755000000000000000000000000012517241563012717 5ustar0000000000000000github-0.13.2/samples/Gists/0000755000000000000000000000000012517241563014010 5ustar0000000000000000github-0.13.2/samples/Gists/ListGists.hs0000644000000000000000000000071612517241563016275 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.13.2/samples/Gists/ShowGist.hs0000644000000000000000000000120212517241563016106 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.13.2/samples/Gists/Comments/0000755000000000000000000000000012517241563015575 5ustar0000000000000000github-0.13.2/samples/Gists/Comments/ShowComment.hs0000644000000000000000000000101712517241563020373 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.13.2/samples/Gists/Comments/ShowComments.hs0000644000000000000000000000112112517241563020552 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.13.2/samples/GitData/0000755000000000000000000000000012517241563014234 5ustar0000000000000000github-0.13.2/samples/GitData/Commits/0000755000000000000000000000000012517241563015647 5ustar0000000000000000github-0.13.2/samples/GitData/Commits/GitShow.hs0000644000000000000000000000152112517241563017566 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.13.2/samples/GitData/References/0000755000000000000000000000000012517241563016315 5ustar0000000000000000github-0.13.2/samples/GitData/References/GitCreateReference.hs0000644000000000000000000000124212517241563022336 0ustar0000000000000000module GitCreateRef where import qualified Github.Auth as Auth import Github.GitData.References main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" newlyCreatedGitRef <- createReference auth "myrepo" "myowner" NewGitReference { newGitReferenceRef = "refs/heads/fav_tag" ,newGitReferenceSha = "aa218f56b14c9653891f9e74264a383fa43fefbd" } case newlyCreatedGitRef of (Left err) -> putStrLn $ "Error: " ++ show err (Right newRef) -> putStrLn . formatReference $ newRef formatReference :: GitReference -> String formatReference ref = (gitObjectSha $ gitReferenceObject ref) ++ "\t" ++ (gitReferenceRef ref) github-0.13.2/samples/GitData/References/GitLsRemote.hs0000644000000000000000000000110712517241563021046 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.13.2/samples/GitData/References/GitLsRemoteTags.hs0000644000000000000000000000114312517241563021665 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.13.2/samples/GitData/References/GitLsRemoteWithRef.hs0000644000000000000000000000066512517241563022347 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.13.2/samples/GitData/Trees/0000755000000000000000000000000012517241563015316 5ustar0000000000000000github-0.13.2/samples/GitData/Trees/GitLsTree.hs0000644000000000000000000000114612517241563017516 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.13.2/samples/GitData/Trees/GitLsTreeRecursively.hs0000644000000000000000000000116712517241563021756 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.13.2/samples/Issues/0000755000000000000000000000000012517241563014172 5ustar0000000000000000github-0.13.2/samples/Issues/ShowIssue.hs0000644000000000000000000000110012517241563016447 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.13.2/samples/Issues/ShowRepoIssues.hs0000644000000000000000000000142112517241563017466 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.13.2/samples/Issues/Comments/0000755000000000000000000000000012517241563015757 5ustar0000000000000000github-0.13.2/samples/Issues/Comments/ShowComment.hs0000644000000000000000000000077412517241563020566 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.13.2/samples/Issues/Comments/ShowComments.hs0000644000000000000000000000112412517241563020737 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.13.2/samples/Issues/Events/0000755000000000000000000000000012517241563015436 5ustar0000000000000000github-0.13.2/samples/Issues/Events/ShowEvent.hs0000644000000000000000000000316312517241563017717 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.13.2/samples/Issues/Events/ShowIssueEvents.hs0000644000000000000000000000323312517241563021111 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.13.2/samples/Issues/Events/ShowRepoEvents.hs0000644000000000000000000000336712517241563020736 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.13.2/samples/Issues/Labels/0000755000000000000000000000000012517241563015374 5ustar0000000000000000github-0.13.2/samples/Issues/Labels/ShowIssueLabels.hs0000644000000000000000000000071012517241563021002 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.13.2/samples/Issues/Labels/ShowLabel.hs0000644000000000000000000000056712517241563017620 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.13.2/samples/Issues/Labels/ShowMilestoneLabels.hs0000644000000000000000000000071712517241563021660 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.13.2/samples/Issues/Labels/ShowRepoLabels.hs0000644000000000000000000000070212517241563020620 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.13.2/samples/Issues/Milestones/0000755000000000000000000000000012517241563016314 5ustar0000000000000000github-0.13.2/samples/Issues/Milestones/ShowMilestone.hs0000644000000000000000000000157612517241563021461 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.13.2/samples/Issues/Milestones/ShowMilestones.hs0000644000000000000000000000163312517241563021636 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.13.2/samples/Organizations/0000755000000000000000000000000012517241563015546 5ustar0000000000000000github-0.13.2/samples/Organizations/ShowPublicOrganization.hs0000644000000000000000000000106512517241563022550 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.13.2/samples/Organizations/ShowPublicOrganizations.hs0000644000000000000000000000070412517241563022732 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.13.2/samples/Organizations/Members/0000755000000000000000000000000012517241563017140 5ustar0000000000000000github-0.13.2/samples/Organizations/Members/ShowMembers.hs0000644000000000000000000000055312517241563021732 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.13.2/samples/Pulls/0000755000000000000000000000000012517241563014016 5ustar0000000000000000github-0.13.2/samples/Pulls/Diff.hs0000644000000000000000000000065712517241563015232 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.13.2/samples/Pulls/ListPulls.hs0000644000000000000000000000157012517241563016310 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.13.2/samples/Pulls/ShowCommits.hs0000644000000000000000000000141012517241563016622 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.13.2/samples/Pulls/ShowPull.hs0000644000000000000000000000175212517241563016134 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.13.2/samples/Pulls/ReviewComments/0000755000000000000000000000000012517241563016765 5ustar0000000000000000github-0.13.2/samples/Pulls/ReviewComments/ListComments.hs0000644000000000000000000000152312517241563021743 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.13.2/samples/Pulls/ReviewComments/ShowComment.hs0000644000000000000000000000147112517241563021567 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.13.2/samples/Repos/0000755000000000000000000000000012517241563014007 5ustar0000000000000000github-0.13.2/samples/Repos/ListBranches.hs0000644000000000000000000000053112517241563016723 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.13.2/samples/Repos/ListContributors.hs0000644000000000000000000000112112517241563017667 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.13.2/samples/Repos/ListContributorsWithAnonymous.hs0000644000000000000000000000115312517241563022441 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.13.2/samples/Repos/ListLanguages.hs0000644000000000000000000000067112517241563017111 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.13.2/samples/Repos/ListOrgRepos.hs0000644000000000000000000000166412517241563016746 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" ++ (fromMaybe "" $ 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 (Just date) = show . Github.fromGithubDate $ date formatDate Nothing = "????" formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.13.2/samples/Repos/ListTags.hs0000644000000000000000000000047612517241563016104 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.13.2/samples/Repos/ListUserRepos.hs0000644000000000000000000000166612517241563017137 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" ++ (fromMaybe "" $ 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 (Just date) = show . Github.fromGithubDate $ date formatDate Nothing = "" formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.13.2/samples/Repos/ShowRepo.hs0000644000000000000000000000152712517241563016116 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.13.2/samples/Repos/Collaborators/0000755000000000000000000000000012517241563016615 5ustar0000000000000000github-0.13.2/samples/Repos/Collaborators/IsCollaborator.hs0000644000000000000000000000077712517241563022103 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.13.2/samples/Repos/Collaborators/ListCollaborators.hs0000644000000000000000000000101012517241563022603 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.13.2/samples/Repos/Commits/0000755000000000000000000000000012517241563015422 5ustar0000000000000000github-0.13.2/samples/Repos/Commits/CommitComment.hs0000644000000000000000000000141612517241563020533 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.13.2/samples/Repos/Commits/CommitComments.hs0000644000000000000000000000154112517241563020715 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.13.2/samples/Repos/Commits/GitDiff.hs0000644000000000000000000000061612517241563017275 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.13.2/samples/Repos/Commits/GitLog.hs0000644000000000000000000000152612517241563017147 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.13.2/samples/Repos/Commits/GitShow.hs0000644000000000000000000000173212517241563017345 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.13.2/samples/Repos/Commits/RepoComments.hs0000644000000000000000000000145612517241563020377 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.13.2/samples/Repos/Forks/0000755000000000000000000000000012517241563015073 5ustar0000000000000000github-0.13.2/samples/Repos/Forks/ListForks.hs0000644000000000000000000000123112517241563017344 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" ++ (formatCloneUrl $ Github.repoCloneUrl fork) formatPushedAt Nothing = "" formatPushedAt (Just pushedAt) = show $ Github.fromGithubDate pushedAt formatCloneUrl Nothing = "" formatCloneUrl (Just cloneUrl) = cloneUrl github-0.13.2/samples/Repos/Starring/0000755000000000000000000000000012517241563015600 5ustar0000000000000000github-0.13.2/samples/Repos/Starring/ListStarred.hs0000644000000000000000000000151012517241563020371 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" ++ (fromMaybe "" $ Github.repoCloneUrl repo) ++ "\t" ++ (formatDate $ Github.repoUpdatedAt repo) ++ "\n" ++ formatLanguage (Github.repoLanguage repo) formatDate (Just date) = show . Github.fromGithubDate $ date formatDate Nothing = "" formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.13.2/samples/Repos/Watching/0000755000000000000000000000000012517241563015553 5ustar0000000000000000github-0.13.2/samples/Repos/Watching/ListWatched.hs0000644000000000000000000000166412517241563020331 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" ++ (fromMaybe "" $ 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 (Just date) = show . Github.fromGithubDate $ date formatDate Nothing = "" formatLanguage (Just language) = "language: " ++ language ++ "\t" formatLanguage Nothing = "" github-0.13.2/samples/Repos/Watching/ListWatchers.hs0000644000000000000000000000073112517241563020524 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.13.2/samples/Repos/Webhooks/0000755000000000000000000000000012517241563015570 5ustar0000000000000000github-0.13.2/samples/Repos/Webhooks/CreateWebhook.hs0000644000000000000000000000155712517241563020656 0ustar0000000000000000module CreateWebhook where import Github.Repos.Webhooks import qualified Github.Auth as Auth import Github.Data.Definitions import qualified Data.Map as M main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" let config = M.fromList [("url", "https://foo3.io"), ("content_type", "application/json"), ("insecure_ssl", "1")] let webhookDef = NewRepoWebhook { newRepoWebhookName = "web", newRepoWebhookConfig = config, newRepoWebhookEvents = Just [WebhookWildcardEvent], newRepoWebhookActive = Just True } newWebhook <- createRepoWebhook' auth "repoOwner" "repoName" webhookDef case newWebhook of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right webhook) -> putStrLn $ formatRepoWebhook webhook formatRepoWebhook :: RepoWebhook -> String formatRepoWebhook (RepoWebhook _ _ _ name _ _ _ _ _ _) = show name github-0.13.2/samples/Repos/Webhooks/DeleteWebhook.hs0000644000000000000000000000053212517241563020645 0ustar0000000000000000module DeleteWebhook where import Github.Repos.Webhooks import qualified Github.Auth as Auth main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" resp <- deleteRepoWebhook' auth "repoOwner" "repoName" 123 case resp of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right stat) -> putStrLn $ "Resp: " ++ (show stat) github-0.13.2/samples/Repos/Webhooks/EditWebhook.hs0000644000000000000000000000151512517241563020332 0ustar0000000000000000module EditWebhook where import Github.Repos.Webhooks import qualified Github.Auth as Auth import Github.Data.Definitions main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" let editWebhookDef = EditRepoWebhook { editRepoWebhookRemoveEvents = Just [WebhookWildcardEvent], editRepoWebhookAddEvents = Just [WebhookCommitCommentEvent, WebhookGollumEvent], editRepoWebhookConfig = Nothing, editRepoWebhookEvents = Nothing, editRepoWebhookActive = Just True } newWebhook <- editRepoWebhook' auth "repoOwner" "repoName" 123 editWebhookDef case newWebhook of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right webhook) -> putStrLn $ formatRepoWebhook webhook formatRepoWebhook :: RepoWebhook -> String formatRepoWebhook (RepoWebhook _ _ _ name _ _ _ _ _ _) = show name github-0.13.2/samples/Repos/Webhooks/ListWebhook.hs0000644000000000000000000000104412517241563020355 0ustar0000000000000000module ListWebhook where import qualified Github.Repos.Webhooks as W import qualified Github.Auth as Auth import qualified Github.Data.Definitions as Def main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" possibleWebhook <- W.webhookFor' auth "repoOwner" "repoName" 123 case possibleWebhook of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right webhook) -> putStrLn $ formatRepoWebhook webhook formatRepoWebhook :: Def.RepoWebhook -> String formatRepoWebhook (Def.RepoWebhook _ _ _ name _ _ _ _ _ _) = show name github-0.13.2/samples/Repos/Webhooks/ListWebhooks.hs0000644000000000000000000000111612517241563020540 0ustar0000000000000000module ListWebhooks where import qualified Github.Repos.Webhooks as W import qualified Github.Auth as Auth import qualified Github.Data.Definitions as Def import Data.List main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" possibleWebhooks <- W.webhooksFor' auth "repoOwner" "repoName" case possibleWebhooks of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right webhooks) -> putStrLn $ intercalate "\n" $ map formatRepoWebhook webhooks formatRepoWebhook :: Def.RepoWebhook -> String formatRepoWebhook (Def.RepoWebhook _ _ _ name _ _ _ _ _ _) = show name github-0.13.2/samples/Repos/Webhooks/PingWebhook.hs0000644000000000000000000000052612517241563020343 0ustar0000000000000000module PingWebhook where import Github.Repos.Webhooks import qualified Github.Auth as Auth main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" resp <- pingRepoWebhook' auth "repoOwner" "repoName" 123 case resp of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right stat) -> putStrLn $ "Resp: " ++ (show stat) github-0.13.2/samples/Repos/Webhooks/TestPushWebhook.hs0000644000000000000000000000053612517241563021226 0ustar0000000000000000module TestPushWebhook where import Github.Repos.Webhooks import qualified Github.Auth as Auth main :: IO () main = do let auth = Auth.GithubOAuth "oauthtoken" resp <- testPushRepoWebhook' auth "repoOwner" "repoName" 123 case resp of (Left err) -> putStrLn $ "Error: " ++ (show err) (Right stat) -> putStrLn $ "Resp: " ++ (show stat) github-0.13.2/samples/Search/0000755000000000000000000000000012517241563014124 5ustar0000000000000000github-0.13.2/samples/Search/SearchRepos.hs0000644000000000000000000000371412517241563016703 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", formatMaybeDate . 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.13.2/samples/Users/0000755000000000000000000000000012517241563014020 5ustar0000000000000000github-0.13.2/samples/Users/ShowUser.hs0000644000000000000000000000365212517241563016141 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" ++ "<" ++ (fromMaybe "" email) ++ ">" ++ "\n" ++ htmlUrl ++ "\t" ++ (formatDate createdAt) ++ "\n" ++ "hireable: " ++ (formatHireable (fromMaybe False 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.13.2/samples/Users/Followers/0000755000000000000000000000000012517241563015774 5ustar0000000000000000github-0.13.2/samples/Users/Followers/ListFollowers.hs0000644000000000000000000000053112517241563021137 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.13.2/samples/Users/Followers/ListFollowing.hs0000644000000000000000000000053312517241563021125 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 github-0.13.2/spec/0000755000000000000000000000000012517241563012205 5ustar0000000000000000github-0.13.2/spec/Spec.hs0000644000000000000000000000005412517241563013432 0ustar0000000000000000{-# OPTIONS_GHC -F -pgmF hspec-discover #-}