lifecycle R-CMD-check Codecov test coverage
With GitStats you can pull git data in a uniform way
from GitHub and GitLab. For the time-being you can get data on:
You can also prepare basic statistics with get_*_stats()
functions for commits and issues.
From CRAN:
install.packages("GitStats")From GitHub:
devtools::install_github("r-world-devs/GitStats")Setup your GitStats:
library(GitStats)
git_stats <- create_gitstats() |>
set_gitlab_host(
repos = "mbtests/gitstatstesting"
) |>
set_github_host(
orgs = "r-world-devs",
repos = "openpharma/DataFakeR"
) Get commits:
commits <- git_stats |>
get_commits(
since = "2022年01月01日"
)
commits
#> # A tibble: 2,976 ×ばつ 11
#> id committed_date author author_login author_name additions deletions
#> <chr> <dttm> <chr> <chr> <chr> <int> <int>
#> 1 7f48... 2024年09月10日 11:12:59 Macie... maciekbanas Maciej Ban... 0 0
#> 2 9c66... 2024年09月10日 10:35:37 Macie... maciekbanas Maciej Ban... 0 0
#> 3 fca2... 2024年09月10日 10:31:24 Macie... maciekbanas Maciej Ban... 0 0
#> 4 e8f2... 2023年03月30日 14:15:33 Macie... maciekbanas Maciej Ban... 1 0
#> 5 7e87... 2023年02月10日 09:48:55 Macie... maciekbanas Maciej Ban... 1 1
#> 6 62c4... 2023年02月10日 09:17:24 Macie... maciekbanas Maciej Ban... 2 87
#> 7 55cf... 2023年02月10日 09:07:54 Macie... maciekbanas Maciej Ban... 92 0
#> 8 C_kw... 2023年05月08日 09:43:31 Kryst... krystian8207 Krystian I... 18 0
#> 9 C_kw... 2023年04月28日 12:30:40 Kamil... <NA> Kamil Kozi... 18 0
#> 10 C_kw... 2023年03月01日 15:05:10 Kryst... krystian8207 Krystian I... 296 153
#> # i 2,966 more rows
#> # i 4 more variables: repository <chr>, organization <chr>, repo_url <chr>,
#> # api_url <glue>
commits |>
get_commits_stats(
time_aggregation = "month",
group_var = author
)
#> # A tibble: 307 ×ばつ 4
#> stats_date githost author stats
#> <dttm> <chr> <chr> <int>
#> 1 2022年01月01日 00:00:00 github Admin_mschuemi 1
#> 2 2022年01月01日 00:00:00 github Gowtham Rao 5
#> 3 2022年01月01日 00:00:00 github Krystian Igras 1
#> 4 2022年01月01日 00:00:00 github Martijn Schuemie 1
#> 5 2022年02月01日 00:00:00 github Hadley Wickham 3
#> 6 2022年02月01日 00:00:00 github Martijn Schuemie 2
#> 7 2022年02月01日 00:00:00 github Maximilian Girlich 13
#> 8 2022年02月01日 00:00:00 github Reijo Sund 1
#> 9 2022年02月01日 00:00:00 github eitsupi 1
#> 10 2022年03月01日 00:00:00 github Maximilian Girlich 14
#> # i 297 more rowsGet repositories with specific code:
git_stats |>
get_repos(
with_code = "shiny",
add_contributors = FALSE
)
#> # A tibble: 8 ×ばつ 16
#> repo_id repo_name organization fullname platform repo_url api_url
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 R_kgDOHYNOFQ cohortBuilder r-world-devs r-world... github https:/... https:...
#> 2 R_kgDOHYNrJw shinyCohortBuild... r-world-devs r-world... github https:/... https:...
#> 3 R_kgDOIvtxsg GitStats r-world-devs r-world... github https:/... https:...
#> 4 R_kgDOJAtHJA shinyTimelines r-world-devs r-world... github https:/... https:...
#> 5 R_kgDOJWYrCA hypothesis r-world-devs r-world... github https:/... https:...
#> 6 R_kgDOM0o1nA queryBuilder r-world-devs r-world... github https:/... https:...
#> 7 R_kgDOM0vVsA shinyQueryBuilder r-world-devs r-world... github https:/... https:...
#> 8 R_kgDONLzQTw GitAI r-world-devs r-world... github https:/... https:...
#> # i 9 more variables: created_at <dttm>, last_activity_at <dttm>,
#> # last_activity <drtn>, default_branch <chr>, stars <int>, forks <int>,
#> # languages <chr>, issues_open <int>, issues_closed <int>Get files:
git_stats |>
get_files(
pattern = "\\.md",
depth = 2L
)
#> # A tibble: 58 ×ばつ 8
#> repo_name repo_id organization file_path file_content file_size repo_url
#> <chr> <chr> <chr> <chr> <chr> <int> <chr>
#> 1 GitStats Test... gid://... mbtests README.md "# GitStats... 122 https:/...
#> 2 shinyGizmo R_kgDO... r-world-devs NEWS.md "# shinyGiz... 2186 https:/...
#> 3 shinyGizmo R_kgDO... r-world-devs README.md "\n# shinyG... 2337 https:/...
#> 4 shinyGizmo R_kgDO... r-world-devs cran-com... "## Test en... 1700 https:/...
#> 5 cohortBuilder R_kgDO... r-world-devs NEWS.md "# cohortBu... 1072 https:/...
#> 6 cohortBuilder R_kgDO... r-world-devs README.md "\n# cohort... 15830 https:/...
#> 7 shinyCohortBu... R_kgDO... r-world-devs NEWS.md "# shinyCoh... 2018 https:/...
#> 8 shinyCohortBu... R_kgDO... r-world-devs README.md "\n# shinyC... 3355 https:/...
#> 9 cohortBuilder... R_kgDO... r-world-devs README.md "\n# cohort... 3472 https:/...
#> 10 GitStats R_kgDO... r-world-devs LICENSE.... "# MIT Lice... 1075 https:/...
#> # i 48 more rows
#> # i 1 more variable: api_url <chr>Print GitStats to see what it stores:
git_stats
#> A GitStats object for 2 hosts:
#> Hosts: https://gitlab.com/api/v4, https://api.github.com
#> Scanning scope:
#> Organizations: [1] r-world-devs
#> Repositories: [2] mbtests/gitstatstesting, openpharma/DataFakeR
#> Storage:
#> Repositories: 8
#> Commits: 2976 [date range: 2022年01月01日 - 2025年06月27日]
#> Files: 58 [file pattern: \.md]GitStats is used to facilitate workflow of the
GitAI R package, a tool for gathering AI-based knowledge
about git repositories: https://r-world-devs.github.io/GitAI/
Special thanks to James Black, Karolina Marcinkowska, Kamil Koziej, Matt Secrest, Krystian Igras, Kamil Wais, Adam Forys - for the support in the package development.