Skip to content

Commit

Permalink
fix #2304: shouldn't have used return(meta) since meta is not the…
Browse files Browse the repository at this point in the history
… `citation()` but `packageDescription()`
  • Loading branch information
yihui committed Oct 30, 2023
1 parent 0f5a15d commit ce8cf77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.45.1
Version: 1.45.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Abhraneel", "Sarma", role = "ctb"),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGES IN knitr VERSION 1.46

## BUG FIXES

- `write_bib()` generated empty entries for packages without URLs (thanks, @bastistician, #2304).

# CHANGES IN knitr VERSION 1.45

Expand Down
7 changes: 3 additions & 4 deletions R/citation.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ write_bib = function(
x = setdiff(x, setdiff(xfun::base_pkgs(), 'base'))
x = sort(x)
bib = sapply(x, function(pkg) {
cite = citation(pkg, auto = if (pkg != 'base') {
meta = packageDescription(pkg, lib.loc = lib.loc)
# don't use the citation() URL if the package has provided its own URL
if (is.null(meta$URL)) return(meta)
meta = packageDescription(pkg, lib.loc = lib.loc)
# don't use the citation() URL if the package has provided its own URL
cite = citation(pkg, auto = if (is.null(meta$URL)) meta else {
if (packageURL) meta$Repository = meta$RemoteType = NULL
# the package may have provided multiple URLs, in which case we use the
# first. We also work around a bug in citation() up to R 4.3.1. The grep
Expand Down

0 comments on commit ce8cf77

Please sign in to comment.