add_github_url_to_desc: Add a github URL to File 'DESCRIPTION'

View source: R/description.R

add_github_url_to_descR Documentation

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

Passed to desc::desc_set_urls.

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.

Value

Invisibly TRUE if adding a ⁠github⁠ URL, FALSE otherwise.

Examples

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)

packager documentation built on Aug. 16, 2023, 5:08 p.m.