{"action":"closed","issue":{"url":"https://api.github.com/repos/google/go-github/issues/162","labels_url":"https://api.github.com/repos/google/go-github/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/google/go-github/issues/162/comments","events_url":"https://api.github.com/repos/google/go-github/issues/162/events","html_url":"https://github.com/google/go-github/issues/162","id":54631683,"number":162,"title":"CreateCommit takes incorrect Tree type","user":{"login":"ImJasonH","id":210737,"avatar_url":"https://avatars.githubusercontent.com/u/210737?v=3","gravatar_id":"","url":"https://api.github.com/users/ImJasonH","html_url":"https://github.com/ImJasonH","followers_url":"https://api.github.com/users/ImJasonH/followers","following_url":"https://api.github.com/users/ImJasonH/following{/other_user}","gists_url":"https://api.github.com/users/ImJasonH/gists{/gist_id}","starred_url":"https://api.github.com/users/ImJasonH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ImJasonH/subscriptions","organizations_url":"https://api.github.com/users/ImJasonH/orgs","repos_url":"https://api.github.com/users/ImJasonH/repos","events_url":"https://api.github.com/users/ImJasonH/events{/privacy}","received_events_url":"https://api.github.com/users/ImJasonH/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-16T22:14:55Z","updated_at":"2015-01-16T22:46:03Z","closed_at":"2015-01-16T22:46:03Z","body":"https://developer.github.com/v3/git/commits/#create-a-commit\r\n\r\nThe JSON body takes a tree's SHA as a string, and returns a commit including the tree's URL and SHA (i.e., mapping to the [`Tree`](http://godoc.org/github.com/google/go-github/github#Tree) struct)\r\n\r\nThe go-github method takes a `Commit` and returns a `Commit`, which defines the Tree\r\nContrast with the code in [git_commits.go](https://github.com/google/go-github/blob/845773f8647cad81ce430e0b903e8818d356e317/github/git_commits.go#L76), where `CreateCommit` takes a `Commit` and returns a `Commit`.\r\n\r\nAttempting to use the method as-is and passing a tree.SHA results in a request like\r\n```\r\n{\r\n  \"message\": \"...\",\r\n  \"tree\": {\r\n    \"sha\": \"...\"\r\n  }\r\n}\r\n```\r\nwhen it should be\r\n```\r\n{\r\n  \"message\": \"...\",\r\n  \"tree\": \"...\"\r\n}\r\n```\r\nGitHub rejects the request with the message\r\n```\r\n{\r\n  \"message\": \"Invalid request.\\n\\nExpected data to be of type \\\"string\\\"; value was: {\\\"sha\\\"=>\\\"...\\\"}.\",\r\n  \"documentation_url\": \"https://developer.github.com/v3/git/commits/#create-a-commit\"\r\n}\r\n```\r\n\r\nThe method should take a struct that has a string field `Tree` instead of the `Tree`-typed field.\r\n\r\nA similar issue affects the CreateRef method, which takes a `Commit` and returns a `Commit`, where GitHub expects the request type to include a string `SHA` field instead of an `Object` with an inner `SHA` field."}}