mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Repository.get_git_tree (and .create_git_tree, not tested)
This commit is contained in:
+4
-1
@@ -167,7 +167,10 @@ class IntegrationTest:
|
||||
print " Forks:", ", ".join( f.owner.login + "/" + f.name for f in r.get_forks() )
|
||||
print " References:", ", ".join( ref.ref + " (" + ref.object[ "sha" ][ :7 ] + ")" for ref in r.get_git_refs() )
|
||||
masterCommitSha = r.get_git_ref( "refs/heads/master" ).object[ "sha" ]
|
||||
print " Master:", masterCommitSha, r.get_git_commit( masterCommitSha ).message
|
||||
masterCommit = r.get_git_commit( masterCommitSha )
|
||||
masterTreeSha = masterCommit.tree[ "sha" ]
|
||||
masterTree = r.get_git_tree( masterTreeSha )
|
||||
print " Master:", masterCommitSha, masterCommit.message, ", ".join( element[ "path" ] + " (" + element[ "type" ] + ")" for element in masterTree.tree )
|
||||
print
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
+6
-2
@@ -204,11 +204,15 @@ API `/repos/:user/:repo/git/tags/:sha`
|
||||
|
||||
API `/repos/:user/:repo/git/trees`
|
||||
==================================
|
||||
* POST: `Repository.create_git_tree( ... )`: `GitTree` (TODO SOON)
|
||||
* POST: `Repository.create_git_tree( ... )`: `GitTree`
|
||||
|
||||
API `/repos/:user/:repo/git/trees?base_tree=`
|
||||
=============================================
|
||||
* POST: `GitTree.create_update( ... )`: `GitTree` (TODO SOON)
|
||||
|
||||
API `/repos/:user/:repo/git/trees/:sha`
|
||||
=======================================
|
||||
* GET: `Repository.get_git_tree( sha )`: `GitTree` (TODO SOON)
|
||||
* GET: `Repository.get_git_tree( sha )`: `GitTree`
|
||||
|
||||
API `/repos/:user/:repo/git/trees/:sha?recursive=1`
|
||||
===================================================
|
||||
|
||||
@@ -83,6 +83,16 @@ GitCommit = GithubObject(
|
||||
),
|
||||
)
|
||||
|
||||
GitTree = GithubObject(
|
||||
"GitTree",
|
||||
BaseUrl( lambda obj: obj._repo._baseUrl + "/git/trees/" + obj.sha ),
|
||||
BasicAttributes(
|
||||
"sha", "url",
|
||||
"tree", ### @todo Structure
|
||||
"_repo", ### Ugly hack
|
||||
),
|
||||
)
|
||||
|
||||
__modifyAttributesForGitObjects = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
|
||||
Repository = GithubObject(
|
||||
"Repository",
|
||||
@@ -111,6 +121,10 @@ Repository = GithubObject(
|
||||
ElementGetable( "git_commit", lambda repo, sha: { "_repo": repo, "sha": sha } ),
|
||||
ElementCreatable( "git_commit", [ "message", "tree", "parents" ], [ "author", "commiter" ], __modifyAttributesForGitObjects )
|
||||
),
|
||||
ListAttribute( "git/trees", GitTree,
|
||||
ElementGetable( "git_tree", lambda repo, sha: { "_repo": repo, "sha": sha } ),
|
||||
ElementCreatable( "git_tree", [ "tree" ], [], __modifyAttributesForGitObjects )
|
||||
),
|
||||
)
|
||||
Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) )
|
||||
Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) )
|
||||
|
||||
Reference in New Issue
Block a user