Learn R Programming

packager (version 1.9.0)

add_github_url_to_desc: Add a github URL to File DESCRIPTION

Description

When writing packages, I often forget to add the appropriate github URL.

Usage

add_github_url_to_desc(path = ".", default_gh_user = NULL, normalize = TRUE)

Arguments

path

Path to the package directory (see devtools::as.package).

default_gh_user

See details.

normalize

Value

Invisibly TRUE if adding a github URL, FALSE otherwise.

Details

The URL is constructed by the package's name as read from it's file DESCRIPTION, and the username returned by whoami::gh_username. whoami::gh_username allows for a fallback, this is given by default_gh_user. You can specify default_gh_user = NA, to try to retrieve the username by searching remotes on github if the package is a git repository. We do not use gert::git_signature_default since there's no way to make sure the configured git user name, locally or globally, is a github username.

Examples

Run this code
# NOT RUN {
path <- file.path(tempdir(), "myPackage")
usethis::create_package(path, open = FALSE)
add_github_url_to_desc(path)
grep("^URL:", readLines(file.path(path, "DESCRIPTION")), value = TRUE)
unlink(path, recursive = TRUE)
# }

Run the code above in your browser using DataLab