From 9ed8e2f804725532754457570d3d6197cf7ef74c Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 12 Feb 2012 21:28:12 +0100 Subject: [PATCH] Repository.get_collaborators, .get_contributors, .get_watchers, .get_forks --- IntegrationTest.py | 8 ++++++++ Reference.md | 8 ++++---- github/GithubObjects.py | 6 ++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/IntegrationTest.py b/IntegrationTest.py index b31240d2..2214973a 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -26,7 +26,15 @@ def dumpOrganization( o ): print " Repos:", ", ".join( r.name for r in o.get_repos() ) print +def dumpRepository( r ): + print r.owner.login + "/" + r.name + print " Collaborators:", ", ".join( u.login for u in r.get_collaborators() ) + print " Contributors:", ", ".join( u.login for u in r.get_contributors() ) + print " Watchers:", ", ".join( u.login for u in r.get_watchers() ) + print " Forks:", ", ".join( f.owner.login + "/" + f.name for f in r.get_forks() ) + dumpUser( g.get_user() ) dumpUser( g.get_user( "nvie" ) ) dumpOrganization( g.get_organization( "github" ) ) dumpOrganization( g.get_organization( "BeaverSoftware" ) ) +dumpRepository( g.get_user( "nvie" ).get_repos()[ 0 ] ) diff --git a/Reference.md b/Reference.md index d6913cdf..7ed609e2 100644 --- a/Reference.md +++ b/Reference.md @@ -110,7 +110,7 @@ /repos/:user/:repo/collaborators ================================ - - GET: `` (TODO) + - GET: `Repository.get_collaborators()`: list of `NamedUser` /repos/:user/:repo/collaborators/:user ====================================== @@ -147,7 +147,7 @@ /repos/:user/:repo/contributors =============================== - - GET: `` (TODO) + - GET: `Repository.get_contributors`: list of `NamedUser` /repos/:user/:repo/downloads ============================ @@ -165,7 +165,7 @@ /repos/:user/:repo/forks ======================== - - GET: `` (TODO) + - GET: `Repository.get_forks()`: list of `Repository` - POST: `` (TODO) /repos/:user/:repo/git/blobs @@ -358,7 +358,7 @@ /repos/:user/:repo/watchers =========================== - - GET: `` (TODO) + - GET: `Repository.get_watchers()`: list of `NamedUser` /teams/:id ========== diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 991ef29e..fdb51abb 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -20,6 +20,8 @@ NamedUser = GithubObject( "blog", "location", "email", "hireable", "bio", "public_repos", "public_gists", "followers", "following", "html_url", "created_at", "type", + # Only in Repository.get_contributors() + "contributions", ), ) @@ -60,9 +62,13 @@ Repository = GithubObject( "mirror_url", "updated_at", "id", ), ExtendedScalarAttribute( "owner", NamedUser ), + ExtendedListAttribute( "collaborators", NamedUser ), + ExtendedListAttribute( "contributors", NamedUser ), + ExtendedListAttribute( "watchers", NamedUser ), ) Repository._addAttributePolicy( ExtendedScalarAttribute( "parent", Repository ) ) Repository._addAttributePolicy( ExtendedScalarAttribute( "source", Repository ) ) +Repository._addAttributePolicy( ExtendedListAttribute( "forks", Repository ) ) AuthenticatedUser._addAttributePolicy( ExtendedListAttribute( "repos", Repository ) ) NamedUser._addAttributePolicy( ExtendedListAttribute( "repos", Repository ) )