Find the first (root) commit in a GitHub repository
Source:R/get_first_repo_commit.R
get_first_repo_commit.RdClones (or refreshes) a GitHub repository into a shared local cache and
determines the earliest (root) commit using git history, without relying
on the GitHub REST API.
Arguments
- owner
Character scalar. GitHub username or organization.
- repo
Character scalar. GitHub repository name.
- branch
Optional character scalar. Git ref to use (e.g.
"main"). IfNULLor empty, the function usesorigin/HEADwhen available, otherwiseHEAD.- date_only
Logical. If
TRUE, return only theDateof the first commit. Defaults toFALSE.- cache_dir
Directory used to cache cloned repositories. Defaults to
getOption("ggext.git_cache", file.path(tempdir(), "gh_repo_cache")).
Value
If a root commit is found:
When
date_only = TRUE, aDate.Otherwise, a one-row
data.framewith columns:first_repo,author,message, andurl.
If the repository cannot be accessed or inspected:
Returns
NAwhendate_only = TRUEReturns
NULLotherwise
Details
This function uses the same on-disk Git repository cache as related helpers:
get_first_export()
The cache location is controlled by the ggext.git_cache option. Repositories
cloned or refreshed by any of these functions are reused across calls, avoiding
redundant network access.
See also
get_first_commit(), get_first_export(), get_first_call_github()
Examples
if (FALSE) { # \dontrun{
get_first_repo_commit("YuLab-SMU", "ggtree")
get_first_repo_commit("tidyverse", "ggplot2", date_only = TRUE)
options(ggext.git_cache = "~/Library/Caches/ggext_git")
} # }