From 534e44334fe15e8b3352a87ba2a2b3643503fc5a Mon Sep 17 00:00:00 2001 From: dieghernan Date: Wed, 12 Jun 2024 09:37:29 +0000 Subject: [PATCH 1/4] 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). From 29b806a240687922e24b0acc1d4853d55b82189b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:44:52 +0000 Subject: [PATCH 2/4] Update docs with pkgdev --- README.md | 3 ++- codemeta.json | 2 +- data/cran_to_spdx.rda | Bin 893 -> 916 bytes 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 021cd090..29a50185 100644 --- a/README.md +++ b/README.md @@ -904,7 +904,8 @@ for more info. ## References -
+
diff --git a/codemeta.json b/codemeta.json index c1eb6eb0..adcbd67f 100644 --- a/codemeta.json +++ b/codemeta.json @@ -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.462KB", + "fileSize": "1602.503KB", "citation": [ { "@type": "ScholarlyArticle", diff --git a/data/cran_to_spdx.rda b/data/cran_to_spdx.rda index a781d11281af54dddd1cd6bf31fed5ada6219786..5cbf32e9d4d9ad016b9d73de84297c46a06478a9 100644 GIT binary patch literal 916 zcmV;F18e*riwFP!000001I<_6PunmM&q$%PYe&amllEk$J%BW$Hi10>QZZdsDM8gb zCZ;`9p%^VvnxG_QA5Z&d_HT|kA5Lt?DMg#MJv8U2pqRws#_{L`XmH|Kvp|eL*6DIxgXqTEIMK0~&SUEF zh@L`~EMX^m^BO|n_yaseaMT5Rc>okHVjQm)V+^1oM3*ZFqk%!+yP8N)OXX%F^GC9U zyy=u=ayYwim_*S8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#%hyF9rJF34aa`Dmm_)rwS4PH!QmVyS#$% From c213083958eaa5f2e308d2fd0904073d7aa7065e Mon Sep 17 00:00:00 2001 From: dieghernan Date: Wed, 12 Jun 2024 09:50:30 +0000 Subject: [PATCH 3/4] Fix vignettes --- vignettes/crosswalk.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/crosswalk.Rmd b/vignettes/crosswalk.Rmd index 1e82b43a..c70ff9ed 100644 --- a/vignettes/crosswalk.Rmd +++ b/vignettes/crosswalk.Rmd @@ -173,7 +173,7 @@ This is the case of packages installed using the Example -```{r authors} +```{r commit} # An example DESCRIPTION path <- system.file("examples/DESCRIPTION_r_universe", package = "cffr") pkg <- desc::desc(path) From a0a0678dfd7ed962610b1b72e11c8ce2f8228a65 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:32:59 +0000 Subject: [PATCH 4/4] Update docs with pkgdev --- codemeta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemeta.json b/codemeta.json index adcbd67f..35dd298e 100644 --- a/codemeta.json +++ b/codemeta.json @@ -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.503KB", + "fileSize": "1602.502KB", "citation": [ { "@type": "ScholarlyArticle",