Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full SHA is the default - but prints out the subset #61

Merged
merged 5 commits into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

# development version

* The `source` column of the output data frame of `package_info()` (also
part of `session_info()`), now contains the full SHA for packages installed
from GitHub, instead of only the first seven characters. This makes it
easier to use the SHA programmatically. Note that this does not affect
formatting and printing, which still use the abbreviated SHA.
(@muschellij2, #61).

* RStudio Package Manager (RSPM) and other repository sources are
now shown in the `source` column, if they set the `Repository`
field in `DESCRIPTION`.
Expand Down
10 changes: 7 additions & 3 deletions R/package-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pkg_source <- function(desc) {
str <- paste0("Github (",
desc$GithubUsername, "/",
desc$GithubRepo, "@",
substr(desc$GithubSHA1, 1, 7), ")")
desc$GithubSHA1, ")")
} else if (!is.null(desc$RemoteType) && desc$RemoteType == "standard") {
if (!is.null(desc$Repository) && desc$Repository == "CRAN") {
pkg_source_cran(desc)
Expand Down Expand Up @@ -144,7 +144,7 @@ pkg_source <- function(desc) {
}

if (!is.null(desc$RemoteSha)) {
sha <- paste0("@", substr(desc$RemoteSha, 1, 7))
sha <- paste0("@", desc$RemoteSha)
} else {
sha <- NULL
}
Expand Down Expand Up @@ -220,6 +220,10 @@ pkg_md5_disk <- function(pkgdir) {
order_by_name(structure(unname(md5_files), names = tolower(dll_files)))
}

abbrev_long_sha <- function(x) {
sub("([0-9a-f]{7})[0-9a-f]{33}", "\\1", x)
}

#' @export

format.packages_info <- function(x, ...) {
Expand All @@ -233,7 +237,7 @@ format.packages_info <- function(x, ...) {
version = ifelse(unloaded, x$ondiskversion, x$loadedversion),
"date (UTC)" = x$date,
lib = paste0("[", flib(x$library), "]"),
source = x$source,
source = abbrev_long_sha(x$source),
stringsAsFactors = FALSE,
check.names = FALSE
)
Expand Down
Binary file modified tests/testthat/fixtures/devtools-info-unix.rda
Binary file not shown.
Binary file modified tests/testthat/fixtures/devtools-info-windows.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-package-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test_that("pkg_source", {

expect_identical(
pkg_source(descs$debugme),
"Github (gaborcsardi/debugme@df8295a)"
"Github (gaborcsardi/debugme@df8295a75f8e26bec90386beb1c82b529427029f)"
)

expect_identical(pkg_source(descs$curl), "CRAN (R 3.3.3)")
Expand Down