knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(gitear) library(dplyr) library(dplyr) library(jsonlite) library(mockery)
The goal of gitear is to request your self-hosted Git service data and import it to R in a tidy data frame.
gitear
is a package that communicates with the
gitea API.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("ixpantia/gitear")
First go to your gitea self hosted service and grab your API Token. Then you should be able to the following:
r <- readRDS(system.file("helper_data/response_example.RDS", package = "gitear")) content_issues <- jsonlite::fromJSON(system.file("helper_data/get_issues.json", package = "gitear")) mockery::stub(where = get_issues, what = "GET", how = r) mockery::stub(where = get_issues, what = "fromJSON", how = content_issues)
# Credentials api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19" url_ixpantia <- "https://prueba.com" # Example function use issues <- get_issues(base_url = url_ixpantia, api_key = api_token, owner = "empresa", repo = "repo_prueba") issues
In order to work with environmental variables to make your scripts safer from somebody getting your credentials, you can follow the next workflow:
Your script could look something like this:
# Storing credentials in an object example_key <- Sys.getenv("example_key") example_url <- Sys.getenv("example_url") # Using a function from gitear issues <- get_issues(base_url = example_url, api_key = example_key, owner = "empresa", repo = "repo_prueba") # Check the output glimpse(issues)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.