Get a response from the GitHub API.

ghr_get(path, ref = "master", ...)

Arguments

path

A string formatted as "owner/repo/subdir" or "owner/repo/subdir@branch", e.g.: "maurolepore/ghr/reference@gh-pages".

ref

Branch name.

...

Arguments passed to gh::gh().

Value

A list.

See also

ghr_fields

Other functions to get github responses: ghr_show_branches

Examples

# The request to GitHub happens only the first time you call ghr_get() system.time(ghr_get("maurolepore/ghr"))
#> user system elapsed #> 0.032 0.000 0.251
# Later calls take no time because the first call is memoised system.time(ghr_get("maurolepore/ghr"))
#> user system elapsed #> 0.016 0.000 0.015
gh_response <- ghr_get("maurolepore/ghr") class(gh_response)
#> [1] "gh_response" "list"
length(gh_response)
#> [1] 16
str(gh_response[[1]])
#> List of 10 #> $ name : chr ".Rbuildignore" #> $ path : chr ".Rbuildignore" #> $ sha : chr "378f0fe22a9c4b63ac910956a99443046a43601a" #> $ size : int 120 #> $ url : chr "https://api.github.com/repos/maurolepore/ghr/contents/.Rbuildignore?ref=master" #> $ html_url : chr "https://github.com/maurolepore/ghr/blob/master/.Rbuildignore" #> $ git_url : chr "https://api.github.com/repos/maurolepore/ghr/git/blobs/378f0fe22a9c4b63ac910956a99443046a43601a" #> $ download_url: chr "https://raw.githubusercontent.com/maurolepore/ghr/master/.Rbuildignore" #> $ type : chr "file" #> $ _links :List of 3 #> ..$ self: chr "https://api.github.com/repos/maurolepore/ghr/contents/.Rbuildignore?ref=master" #> ..$ git : chr "https://api.github.com/repos/maurolepore/ghr/git/blobs/378f0fe22a9c4b63ac910956a99443046a43601a" #> ..$ html: chr "https://github.com/maurolepore/ghr/blob/master/.Rbuildignore"
ghr_pull(ghr_get("maurolepore/ghr", ref = "gh-pages"), "path")
#> [1] "CHANGELOG.html" "CODE_OF_CONDUCT.html" "CONTRIBUTING.html" #> [4] "ISSUE_TEMPLATE.html" "LICENSE.html" "SUPPORT.html" #> [7] "articles" "authors.html" "docsearch.css" #> [10] "docsearch.js" "index.html" "link.svg" #> [13] "news" "pkgdown.css" "pkgdown.js" #> [16] "pkgdown.yml" "reference"
# Same ghr_pull(ghr_get("maurolepore/ghr@gh-pages"), "path")
#> [1] "CHANGELOG.html" "CODE_OF_CONDUCT.html" "CONTRIBUTING.html" #> [4] "ISSUE_TEMPLATE.html" "LICENSE.html" "SUPPORT.html" #> [7] "articles" "authors.html" "docsearch.css" #> [10] "docsearch.js" "index.html" "link.svg" #> [13] "news" "pkgdown.css" "pkgdown.js" #> [16] "pkgdown.yml" "reference"