read_github_file: Read files from a commit

Description Usage Arguments Value Examples

Description

These functions read a file from a commit in a repository. read_github_file() reads a text file, using readr::read_file(), and returns the result as a string. read_github_lines() reads a text file, using readr::read_lines(), and returns the result as a character vector, one element per line. read_github_csv() reads a CSV file, using readr::read_csv(), and returns the result as a tibble.

Usage

1
2
3
4
5
read_github_file(path, ref, repo, ...)

read_github_lines(path, ref, repo, ...)

read_github_csv(path, ref, repo, ...)

Arguments

path

(string) The path to the file, within the repository.

ref

(string) Either a SHA, branch or tag used to identify the commit.

repo

(string) The repository specified in the format: owner/repo.

...

Parameters passed to readr::read_file(), readr::read_lines() or readr::read_csv().

Value

read_github_file() returns a string containing the file contents, read_github_lines() returns a character vector, and read_github_csv() returns a tibble.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 

  read_github_file(
    path = "README.md",
    ref  = "main",
    repo = "ChadGoymer/githapi"
  )

  read_github_lines(
    path = "README.md",
    ref  = "main",
    repo = "ChadGoymer/githapi"
  )

  read_github_csv(
    path = "inst/test-data/test.csv",
    ref  = "main",
    repo = "ChadGoymer/githapi"
  )


## End(Not run)

ChadGoymer/githapi documentation built on Oct. 22, 2021, 10:56 a.m.