Skip to contents

Get info of a branch in a GitHub repo

Usage

get_branch_info_from_gh(
  owner = getOption("pipfun.ghowner"),
  repo,
  branch = "main",
  gh_func = gh::gh,
  creds_func = get_github_creds,
  url_func = info_from_url
)

Arguments

owner

character: owner of repo

repo

character: repository name

branch

character: branch name (default is "main")

gh_func

function: function used to call the GitHub API (default is gh::gh)

creds_func

function: function used to retrieve GitHub credentials (default is get_github_creds)

url_func

function: function used to extract additional information from the protection URL (default is info_from_url)

Value

Complete response from GET method of GitHub API

Examples

get_branch_info_from_gh(owner     = getOption("pipfun.ghowner"),
                        repo      = "pip_info",
                        branch    = "releases")
#> Git credentials are missing or invalid in non-interactive mode.
#> $name
#> [1] "releases"
#> 
#> $commit
#> $commit$sha
#> [1] "77712811ff1327edae2b7d4bd505deb7aad01c24"
#> 
#> $commit$node_id
#> [1] "C_kwDOMtdcOdoAKDc3NzEyODExZmYxMzI3ZWRhZTJiN2Q0YmQ1MDVkZWI3YWFkMDFjMjQ"
#> 
#> $commit$commit
#> $commit$commit$author
#> $commit$commit$author$name
#> [1] "R.Andrés Castañeda"
#> 
#> $commit$commit$author$email
#> [1] "acastanedaa@worldbank.org"
#> 
#> $commit$commit$author$date
#> [1] "2025-04-12T19:41:47Z"
#> 
#> 
#> $commit$commit$committer
#> $commit$commit$committer$name
#> [1] "R.Andrés Castañeda"
#> 
#> $commit$commit$committer$email
#> [1] "acastanedaa@worldbank.org"
#> 
#> $commit$commit$committer$date
#> [1] "2025-04-12T19:41:47Z"
#> 
#> 
#> $commit$commit$message
#> [1] "Updating data via R script on 2025-04-12 15:41:48.34397"
#> 
#> $commit$commit$tree
#> $commit$commit$tree$sha
#> [1] "3f47af7ff68c244732eb00c3a714d178590d046a"
#> 
#> $commit$commit$tree$url
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/git/trees/3f47af7ff68c244732eb00c3a714d178590d046a"
#> 
#> 
#> $commit$commit$url
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/git/commits/77712811ff1327edae2b7d4bd505deb7aad01c24"
#> 
#> $commit$commit$comment_count
#> [1] 0
#> 
#> $commit$commit$verification
#> $commit$commit$verification$verified
#> [1] FALSE
#> 
#> $commit$commit$verification$reason
#> [1] "unsigned"
#> 
#> $commit$commit$verification$signature
#> NULL
#> 
#> $commit$commit$verification$payload
#> NULL
#> 
#> $commit$commit$verification$verified_at
#> NULL
#> 
#> 
#> 
#> $commit$url
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/commits/77712811ff1327edae2b7d4bd505deb7aad01c24"
#> 
#> $commit$html_url
#> [1] "https://github.com/PIP-Technical-Team/pip_info/commit/77712811ff1327edae2b7d4bd505deb7aad01c24"
#> 
#> $commit$comments_url
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/commits/77712811ff1327edae2b7d4bd505deb7aad01c24/comments"
#> 
#> $commit$author
#> $commit$author$login
#> [1] "randrescastaneda"
#> 
#> $commit$author$id
#> [1] 35301997
#> 
#> $commit$author$node_id
#> [1] "MDQ6VXNlcjM1MzAxOTk3"
#> 
#> $commit$author$avatar_url
#> [1] "https://avatars.githubusercontent.com/u/35301997?v=4"
#> 
#> $commit$author$gravatar_id
#> [1] ""
#> 
#> $commit$author$url
#> [1] "https://api.github.com/users/randrescastaneda"
#> 
#> $commit$author$html_url
#> [1] "https://github.com/randrescastaneda"
#> 
#> $commit$author$followers_url
#> [1] "https://api.github.com/users/randrescastaneda/followers"
#> 
#> $commit$author$following_url
#> [1] "https://api.github.com/users/randrescastaneda/following{/other_user}"
#> 
#> $commit$author$gists_url
#> [1] "https://api.github.com/users/randrescastaneda/gists{/gist_id}"
#> 
#> $commit$author$starred_url
#> [1] "https://api.github.com/users/randrescastaneda/starred{/owner}{/repo}"
#> 
#> $commit$author$subscriptions_url
#> [1] "https://api.github.com/users/randrescastaneda/subscriptions"
#> 
#> $commit$author$organizations_url
#> [1] "https://api.github.com/users/randrescastaneda/orgs"
#> 
#> $commit$author$repos_url
#> [1] "https://api.github.com/users/randrescastaneda/repos"
#> 
#> $commit$author$events_url
#> [1] "https://api.github.com/users/randrescastaneda/events{/privacy}"
#> 
#> $commit$author$received_events_url
#> [1] "https://api.github.com/users/randrescastaneda/received_events"
#> 
#> $commit$author$type
#> [1] "User"
#> 
#> $commit$author$user_view_type
#> [1] "public"
#> 
#> $commit$author$site_admin
#> [1] FALSE
#> 
#> 
#> $commit$committer
#> $commit$committer$login
#> [1] "randrescastaneda"
#> 
#> $commit$committer$id
#> [1] 35301997
#> 
#> $commit$committer$node_id
#> [1] "MDQ6VXNlcjM1MzAxOTk3"
#> 
#> $commit$committer$avatar_url
#> [1] "https://avatars.githubusercontent.com/u/35301997?v=4"
#> 
#> $commit$committer$gravatar_id
#> [1] ""
#> 
#> $commit$committer$url
#> [1] "https://api.github.com/users/randrescastaneda"
#> 
#> $commit$committer$html_url
#> [1] "https://github.com/randrescastaneda"
#> 
#> $commit$committer$followers_url
#> [1] "https://api.github.com/users/randrescastaneda/followers"
#> 
#> $commit$committer$following_url
#> [1] "https://api.github.com/users/randrescastaneda/following{/other_user}"
#> 
#> $commit$committer$gists_url
#> [1] "https://api.github.com/users/randrescastaneda/gists{/gist_id}"
#> 
#> $commit$committer$starred_url
#> [1] "https://api.github.com/users/randrescastaneda/starred{/owner}{/repo}"
#> 
#> $commit$committer$subscriptions_url
#> [1] "https://api.github.com/users/randrescastaneda/subscriptions"
#> 
#> $commit$committer$organizations_url
#> [1] "https://api.github.com/users/randrescastaneda/orgs"
#> 
#> $commit$committer$repos_url
#> [1] "https://api.github.com/users/randrescastaneda/repos"
#> 
#> $commit$committer$events_url
#> [1] "https://api.github.com/users/randrescastaneda/events{/privacy}"
#> 
#> $commit$committer$received_events_url
#> [1] "https://api.github.com/users/randrescastaneda/received_events"
#> 
#> $commit$committer$type
#> [1] "User"
#> 
#> $commit$committer$user_view_type
#> [1] "public"
#> 
#> $commit$committer$site_admin
#> [1] FALSE
#> 
#> 
#> $commit$parents
#> $commit$parents[[1]]
#> $commit$parents[[1]]$sha
#> [1] "2290221252550aa479f0057b8d99f5771de3e23a"
#> 
#> $commit$parents[[1]]$url
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/commits/2290221252550aa479f0057b8d99f5771de3e23a"
#> 
#> $commit$parents[[1]]$html_url
#> [1] "https://github.com/PIP-Technical-Team/pip_info/commit/2290221252550aa479f0057b8d99f5771de3e23a"
#> 
#> 
#> 
#> 
#> $`_links`
#> $`_links`$self
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/branches/releases"
#> 
#> $`_links`$html
#> [1] "https://github.com/PIP-Technical-Team/pip_info/tree/releases"
#> 
#> 
#> $protected
#> [1] FALSE
#> 
#> $protection
#> $protection$enabled
#> [1] FALSE
#> 
#> $protection$required_status_checks
#> $protection$required_status_checks$enforcement_level
#> [1] "off"
#> 
#> $protection$required_status_checks$contexts
#> list()
#> 
#> $protection$required_status_checks$checks
#> list()
#> 
#> 
#> 
#> $protection_url
#> [1] "https://api.github.com/repos/PIP-Technical-Team/pip_info/branches/releases/protection"
#> 
#> $owner
#> [1] "PIP-Technical-Team"
#> 
#> $repo
#> [1] "pip_info"
#> 
#> $branch
#> [1] "releases"
#>