Learn R Programming

gitear

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.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("ixpantia/gitear")

Usage

First go to your gitea self hosted service and grab your API Token. Then you should be able to the following:

# 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
#>   number                      title created_date created_time updated_date
#> 1      3 Primer tiquete para prueba   2020-07-15     23:43:42   2020-07-24
#> 2      2 Primer tiquete para prueba   2020-07-15     23:12:37   2020-07-24
#>   updated_time             due_date author assignee
#> 1     14:41:47 2020-07-31T23:59:59Z   juan     juan
#> 2     14:41:37 2020-07-31T23:59:59Z   juan     juan

Environmental variables:

In order to work with environmental variables to make your scripts safer from somebody getting your credentials, you can follow the next workflow:

  1. Create an .Renviron file with your credentials
  2. Restart your R session
  3. Store your credentials in an object for using it in your script

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)
#> Rows: 2
#> Columns: 9
#> $ number       <int> 3, 2
#> $ title        <chr> "Primer tiquete para prueba", "Primer tiquete para pru...
#> $ created_date <chr> "2020-07-15", "2020-07-15"
#> $ created_time <chr> "23:43:42", "23:12:37"
#> $ updated_date <chr> "2020-07-24", "2020-07-24"
#> $ updated_time <chr> "14:41:47", "14:41:37"
#> $ due_date     <chr> "2020-07-31T23:59:59Z", "2020-07-31T23:59:59Z"
#> $ author       <chr> "juan", "juan"
#> $ assignee     <chr> "juan", "juan"

Copy Link

Version

Install

install.packages('gitear')

Monthly Downloads

179

Version

1.0.0

License

GPL-3

Maintainer

Frans van Dunn

Last Published

September 18th, 2020

Functions in gitear (1.0.0)

get_branches

Returns the branches of a repository
get_an_organization

Returns an organization
edit_comment

Edit a comment
get_admin_organizations

Returns organizations for an administrator user
create_issue

Create a new issue
add_tracked_time_issue

Add tracked time to an issue
get_forks

Returns the forks of a repository
edit_issue

Edit an issue
create_comment_issue

Add a comment to an issue
get_commits

Returns repository commits
get_issues

Returns open issues from an specific repository
get_list_org_members

Returns organization's members
get_issues_closed_state

Returns the repository issues in closed state
get_milestones

Returns open milestones of a repository
get_releases

Returns releases of a repository
get_pull_requests

Returns pull requests of a repository
get_list_org_teams

Returns organization's teams
get_org_hook

Returns a hook
get_list_comments_repository

Returns all comments in a repository
get_list_comments_issue

Returns all comments on an issue
get_version

Returns gitea service version
gitear

gitear package
get_list_repos_org

Returns organization's repositories
get_list_users

Returns users of a gitea server
get_times_issue

Returns issue's tracked times
get_issues_open_state

Returns the repository issues in open state
get_repositories

Returns repositories of a gitea service
get_label_issue

Returns an issue's labels
get_organizations

Returns organizations of the user
get_org_list_hooks

Returns organization's webhooks