diff --git a/src/github/Repository.py b/src/github/Repository.py index 253aa973..6d6440e7 100644 --- a/src/github/Repository.py +++ b/src/github/Repository.py @@ -261,7 +261,7 @@ class Repository( object ): } status, headers, data = self.__requester.request( "POST", - str( self.url ) + "/git", + str( self.url ) + "/git/refs", None, post_parameters ) diff --git a/test/Framework/__init__.py b/test/Framework/__init__.py index 89d46019..f6c89b96 100644 --- a/test/Framework/__init__.py +++ b/test/Framework/__init__.py @@ -27,7 +27,7 @@ class RecordingHttpsConnection: self.__cnx = self.__realHttpsConnection( *args, **kwds ) def request( self, verb, url, input, headers ): - print verb, url + print verb, url, self.__cnx.request( verb, url, input, headers ) del headers[ "Authorization" ] # Do not let sensitive info in git :-p self.__file.write( verb + " " + url + " " + str( headers ) + " " + input + "\n" ) @@ -36,6 +36,7 @@ class RecordingHttpsConnection: res = self.__cnx.getresponse() status = res.status + print "=>", status headers = res.getheaders() output = res.read() diff --git a/test/GitObjects.py b/test/GitObjects.py index 97f42df3..e4c9e4a9 100644 --- a/test/GitObjects.py +++ b/test/GitObjects.py @@ -65,14 +65,21 @@ class GitCommit( Framework.TestCase ): class GitRef( Framework.TestCase ): def setUp( self ): Framework.TestCase.setUp( self ) - self.r = self.g.get_user().get_repo( "PyGithub" ).get_git_ref( "refs/heads/topic/RewriteWithGeneratedCode" ) + self.repo = self.g.get_user().get_repo( "PyGithub" ) def testAttributes( self ): - self.assertEqual( self.r.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" ) - self.assertEqual( self.r.object.type, "commit" ) - self.assertEqual( self.r.object.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a" ) - self.assertEqual( self.r.ref, "refs/heads/topic/RewriteWithGeneratedCode" ) - self.assertEqual( self.r.url, "https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/topic/RewriteWithGeneratedCode" ) + ref = self.repo.get_git_ref( "refs/heads/topic/RewriteWithGeneratedCode" ) + self.assertEqual( ref.object.sha, "1292bf0e22c796e91cc3d6e24b544aece8c21f2a" ) + self.assertEqual( ref.object.type, "commit" ) + self.assertEqual( ref.object.url, "https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a" ) + self.assertEqual( ref.ref, "refs/heads/topic/RewriteWithGeneratedCode" ) + self.assertEqual( ref.url, "https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/topic/RewriteWithGeneratedCode" ) + + def testCreateEditDelete( self ): + ref = self.repo.create_git_ref( "refs/heads/BranchCreatedByPyGithub", "4303c5b90e2216d927155e9609436ccb8984c495" ) + ref.edit( "04cde900a0775b51f762735637bd30de392a2793" ) + ref.edit( "4303c5b90e2216d927155e9609436ccb8984c495", force = True ) + ref.delete() class GitTag( Framework.TestCase ): def setUp( self ): diff --git a/test/ReplayData/GitRef.setUp.txt b/test/ReplayData/GitRef.setUp.txt index be0210c9..c487f040 100644 --- a/test/ReplayData/GitRef.setUp.txt +++ b/test/ReplayData/GitRef.setUp.txt @@ -1,15 +1,10 @@ -GET /user {} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"b945f11dd3b44dd11184918914b87c02"'), ('date', 'Thu, 10 May 2012 14:37:56 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"private_gists":5,"type":"User","url":"https://api.github.com/users/jacquev6","owned_private_repos":5,"disk_usage":16776,"plan":{"private_repos":5,"collaborators":1,"space":614400,"name":"micro"},"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jacquev6","collaborators":0,"email":"vincent@vincent-jacques.net","html_url":"https://github.com/jacquev6","created_at":"2010-07-09T06:10:06Z","company":"Criteo","location":"Paris, France","hireable":false,"public_repos":10,"followers":13,"following":24,"name":"Vincent Jacques","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","public_gists":1,"bio":"","id":327146,"total_private_repos":5,"blog":"http://vincent-jacques.net"} - -GET /repos/jacquev6/PyGithub {} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"044706cdc7381a70bf368b2afccbdb89"'), ('date', 'Thu, 10 May 2012 14:37:57 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"homepage":"http://vincent-jacques.net/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","has_downloads":true,"watchers":13,"permissions":{"admin":true,"pull":true,"push":true},"has_wiki":false,"has_issues":true,"fork":false,"mirror_url":null,"forks":2,"language":"Python","size":264,"description":"Python library implementing the full Github API v3","html_url":"https://github.com/jacquev6/PyGithub","private":false,"created_at":"2012-02-25T12:53:47Z","open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"name":"PyGithub","pushed_at":"2012-05-09T16:22:47Z","id":3544490,"ssh_url":"git@github.com:jacquev6/PyGithub.git","updated_at":"2012-05-09T16:22:48Z"} - -GET /repos/jacquev6/PyGithub/git/refs/heads/topic/RewriteWithGeneratedCode {} null -200 -[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '336'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"ef55032f07a176e09c65b2ac524c2ecf"'), ('date', 'Thu, 10 May 2012 14:38:00 GMT'), ('content-type', 'application/json; charset=utf-8')] -{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/topic/RewriteWithGeneratedCode","object":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a","type":"commit","sha":"1292bf0e22c796e91cc3d6e24b544aece8c21f2a"},"ref":"refs/heads/topic/RewriteWithGeneratedCode"} - +GET /user {} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4989'), ('content-length', '801'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"fc8367028bd9046f0b52929ea8657756"'), ('date', 'Thu, 10 May 2012 18:49:18 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"type":"User","owned_private_repos":5,"public_repos":10,"html_url":"https://github.com/jacquev6","blog":"http://vincent-jacques.net","collaborators":0,"following":24,"company":"Criteo","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","public_gists":1,"followers":13,"url":"https://api.github.com/users/jacquev6","private_gists":5,"hireable":false,"login":"jacquev6","email":"vincent@vincent-jacques.net","disk_usage":16676,"plan":{"private_repos":5,"collaborators":1,"space":614400,"name":"micro"},"created_at":"2010-07-09T06:10:06Z","name":"Vincent Jacques","bio":"","id":327146,"total_private_repos":5,"location":"Paris, France"} + +GET /repos/jacquev6/PyGithub {} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4988'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"82dfa2c767e249ed2a1703529101f0aa"'), ('date', 'Thu, 10 May 2012 18:49:18 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"homepage":"http://vincent-jacques.net/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","html_url":"https://github.com/jacquev6/PyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub","has_downloads":true,"watchers":13,"permissions":{"admin":true,"pull":true,"push":true},"mirror_url":null,"git_url":"git://github.com/jacquev6/PyGithub.git","has_wiki":false,"has_issues":true,"fork":false,"forks":2,"language":"Python","size":196,"description":"Python library implementing the full Github API v3","private":false,"created_at":"2012-02-25T12:53:47Z","open_issues":15,"svn_url":"https://github.com/jacquev6/PyGithub","owner":{"url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","id":327146},"name":"PyGithub","pushed_at":"2012-05-10T18:14:23Z","id":3544490,"ssh_url":"git@github.com:jacquev6/PyGithub.git","updated_at":"2012-05-10T18:14:23Z"} + diff --git a/test/ReplayData/GitRef.testAttributes.txt b/test/ReplayData/GitRef.testAttributes.txt new file mode 100644 index 00000000..d96ef497 --- /dev/null +++ b/test/ReplayData/GitRef.testAttributes.txt @@ -0,0 +1,5 @@ +GET /repos/jacquev6/PyGithub/git/refs/heads/topic/RewriteWithGeneratedCode {} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('content-length', '336'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"ef55032f07a176e09c65b2ac524c2ecf"'), ('date', 'Thu, 10 May 2012 14:38:00 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/topic/RewriteWithGeneratedCode","object":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a","type":"commit","sha":"1292bf0e22c796e91cc3d6e24b544aece8c21f2a"},"ref":"refs/heads/topic/RewriteWithGeneratedCode"} + diff --git a/test/ReplayData/GitRef.testCreateEditDelete.txt b/test/ReplayData/GitRef.testCreateEditDelete.txt new file mode 100644 index 00000000..d4c5f956 --- /dev/null +++ b/test/ReplayData/GitRef.testCreateEditDelete.txt @@ -0,0 +1,20 @@ +POST /repos/jacquev6/PyGithub/git/refs {} {"sha": "4303c5b90e2216d927155e9609436ccb8984c495", "ref": "refs/heads/BranchCreatedByPyGithub"} +201 +[('status', '201 Created'), ('x-ratelimit-remaining', '4987'), ('content-length', '322'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"0302e489fc6bd534afa44cdbec1227e7"'), ('date', 'Thu, 10 May 2012 18:49:19 GMT'), ('content-type', 'application/json; charset=utf-8'), ('location', 'https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub')] +{"object":{"type":"commit","sha":"4303c5b90e2216d927155e9609436ccb8984c495","url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495"},"ref":"refs/heads/BranchCreatedByPyGithub","url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub"} + +PATCH /repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub {} {"sha": "04cde900a0775b51f762735637bd30de392a2793"} +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('content-length', '322'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"ced480ad69948233f6520f7cd945eb34"'), ('date', 'Thu, 10 May 2012 18:49:20 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub","object":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/04cde900a0775b51f762735637bd30de392a2793","type":"commit","sha":"04cde900a0775b51f762735637bd30de392a2793"},"ref":"refs/heads/BranchCreatedByPyGithub"} + +PATCH /repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub {} {"sha": "4303c5b90e2216d927155e9609436ccb8984c495", "force": true} +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('content-length', '322'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"fb39f29de1defbab14def8a331d00c69"'), ('date', 'Thu, 10 May 2012 18:49:21 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub","object":{"url":"https://api.github.com/repos/jacquev6/PyGithub/git/commits/4303c5b90e2216d927155e9609436ccb8984c495","type":"commit","sha":"4303c5b90e2216d927155e9609436ccb8984c495"},"ref":"refs/heads/BranchCreatedByPyGithub"} + +DELETE /repos/jacquev6/PyGithub/git/refs/heads/BranchCreatedByPyGithub {} null +204 +[('status', '204 No Content'), ('x-ratelimit-remaining', '4984'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"d41d8cd98f00b204e9800998ecf8427e"'), ('date', 'Thu, 10 May 2012 18:49:22 GMT')] + +