AUTHOR: Brian M. Bot (brian.bot@sagebase.org)

if( file.exists("~/.Rprofile") )
  source("~/.Rprofile")
require(rGithubClient)

Overview

GitHub has emerged as a very popular tool for collaborative code development in the software community. The utility of source code repositories expands far beyond use in professional software development. In fact, it has been shown to be extremely useful for a number of other endeavors. The purpose of this package is to provide an interface for users of R to have web-accessible access to their code directly within their R sessions.

Setting your GitHub credentials

Users can use the rGithubClient without authenticating (anonymous calls to the API), however there are limits both to what can be accessed as well as the number of API calls allowed. Please see the GitHub Developer docs for more information on anonymous use of the GitHub API.

For access to private repositories and/or to have an increased limit on the number of API calls, users should register a personal access token with the client via the setGithubToken function. Personal access tokens can be generated on your GitHub settings page. Give your token a meaningful name, like "rGithubClient token" such that you can remember what it is being used for. Once you have called setGithubToken, the token passed to this function is then used for all subsequent calls to github api for the current R session.

via interactive authorization

require(rGithubClient)
setGithubToken("myTokenFromGithub12345678")

via a hook in your .Rprofile

Include the following information in your .Rprofile located in your root directory. As this is sensitive information, make sure that this file is only visible to you.

setHook(
  packageEvent("rGithubClient", "attach"),
  function(...){
    ## set my github authorization at package loading
    setGithubToken("myTokenFromGithub12345678")
  }
)

Getting meta-information about a GitHub repository

from head of the master branch (default)

repo <- getRepo('brian-bot/rGithubClient')
repo

from a specific branch

repoDev <- getRepo('brian-bot/rGithubClient', ref='branch', refName='dev')
repoDev

from a specific tag

repoTag <- getRepo('brian-bot/rGithubClient', ref='tag', refName='rGithubClient-0.8')
repoTag

from a specific commit

repoCommit <- getRepo("brian-bot/rGithubClient", ref="commit", refName="9382e7191073c1a5dc554ec8b6658d07d405b89e")
repoCommit

Sourcing a file from a GitHub repository

sourceRepoFile(repoDev, "inst/misc/helloWorld.R")

Retrieving a permlink from a GitHub file

getPermlink(repoDev, "inst/misc/helloWorld.R")

Viewing a specific commit on GitHub

view(repoDev, "inst/misc/helloWorld.R")

R sessionInfo()

sessionInfo()


brian-bot/rGithubClient documentation built on May 13, 2019, 5:12 a.m.