Closed aronlindberg closed 9 years ago
If this is an entry point that was added less than a year ago, then you’re right, rgithub does not support it.
But it looks like the entry point looks very much like all other entry points, so it should take only 3-10 new lines of code to support it.
pull requests welcome!
I'm new at this, but would to attempt to contribute. Looking at https://developer.github.com/v3/git/commits/#get-a-commit and https://developer.github.com/v3/git/trees/#get-a-tree it seems that the API calls for getting trees and commits have a similar structure:
GET /repos/:owner/:repo/git/commits/:sha
GET /repos/:owner/:repo/git/trees/:sha
My assumption is then that writing a function to get a tree could be modeled on what we already have for getting a commit, i.e.:
get.commit <- function(owner, repo, sha, ctx = get.github.context())
.api.get.request(ctx, c("repos", owner, repo, "git", "commits", sha))
So, may be something like this:
get.tree <- function(owner, repo, sha, ctx = get.github.context())
.api.get.request(ctx, c("repos", owner, repo, "git", "trees", sha))
@cscheid: am I completely out of depth here, or does this make sense?
However, running e.g.
get.tree <- function(owner, repo, sha, ctx = get.github.context())
+ .api.get.request(ctx, c("repos", owner, repo, "git", "trees", sha))
and then
get.tree(owner = "rails", repo = "rails", sha = "6bd777c85156aca0cf2d1f34d8c1fe37d96ac3d9", ctx = get.github.context())
generates a similar error as when trying to get all the commits on a pull request, meaning:
Error in .cached.api.request(ctx, req, .without.body(GET), expect.code, :
could not find function ".api.request"
and https://github.com/cscheid/rgithub/blob/master/R/github.R is pretty much Greek to me. Any pointers on what I need to understand in order to understand what's in that file (where e.g. .api.request
resides)
I'm going to add a trees.R
set of entry points in the near future.
EDIT: Wait! We already have get.tree
on data.R
:
get.tree <- function(owner, repo, sha, ..., ctx = get.github.context())
.api.get.request(ctx, c("repos", owner, repo, "git", "trees", sha), params=list(...))
Any reason it doesn't work for you? (.api.request
is not an exported symbol and can only be used inside the library, which is why your function doesn't work)
... yeah, this just works out-of-the-box.
> library(github)
> get.tree(owner = "rails", repo = "rails", sha = "6bd777c85156aca0cf2d1f34d8c1fe37d96ac3d9")
$ok
[1] TRUE
$content
$content$sha
[1] "6bd777c85156aca0cf2d1f34d8c1fe37d96ac3d9"
$content$url
[1] "https://api.github.com/repos/rails/rails/git/trees/6bd777c85156aca0cf2d1f34d8c1fe37d96ac3d9"
$content$tree
$content$tree[[1]]
$content$tree[[1]]$path
[1] ".gitignore"
$content$tree[[1]]$mode
[1] "100644"
$content$tree[[1]]$type
[1] "blob"
$content$tree[[1]]$sha
[1] "bc96284375bd0c48781c96b45d81d87068e7d5e5"
$content$tree[[1]]$size
[1] 508
$content$tree[[1]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/bc96284375bd0c48781c96b45d81d87068e7d5e5"
$content$tree[[2]]
$content$tree[[2]]$path
[1] ".travis.yml"
$content$tree[[2]]$mode
[1] "100644"
$content$tree[[2]]$type
[1] "blob"
$content$tree[[2]]$sha
[1] "b38cb0032bded89838a9f540eb13293947ea1377"
$content$tree[[2]]$size
[1] 1150
$content$tree[[2]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/b38cb0032bded89838a9f540eb13293947ea1377"
$content$tree[[3]]
$content$tree[[3]]$path
[1] ".yardopts"
$content$tree[[3]]$mode
[1] "100644"
$content$tree[[3]]$type
[1] "blob"
$content$tree[[3]]$sha
[1] "25ec38658f55c94e9b917b5418c90137be81fbef"
$content$tree[[3]]$size
[1] 68
$content$tree[[3]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/25ec38658f55c94e9b917b5418c90137be81fbef"
$content$tree[[4]]
$content$tree[[4]]$path
[1] "CONTRIBUTING.md"
$content$tree[[4]]$mode
[1] "100644"
$content$tree[[4]]$type
[1] "blob"
$content$tree[[4]]$sha
[1] "421e7088cbfd38553fb8302292fa0d45fded7f37"
$content$tree[[4]]$size
[1] 1197
$content$tree[[4]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/421e7088cbfd38553fb8302292fa0d45fded7f37"
$content$tree[[5]]
$content$tree[[5]]$path
[1] "Gemfile"
$content$tree[[5]]$mode
[1] "100644"
$content$tree[[5]]$type
[1] "blob"
$content$tree[[5]]$sha
[1] "08aa842d2fb9516bff5beac534c7b18b623a4a03"
$content$tree[[5]]$size
[1] 3453
$content$tree[[5]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/08aa842d2fb9516bff5beac534c7b18b623a4a03"
$content$tree[[6]]
$content$tree[[6]]$path
[1] "RAILS_VERSION"
$content$tree[[6]]$mode
[1] "100644"
$content$tree[[6]]$type
[1] "blob"
$content$tree[[6]]$sha
[1] "2b915d7d5c7c8144dab8ea6352508685996645b5"
$content$tree[[6]]$size
[1] 12
$content$tree[[6]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/2b915d7d5c7c8144dab8ea6352508685996645b5"
$content$tree[[7]]
$content$tree[[7]]$path
[1] "README.md"
$content$tree[[7]]$mode
[1] "100644"
$content$tree[[7]]$type
[1] "blob"
$content$tree[[7]]$sha
[1] "bbe3a6731d966ad358b626fdca440c46dec2057e"
$content$tree[[7]]$size
[1] 4196
$content$tree[[7]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/bbe3a6731d966ad358b626fdca440c46dec2057e"
$content$tree[[8]]
$content$tree[[8]]$path
[1] "RELEASING_RAILS.rdoc"
$content$tree[[8]]$mode
[1] "100644"
$content$tree[[8]]$type
[1] "blob"
$content$tree[[8]]$sha
[1] "0e09234b82e47f59bc2a6368cd9342d7d9bceecd"
$content$tree[[8]]$size
[1] 6678
$content$tree[[8]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/0e09234b82e47f59bc2a6368cd9342d7d9bceecd"
$content$tree[[9]]
$content$tree[[9]]$path
[1] "Rakefile"
$content$tree[[9]]$mode
[1] "100644"
$content$tree[[9]]$type
[1] "blob"
$content$tree[[9]]$sha
[1] "db27105cc384fdcb01b7bf3d4f36df4191b8a464"
$content$tree[[9]]$size
[1] 1988
$content$tree[[9]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/db27105cc384fdcb01b7bf3d4f36df4191b8a464"
$content$tree[[10]]
$content$tree[[10]]$path
[1] "actionmailer"
$content$tree[[10]]$mode
[1] "040000"
$content$tree[[10]]$type
[1] "tree"
$content$tree[[10]]$sha
[1] "733a81118e7d3de61fb6c3eb0df9ee272db7e49f"
$content$tree[[10]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/733a81118e7d3de61fb6c3eb0df9ee272db7e49f"
$content$tree[[11]]
$content$tree[[11]]$path
[1] "actionpack"
$content$tree[[11]]$mode
[1] "040000"
$content$tree[[11]]$type
[1] "tree"
$content$tree[[11]]$sha
[1] "99673104a437d5e976d6b3cd9a799300821136a2"
$content$tree[[11]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/99673104a437d5e976d6b3cd9a799300821136a2"
$content$tree[[12]]
$content$tree[[12]]$path
[1] "actionview"
$content$tree[[12]]$mode
[1] "040000"
$content$tree[[12]]$type
[1] "tree"
$content$tree[[12]]$sha
[1] "b6edaa5756a4f914b51a8bb2c8727c5618e52899"
$content$tree[[12]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/b6edaa5756a4f914b51a8bb2c8727c5618e52899"
$content$tree[[13]]
$content$tree[[13]]$path
[1] "activejob"
$content$tree[[13]]$mode
[1] "040000"
$content$tree[[13]]$type
[1] "tree"
$content$tree[[13]]$sha
[1] "caf4125f0caa2c52249a31a0d90bd833bd47306d"
$content$tree[[13]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/caf4125f0caa2c52249a31a0d90bd833bd47306d"
$content$tree[[14]]
$content$tree[[14]]$path
[1] "activemodel"
$content$tree[[14]]$mode
[1] "040000"
$content$tree[[14]]$type
[1] "tree"
$content$tree[[14]]$sha
[1] "7d9a20f9b6697fcfcd3cebd4a1367c886c020657"
$content$tree[[14]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/7d9a20f9b6697fcfcd3cebd4a1367c886c020657"
$content$tree[[15]]
$content$tree[[15]]$path
[1] "activerecord"
$content$tree[[15]]$mode
[1] "040000"
$content$tree[[15]]$type
[1] "tree"
$content$tree[[15]]$sha
[1] "b10efcd771cfe0d9897240c909771e33281eb350"
$content$tree[[15]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/b10efcd771cfe0d9897240c909771e33281eb350"
$content$tree[[16]]
$content$tree[[16]]$path
[1] "activesupport"
$content$tree[[16]]$mode
[1] "040000"
$content$tree[[16]]$type
[1] "tree"
$content$tree[[16]]$sha
[1] "c4b23480eacc3fcfce1862cf02c324bc987e70bb"
$content$tree[[16]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/c4b23480eacc3fcfce1862cf02c324bc987e70bb"
$content$tree[[17]]
$content$tree[[17]]$path
[1] "ci"
$content$tree[[17]]$mode
[1] "040000"
$content$tree[[17]]$type
[1] "tree"
$content$tree[[17]]$sha
[1] "70a4e8aaca18886c2b209e6d830b3455420a2f8a"
$content$tree[[17]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/70a4e8aaca18886c2b209e6d830b3455420a2f8a"
$content$tree[[18]]
$content$tree[[18]]$path
[1] "guides"
$content$tree[[18]]$mode
[1] "040000"
$content$tree[[18]]$type
[1] "tree"
$content$tree[[18]]$sha
[1] "db5cb05121a9c02b5897cb8bfa8127613955d4ef"
$content$tree[[18]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/db5cb05121a9c02b5897cb8bfa8127613955d4ef"
$content$tree[[19]]
$content$tree[[19]]$path
[1] "install.rb"
$content$tree[[19]]$mode
[1] "100644"
$content$tree[[19]]$type
[1] "blob"
$content$tree[[19]]$sha
[1] "96e4153165f5d4873135f664dc3619dcec29f801"
$content$tree[[19]]$size
[1] 534
$content$tree[[19]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/96e4153165f5d4873135f664dc3619dcec29f801"
$content$tree[[20]]
$content$tree[[20]]$path
[1] "load_paths.rb"
$content$tree[[20]]$mode
[1] "100644"
$content$tree[[20]]$type
[1] "blob"
$content$tree[[20]]$sha
[1] "0ad8fcfeda7fc44f99d28dd7c986820f6b85dab4"
$content$tree[[20]]$size
[1] 51
$content$tree[[20]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/0ad8fcfeda7fc44f99d28dd7c986820f6b85dab4"
$content$tree[[21]]
$content$tree[[21]]$path
[1] "rails.gemspec"
$content$tree[[21]]$mode
[1] "100644"
$content$tree[[21]]$type
[1] "blob"
$content$tree[[21]]$sha
[1] "139816992256e5303975256d9ece2ca5a6e305ba"
$content$tree[[21]]$size
[1] 1170
$content$tree[[21]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/139816992256e5303975256d9ece2ca5a6e305ba"
$content$tree[[22]]
$content$tree[[22]]$path
[1] "railties"
$content$tree[[22]]$mode
[1] "040000"
$content$tree[[22]]$type
[1] "tree"
$content$tree[[22]]$sha
[1] "18e09439d477446a32e17293e4e45b9044ad9d51"
$content$tree[[22]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/18e09439d477446a32e17293e4e45b9044ad9d51"
$content$tree[[23]]
$content$tree[[23]]$path
[1] "tasks"
$content$tree[[23]]$mode
[1] "040000"
$content$tree[[23]]$type
[1] "tree"
$content$tree[[23]]$sha
[1] "0faed436f5b8044f3d66b9fd2aec5c8d7d225407"
$content$tree[[23]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/0faed436f5b8044f3d66b9fd2aec5c8d7d225407"
$content$tree[[24]]
$content$tree[[24]]$path
[1] "tools"
$content$tree[[24]]$mode
[1] "040000"
$content$tree[[24]]$type
[1] "tree"
$content$tree[[24]]$sha
[1] "26ac3f78761e65305927402b7a84082cd25afb70"
$content$tree[[24]]$url
[1] "https://api.github.com/repos/rails/rails/git/trees/26ac3f78761e65305927402b7a84082cd25afb70"
$content$tree[[25]]
$content$tree[[25]]$path
[1] "version.rb"
$content$tree[[25]]$mode
[1] "100644"
$content$tree[[25]]$type
[1] "blob"
$content$tree[[25]]$sha
[1] "7d74b1bfe5e92812570789ec38aaf576f5eb5cc5"
$content$tree[[25]]$size
[1] 308
$content$tree[[25]]$url
[1] "https://api.github.com/repos/rails/rails/git/blobs/7d74b1bfe5e92812570789ec38aaf576f5eb5cc5"
$content$truncated
[1] FALSE
$headers
$server
[1] "GitHub.com"
$date
[1] "Fri, 24 Apr 2015 16:38:49 GMT"
$`content-type`
[1] "application/json; charset=utf-8"
$`transfer-encoding`
[1] "chunked"
$status
[1] "200 OK"
$`x-ratelimit-limit`
[1] "60"
$`x-ratelimit-remaining`
[1] "57"
$`x-ratelimit-reset`
[1] "1429895248"
$`cache-control`
[1] "public, max-age=60, s-maxage=60"
$`last-modified`
[1] "Fri, 24 Apr 2015 16:19:43 GMT"
$etag
[1] "W/\"5cf2ba9a233ca744f9fb2107044903b4\""
$vary
[1] "Accept"
$`x-github-media-type`
[1] "github.v3"
$`x-xss-protection`
[1] "1; mode=block"
$`x-frame-options`
[1] "deny"
$`content-security-policy`
[1] "default-src 'none'"
$`access-control-allow-credentials`
[1] "true"
$`access-control-expose-headers`
[1] "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"
$`access-control-allow-origin`
[1] "*"
$`x-github-request-id`
[1] "968744DD:70CD:20C6CFB:553A7199"
$`strict-transport-security`
[1] "max-age=31536000; includeSubdomains; preload"
$`x-content-type-options`
[1] "nosniff"
$vary
[1] "Accept-Encoding"
$`x-served-by`
[1] "bd82876e9bf04990f289ba22f246ee9b"
$`content-encoding`
[1] "gzip"
attr(,"class")
[1] "insensitive" "list"
$code
[1] 200
Is it currently possible to get the tree of a commit (e.g. https://developer.github.com/v3/git/trees/#get-a-tree)? Based on my reading of the code it seems like this is not possible, but it would be a very useful feature/