From 534e44334fe15e8b3352a87ba2a2b3643503fc5a Mon Sep 17 00:00:00 2001 From: dieghernan Date: Wed, 12 Jun 2024 09:37:29 +0000 Subject: [PATCH] Extract commit info --- CITATION.cff | 2 +- DESCRIPTION | 2 +- NEWS.md | 4 +++ R/cff_read.R | 3 ++- R/utils-cff_read.R | 10 ++++++++ README.md | 4 +-- codemeta.json | 4 +-- inst/WORDLIST | 1 + inst/schemaorg.json | 2 +- tests/testthat/_snaps/cff_create.md | 1 + tests/testthat/_snaps/utils-create.md | 1 + vignettes/crosswalk.Rmd | 37 +++++++++++++++++---------- 12 files changed, 49 insertions(+), 22 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index fbf155f1..f16ce419 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -8,7 +8,7 @@ message: 'To cite package "cffr" in publications use:' type: software license: GPL-3.0-or-later title: 'cffr: Generate Citation File Format (''cff'') Metadata for R Packages' -version: 1.0.1 +version: 1.0.1.9000 doi: 10.21105/joss.03900 abstract: The Citation File Format version 1.2.0 is a human and machine readable file format which provides citation metadata for diff --git a/DESCRIPTION b/DESCRIPTION index 12fe7594..ea778882 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cffr Title: Generate Citation File Format ('cff') Metadata for R Packages -Version: 1.0.1 +Version: 1.0.1.9000 Authors@R: c( person("Diego", "Hernangómez", , "diego.hernangomezherrero@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0001-8457-4658")), diff --git a/NEWS.md b/NEWS.md index 4cdb0665..e14e3adb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# cffr (development version) + +- Extract `commit` from `RemoteSha`. + # cffr 1.0.1 - Update `cff_write()` to add a new `encoding` argument to make it work with diff --git a/R/cff_read.R b/R/cff_read.R index 7d7c88c8..f071d3eb 100644 --- a/R/cff_read.R +++ b/R/cff_read.R @@ -178,7 +178,8 @@ cff_read_description <- function(path, cff_version = "1.2.0", "date-released" = get_desc_date_released(pkg), contact = get_desc_contacts(pkg), keywords = get_desc_keywords(pkg), - license = unlist(get_desc_license(pkg)) + license = unlist(get_desc_license(pkg)), + commit = get_desc_sha(pkg) ) if (gh_keywords) { diff --git a/R/utils-cff_read.R b/R/utils-cff_read.R index f8d7f5ae..5388c092 100644 --- a/R/utils-cff_read.R +++ b/R/utils-cff_read.R @@ -356,3 +356,13 @@ get_gh_topics <- function(x) { return(remotetopics) } + + +get_desc_sha <- function(pkg) { + sha <- pkg$get("RemoteSha") + + sha <- clean_str(sha) + sha <- unname(sha) + + sha +} diff --git a/README.md b/README.md index bbff6326..021cd090 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ file and the `CITATION` file (if present) of your package. Note that **cffr** works best if your package pass `R CMD check/devtools::check()`. -As per 2024-06-05 there are at least 242 repos on GitHub using **cffr**. +As per 2024-06-12 there are at least 271 repos on GitHub using **cffr**. [Check them out here](https://github.com/search?q=cffr%20path%3A**%2FCITATION.cff&type=code). @@ -311,9 +311,9 @@ test <- cff_create("rmarkdown") authors: - family-names: Wickham given-names: Hadley + email: hadley@posit.co - family-names: Xie given-names: Yihui - email: xie@yihui.name orcid: https://orcid.org/0000-0003-0645-5666 year: '2024' version: '>= 0.13' diff --git a/codemeta.json b/codemeta.json index 85ee1131..c1eb6eb0 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,7 +8,7 @@ "codeRepository": "https://github.com/ropensci/cffr", "issueTracker": "https://github.com/ropensci/cffr/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "1.0.1", + "version": "1.0.1.9000", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -200,7 +200,7 @@ }, "isPartOf": "https://ropensci.org", "keywords": ["attribution", "citation", "credit", "citation-files", "cff", "metadata", "r", "r-package", "citation-file-format", "rstats", "ropensci", "cran"], - "fileSize": "1602.066KB", + "fileSize": "1602.462KB", "citation": [ { "@type": "ScholarlyArticle", diff --git a/inst/WORDLIST b/inst/WORDLIST index 1db8f9d4..7fc3f929 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -78,6 +78,7 @@ inproceedings json jsonvalidate nd +pak param plaintext pre diff --git a/inst/schemaorg.json b/inst/schemaorg.json index 0671b75b..5cbd220d 100644 --- a/inst/schemaorg.json +++ b/inst/schemaorg.json @@ -27,5 +27,5 @@ "url": "https://cran.r-project.org" }, "runtimePlatform": "R version 4.4.0 (2024-04-24)", - "version": "1.0.1" + "version": "1.0.1.9000" } diff --git a/tests/testthat/_snaps/cff_create.md b/tests/testthat/_snaps/cff_create.md index 0264c035..d4b01e84 100644 --- a/tests/testthat/_snaps/cff_create.md +++ b/tests/testthat/_snaps/cff_create.md @@ -416,6 +416,7 @@ - citation - credit - linked-data + commit: bdd9a29d7eabcc43c3195fe461f884932eba763c # Parsing Bioconductor diff --git a/tests/testthat/_snaps/utils-create.md b/tests/testthat/_snaps/utils-create.md index 906fbdb4..c1bcbb83 100644 --- a/tests/testthat/_snaps/utils-create.md +++ b/tests/testthat/_snaps/utils-create.md @@ -665,6 +665,7 @@ - credit - linked-data license: GPL-3.0-only + commit: bdd9a29d7eabcc43c3195fe461f884932eba763c doi: 10.1111/2041-210X.12469 preferred-citation: type: article diff --git a/vignettes/crosswalk.Rmd b/vignettes/crosswalk.Rmd index f9bf6a83..1e82b43a 100644 --- a/vignettes/crosswalk.Rmd +++ b/vignettes/crosswalk.Rmd @@ -59,7 +59,8 @@ origin[keys %in% c( "date-released", "contact", "keywords", - "license" + "license", + "commit" )] <- "DESCRIPTION file" origin[keys %in% c( @@ -163,20 +164,28 @@ cat(cff_objv110$`cff-version`) ### commit -This key is not extracted from the metadata of the package. See the description -on the [Guide to CFF schema -v1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#commit). +This key is extracted from the `"RemoteSha"` field of the `DESCRIPTION` file. +This is the case of packages installed using the +[r-universe](https://r-universe.dev/) or packages such as **remotes** or +**pak**. -> - **description**: The commit hash or revision number of the software -> version. -> -> - **usage**: -> -> ``` yaml -> commit: 1ff847d81f29c45a3a1a5ce73d38e45c2f319bba -> -> commit: "Revision: 8612" -> ``` +
+ +Example + +```{r authors} +# An example DESCRIPTION +path <- system.file("examples/DESCRIPTION_r_universe", package = "cffr") +pkg <- desc::desc(path) + +# See RemoteSha +pkg$get("RemoteSha") + + +cff_read(path) +``` + +
[Back to summary](#summary).