Skip to content

Commit

Permalink
Extract commit info
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Jun 12, 2024
1 parent 1bd4be6 commit 534e443
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://doi.org/10.5281/zenodo.5171937>
is a human and machine readable file format which provides citation metadata for
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8457-4658")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion R/cff_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions R/utils-cff_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -311,9 +311,9 @@ test <- cff_create("rmarkdown")
authors:
- family-names: Wickham
given-names: Hadley
email: [email protected]
- family-names: Xie
given-names: Yihui
email: [email protected]
orcid: https://orcid.org/0000-0003-0645-5666
year: '2024'
version: '>= 0.13'
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ inproceedings
json
jsonvalidate
nd
pak
param
plaintext
pre
Expand Down
2 changes: 1 addition & 1 deletion inst/schemaorg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions tests/testthat/_snaps/cff_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@
- citation
- credit
- linked-data
commit: bdd9a29d7eabcc43c3195fe461f884932eba763c

# Parsing Bioconductor

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/_snaps/utils-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@
- credit
- linked-data
license: GPL-3.0-only
commit: bdd9a29d7eabcc43c3195fe461f884932eba763c
doi: 10.1111/2041-210X.12469
preferred-citation:
type: article
Expand Down
37 changes: 23 additions & 14 deletions vignettes/crosswalk.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ origin[keys %in% c(
"date-released",
"contact",
"keywords",
"license"
"license",
"commit"
)] <- "DESCRIPTION file"
origin[keys %in% c(
Expand Down Expand Up @@ -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"
> ```
<details>

<summary><strong>Example</strong></summary>

```{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)
```

</details>

[Back to summary](#summary).

Expand Down

0 comments on commit 534e443

Please sign in to comment.