New Upstream Release - r-cran-packrat

Ready changes

Summary

Merged new upstream version: 0.9.1 (was: 0.9.0).

Diff

diff --git a/DESCRIPTION b/DESCRIPTION
index ebbbf0b..06ea667 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,24 +1,38 @@
-Package: packrat
 Type: Package
+Package: packrat
 Title: A Dependency Management System for Projects and their R Package
         Dependencies
-Version: 0.9.0
-Author: Kevin Ushey, Jonathan McPherson, Joe Cheng, Aron Atkins, JJ Allaire,
-    Toph Allen
-Maintainer: Aron Atkins <aron@posit.co>
-Description: Manage the R packages your project depends
-    on in an isolated, portable, and reproducible way.
+Version: 0.9.1
+Authors@R: c(
+    person("Aron", "Atkins", , "aron@posit.co", role = c("aut", "cre")),
+    person("Toph", "Allen", role = "aut"),
+    person("Kevin", "Ushey", role = "aut"),
+    person("Jonathan", "McPherson", role = "aut"),
+    person("Joe", "Cheng", role = "aut"),
+    person("JJ", "Allaire", role = "aut"),
+    person("Posit Software, PBC", role = c("cph", "fnd"))
+  )
+Description: Manage the R packages your project depends on in an isolated,
+    portable, and reproducible way.
 License: GPL-2
-Depends: R (>= 3.0.0)
-Imports: tools, utils
-Suggests: testthat (>= 3.0.0), devtools, httr, knitr, mockery,
-        rmarkdown
 URL: https://github.com/rstudio/packrat/
 BugReports: https://github.com/rstudio/packrat/issues
-RoxygenNote: 7.2.1
-Encoding: UTF-8
+Depends: R (>= 3.0.0)
+Imports: tools, utils
+Suggests: devtools, httr, knitr, mockery, rmarkdown, testthat (>=
+        3.0.0)
 Config/testthat/edition: 3
+Encoding: UTF-8
+RoxygenNote: 7.2.1
 NeedsCompilation: no
-Packaged: 2023-01-09 18:28:51 UTC; aron
+Packaged: 2023-02-27 18:08:33 UTC; aron
+Author: Aron Atkins [aut, cre],
+  Toph Allen [aut],
+  Kevin Ushey [aut],
+  Jonathan McPherson [aut],
+  Joe Cheng [aut],
+  JJ Allaire [aut],
+  Posit Software, PBC [cph, fnd]
+Maintainer: Aron Atkins <aron@posit.co>
 Repository: CRAN
-Date/Publication: 2023-01-09 22:40:02 UTC
+Date/Publication: 2023-02-27 18:52:29 UTC
diff --git a/MD5 b/MD5
index e9af4ed..7665e9f 100644
--- a/MD5
+++ b/MD5
@@ -1,4 +1,4 @@
-5e4477b8e6225402380e7f0723aa53c5 *DESCRIPTION
+0e2648aa3026bf838f2b990559e4166d *DESCRIPTION
 68b2e6e1a0576545e864883209a52387 *NAMESPACE
 f7605480c8640975ae1ef30de805d88c *R/aaa-globals.R
 93425f6b0e493e121fb325aeda3e1c3f *R/augment-rprofile.R
@@ -31,15 +31,16 @@ b7824af94c203209442da312f717f51b *R/options.R
 7a4c40ceb6b8f42e2ebd7bf62e3f6e91 *R/packrat-mode.R
 bda0bcf40594cfd863a76e2b2f2b1455 *R/packrat.R
 99c8719fe51492ceee438bf9414cb6de *R/paths.R
-d04ea0c6b242f1a3a9c6df03d4fc9a1f *R/pkg.R
+8e7ed6dfeb378cd1735578e6eaa6c480 *R/pkg.R
 801164f8a688581ed9382f9117a0d844 *R/platform.R
 4ded567b978ae76cf35db714a179e0d8 *R/pretty-print.R
 569c4c36f965955d8cf887cf72ee3f02 *R/r-hooks.R
 e095eab068811896ebb349e87be70c69 *R/read-lock-file.R
 198bb6a81c968faf5a3c7bb0194f642a *R/recursive-package-dependencies.R
+7acff827ac4f0e1e0b6ffc3286813d0a *R/remote-info.R
 87a290c8cdacab5bc2376c0ffaa41e25 *R/renv.R
 b59b3e74c781a83ec42ec33222fcfe6c *R/restore-routines.R
-be77e8afed46c1e97c4a893684578fbe *R/restore.R
+ad31dae54aa6eadd3445106bb5393613 *R/restore.R
 aee2783e46d67af252a64c521e1a76f5 *R/rstudio-protocol.R
 2875f900853e4cbc72651094e3a1cf60 *R/search-path.R
 7d14b314c7484ab9841ebeacb8e63079 *R/snapshot.R
@@ -48,9 +49,9 @@ aee2783e46d67af252a64c521e1a76f5 *R/rstudio-protocol.R
 4d6b0ff3b7561d856b73da02ec4aa4c2 *R/update.R
 93cb4c972cc90d704fa9543099847199 *R/utils.R
 14e23c2ce997fd13807e30747f136f35 *R/zzz.R
-1461a5f6eac464f97cfa7e7372b5cb66 *README.md
-b95d4ad6896ae390994b636850c2718c *inst/resources/init-rprofile.R
-eeae5aa49d03655f45c655d5e4a55a89 *inst/resources/init.R
+77fa74c6b9d191d22530c95ec2d167b4 *README.md
+9ec960579691d61978bd31bea917b751 *inst/resources/init-rprofile.R
+f7ee2ac922e0fc28674f1358402f591e *inst/resources/init.R
 d561460976514e88a13dc6906d9466db *inst/resources/mac_r_userlib.sh
 926ce3615151aab7b248ef3d569210a5 *inst/resources/renv.R
 4affbb9d61d533e48a8274cdd712a9f8 *inst/rstudio/rstudio-protocol
@@ -85,6 +86,7 @@ b81d577ce3cac1b01b26748ed6d4bea6 *tests/testthat/Ugly, but legal, path for a pro
 700e054b6e32a80c8dcab5dcaa4e60d5 *tests/testthat/Ugly, but legal, path for a project (long)/oatmeal/DESCRIPTION
 6c70d47d06818418de8a62ba55e89326 *tests/testthat/Ugly, but legal, path for a project (long)/packrat/DESCRIPTION
 5b5c76f4e4849a8a7ba8ee493a125dc4 *tests/testthat/Ugly, but legal, path for a project (long)/toast/DESCRIPTION
+afaac71d0571b4dfc93b15873db80547 *tests/testthat/_snaps/pkg.md
 bbf95919533904a68997563891f47f52 *tests/testthat/lockfiles/lockfile-multipleRepos.txt
 6c70d47d06818418de8a62ba55e89326 *tests/testthat/other-packages/packrat/DESCRIPTION
 ed5a74b6ccd53686fc405ec5fe0287b3 *tests/testthat/packages/bread/DESCRIPTION
@@ -116,6 +118,10 @@ bf6fed44bb0513e754e46b10e4ab2e2e *tests/testthat/projects/partlyignored/ignoreme
 6e8dfef23f24b44f23ca91be694e02c7 *tests/testthat/resources/dependencies.qmd
 c51fc227932d77364c6bbdc8bb699cae *tests/testthat/resources/descriptions/falsy.packrat
 df273585283d871edb56757a93adbca5 *tests/testthat/resources/descriptions/falsy.remotes
+b49ba441279ee4ce29e4b3ac41e92995 *tests/testthat/resources/descriptions/github
+38467405b3bb4b474fda4f828f9c8cb0 *tests/testthat/resources/descriptions/github_subdir
+14dcd8256e3b3f84a048273730fa72ab *tests/testthat/resources/descriptions/gitlab
+9d7019b315094534e5f05b08cb2fccc5 *tests/testthat/resources/descriptions/gitlab_subdir
 268b6736c4e14677296e34d643bf0610 *tests/testthat/resources/emoji.R
 6312ea33543606514a199b4a22210424 *tests/testthat/resources/emoji.Rmd
 9f35e681fa91648d33cd15e0b081e543 *tests/testthat/resources/evaluate-deps.Rmd
@@ -145,6 +151,8 @@ f5483843abd80d00e13050f4dc134e89 *tests/testthat/test-hash.R
 b6ff0c6169e7656c345cdf7711c78980 *tests/testthat/test-options.R
 b90c9cd6e3720870a9f62eb80ee6386c *tests/testthat/test-packrat-mode.R
 b377e22c8f42ec0950256fba3da9d032 *tests/testthat/test-packrat.R
+a2bd95ba533f68cfdcf3bc3833280b18 *tests/testthat/test-pkg.R
+9468a8efcc8e843e188fb5d375527a7f *tests/testthat/test-remote-info.R
 e69ab15253ebb9a1d4d59e2f0d5cc9c7 *tests/testthat/test-restore.R
 12f74cb89ac277df5804e036599a0874 *tests/testthat/test-rmarkdown.R
 dacdbad2fff1a486e2ada169f63f184c *tests/testthat/test-shiny.R
diff --git a/R/pkg.R b/R/pkg.R
index d18276b..e305e48 100644
--- a/R/pkg.R
+++ b/R/pkg.R
@@ -344,7 +344,8 @@ inferPackageRecord <- function(df, available = availablePackages()) {
       c(remote_repo = as.character(df$RemoteRepo)),
       c(remote_username = as.character(df$RemoteUsername)),
       c(remote_ref = as.character(df$RemoteRef)),
-      c(remote_sha = as.character(df$RemoteSha))
+      c(remote_sha = as.character(df$RemoteSha)),
+      c(remote_subdir = as.character(df$RemoteSubdir))
     ), class = c('packageRecord', 'github')))
   } else if (hasRemoteType(df, "bitbucket")) {
     # It's Bitbucket!
diff --git a/R/remote-info.R b/R/remote-info.R
new file mode 100644
index 0000000..052dba8
--- /dev/null
+++ b/R/remote-info.R
@@ -0,0 +1,35 @@
+# This code is difficult to read and has caused problems in the past. Heed my
+# warning. This so that as.data.frame() is given a list. The *_subdir fields are
+# missing in most cases. If they were included in the main list() calls, list()
+# would include a field with that name with a NULL value.
+#
+# Creating a list and then concatenating the possibly-NULL subdir fields means
+# that they are NULL, they will not appear at all in the resulting list at all.
+# The resulting data frame is later appended to the DESCRIPTION file, so this is
+# desirable.
+getRemoteInfo <- function(pkgRecord) {
+  if (pkgRecord$source == "github") {
+    return(
+      as.data.frame(as.list(c(
+        RemoteType     = pkgRecord$source,
+        GithubRepo     = pkgRecord$gh_repo,
+        GithubUsername = pkgRecord$gh_username,
+        GithubRef      = pkgRecord$gh_ref,
+        GithubSHA1     = pkgRecord$gh_sha1,
+        GithubSubdir = pkgRecord$gh_subdir
+      )), stringsAsFactors = FALSE)
+    )
+  } else {
+    return(
+      as.data.frame(as.list(c(
+        RemoteType     = pkgRecord$source,
+        RemoteHost     = pkgRecord$remote_host,
+        RemoteRepo     = pkgRecord$remote_repo,
+        RemoteUsername = pkgRecord$remote_username,
+        RemoteRef      = pkgRecord$remote_ref,
+        RemoteSha      = pkgRecord$remote_sha,
+        RemoteSubdir = pkgRecord$remote_subdir
+      )), stringsAsFactors = FALSE)
+    )
+  }
+}
diff --git a/R/restore.R b/R/restore.R
index 42048ea..7a7a2b2 100644
--- a/R/restore.R
+++ b/R/restore.R
@@ -242,17 +242,7 @@ getSourceForPkgRecord <- function(pkgRecord,
       stop(e)
     })
 
-    remote_info <- as.data.frame(
-      list(
-        RemoteType     = pkgRecord$source,
-        GithubRepo     = pkgRecord$gh_repo,
-        GithubUsername = pkgRecord$gh_username,
-        GithubRef      = pkgRecord$gh_ref,
-        GithubSHA1     = pkgRecord$gh_sha1
-      ),
-      c(GithubSubdir   = pkgRecord$gh_subdir),
-      stringsAsFactors = FALSE
-    )
+    remote_info <- getRemoteInfo(pkgRecord)
 
     dest <- normalizePath(file.path(pkgSrcDir, pkgSrcFile), winslash = "/", mustWork = FALSE)
 
@@ -287,19 +277,7 @@ getSourceForPkgRecord <- function(pkgRecord,
       stop(e)
     })
 
-    # Modify remote info, move modified package to new location
-    remote_info <- as.data.frame(
-      list(
-        RemoteType = pkgRecord$source,
-        RemoteHost = pkgRecord$remote_host,
-        RemoteRepo = pkgRecord$remote_repo,
-        RemoteUsername = pkgRecord$remote_username,
-        RemoteRef = pkgRecord$remote_ref,
-        RemoteSha = pkgRecord$remote_sha
-      ),
-      c(RemoteSubdir = pkgRecord$remote_subdir),
-      stringsAsFactors = FALSE
-    )
+    remote_info <- getRemoteInfo(pkgRecord)
 
     dest <- normalizePath(file.path(pkgSrcDir, pkgSrcFile), winslash = "/", mustWork = FALSE)
 
@@ -335,19 +313,7 @@ getSourceForPkgRecord <- function(pkgRecord,
       stop(e)
     })
 
-    # Modify remote info, move modified package to new location
-    remote_info <- as.data.frame(
-      list(
-        RemoteType = pkgRecord$source,
-        RemoteHost = pkgRecord$remote_host,
-        RemoteRepo = pkgRecord$remote_repo,
-        RemoteUsername = pkgRecord$remote_username,
-        RemoteRef = pkgRecord$remote_ref,
-        RemoteSha = pkgRecord$remote_sha
-      ),
-      c(RemoteSubdir = pkgRecord$remote_subdir),
-      stringsAsFactors = FALSE
-    )
+    remote_info <- getRemoteInfo(pkgRecord)
 
     dest <- normalizePath(file.path(pkgSrcDir, pkgSrcFile), winslash = "/", mustWork = FALSE)
 
diff --git a/README.md b/README.md
index 85c6a62..32775a2 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,6 @@
 
 <!-- badges: start -->
 [![R-CMD-check](https://github.com/rstudio/packrat/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/packrat/actions)
-[![Coverage Status](https://codecov.io/github/rstudio/packrat/coverage.svg?branch=master)](https://codecov.io/github/rstudio/packrat?branch=master)
 <!-- badges: end -->
 
 ## NOTE
diff --git a/debian/changelog b/debian/changelog
index 3f253f7..ff4629c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+r-cran-packrat (0.9.1-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sat, 01 Apr 2023 07:26:00 -0000
+
 r-cran-packrat (0.9.0-2) unstable; urgency=medium
 
   * Do not attempt to download anything in autopkgtest
diff --git a/debian/patches/do-not-change-workdir.patch b/debian/patches/do-not-change-workdir.patch
index e5fad01..385129c 100644
--- a/debian/patches/do-not-change-workdir.patch
+++ b/debian/patches/do-not-change-workdir.patch
@@ -1,9 +1,11 @@
 Description: Do not change workdir for it fails in debci env
 Author: Nilesh Patra
 Last-Update: 2022-07-05
---- a/tests/testthat/test-options.R
-+++ b/tests/testthat/test-options.R
-@@ -4,9 +4,6 @@
+Index: r-cran-packrat.git/tests/testthat/test-options.R
+===================================================================
+--- r-cran-packrat.git.orig/tests/testthat/test-options.R
++++ r-cran-packrat.git/tests/testthat/test-options.R
+@@ -4,9 +4,6 @@ withTestContext({
    test_that("an option can be set and retrieved", {
      projRoot <- cloneTestProject("empty")
  
diff --git a/debian/patches/ignore_test_downloading_stuff.patch b/debian/patches/ignore_test_downloading_stuff.patch
index 1557a34..4ec67a2 100644
--- a/debian/patches/ignore_test_downloading_stuff.patch
+++ b/debian/patches/ignore_test_downloading_stuff.patch
@@ -5,8 +5,10 @@ Description: Do not attempt to download anything
    -- Error ('test-downloader.R:76'): renvDownload calls renv$download, passing in the values it received --
    Error in `secureDownloadMethod()`: Failed to discover a secure download method.
 
---- a/tests/testthat/test-downloader.R
-+++ b/tests/testthat/test-downloader.R
+Index: r-cran-packrat.git/tests/testthat/test-downloader.R
+===================================================================
+--- r-cran-packrat.git.orig/tests/testthat/test-downloader.R
++++ r-cran-packrat.git/tests/testthat/test-downloader.R
 @@ -73,6 +73,7 @@ test_that("renvDownload calls renv$downl
    renv_download_mock <- mockery::mock(destfile)
    mockery::stub(renvDownload, "renv$download", renv_download_mock)
diff --git a/inst/resources/init-rprofile.R b/inst/resources/init-rprofile.R
index 2aec0a6..bb090fc 100644
--- a/inst/resources/init-rprofile.R
+++ b/inst/resources/init-rprofile.R
@@ -1,3 +1,3 @@
-#### -- Packrat Autoloader (version 0.9.0) -- ####
+#### -- Packrat Autoloader (version 0.9.1) -- ####
 source("packrat/init.R")
 #### -- End Packrat Autoloader -- ####
diff --git a/inst/resources/init.R b/inst/resources/init.R
index 0e24d2f..b4aafbb 100644
--- a/inst/resources/init.R
+++ b/inst/resources/init.R
@@ -186,7 +186,7 @@ local({
     ## an 'installed from source' version
 
     ## -- InstallAgent -- ##
-    installAgent <- "InstallAgent: packrat 0.9.0"
+    installAgent <- "InstallAgent: packrat 0.9.1"
 
     ## -- InstallSource -- ##
     installSource <- "InstallSource: source"
diff --git a/tests/testthat/_snaps/pkg.md b/tests/testthat/_snaps/pkg.md
new file mode 100644
index 0000000..5839cce
--- /dev/null
+++ b/tests/testthat/_snaps/pkg.md
@@ -0,0 +1,161 @@
+# inferPackageRecord preserves fields: GitHub
+
+    Code
+      inferPackageRecord(df)
+    Output
+      $name
+      [1] "pkg"
+      
+      $source
+      [1] "github"
+      
+      $version
+      [1] "0.1.0"
+      
+      $gh_repo
+      [1] "plain_ol_pkg"
+      
+      $gh_username
+      [1] "my-github-username"
+      
+      $gh_ref
+      [1] "HEAD"
+      
+      $gh_sha1
+      [1] "abc123"
+      
+      $remote_host
+      [1] "api.github.com"
+      
+      $remote_repo
+      [1] "plain_ol_pkg"
+      
+      $remote_username
+      [1] "my-github-username"
+      
+      $remote_ref
+      [1] "HEAD"
+      
+      $remote_sha
+      [1] "abc123"
+      
+      attr(,"class")
+      [1] "packageRecord" "github"       
+
+# inferPackageRecord preserves fields: GitHub, pkg in subdir
+
+    Code
+      inferPackageRecord(df)
+    Output
+      $name
+      [1] "pkginsubdir"
+      
+      $source
+      [1] "github"
+      
+      $version
+      [1] "0.1.0"
+      
+      $gh_repo
+      [1] "pkg_in_subdir"
+      
+      $gh_username
+      [1] "my-github-username"
+      
+      $gh_ref
+      [1] "HEAD"
+      
+      $gh_sha1
+      [1] "abc123"
+      
+      $gh_subdir
+      [1] "pkginsubdir"
+      
+      $remote_host
+      [1] "api.github.com"
+      
+      $remote_repo
+      [1] "pkg_in_subdir"
+      
+      $remote_username
+      [1] "my-github-username"
+      
+      $remote_ref
+      [1] "HEAD"
+      
+      $remote_sha
+      [1] "abc123"
+      
+      $remote_subdir
+      [1] "pkginsubdir"
+      
+      attr(,"class")
+      [1] "packageRecord" "github"       
+
+# inferPackageRecord preserves fields: GitLab
+
+    Code
+      inferPackageRecord(df)
+    Output
+      $name
+      [1] "pkg"
+      
+      $source
+      [1] "gitlab"
+      
+      $version
+      [1] "0.1.0"
+      
+      $remote_repo
+      [1] "plain_ol_pkg"
+      
+      $remote_username
+      [1] "my-gitlab-username"
+      
+      $remote_ref
+      [1] "HEAD"
+      
+      $remote_sha
+      [1] "abc123"
+      
+      $remote_host
+      [1] "gitlab.com"
+      
+      attr(,"class")
+      [1] "packageRecord" "gitlab"       
+
+# inferPackageRecord preserves fields: GitLab, pkg in subdir
+
+    Code
+      inferPackageRecord(df)
+    Output
+      $name
+      [1] "pkginsubdir"
+      
+      $source
+      [1] "gitlab"
+      
+      $version
+      [1] "0.1.0"
+      
+      $remote_repo
+      [1] "pkg_in_subdir"
+      
+      $remote_username
+      [1] "my-gitlab-username"
+      
+      $remote_ref
+      [1] "HEAD"
+      
+      $remote_sha
+      [1] "abc123"
+      
+      $remote_host
+      [1] "gitlab.com"
+      
+      $remote_subdir
+      [1] "pkginsubdir"
+      
+      attr(,"class")
+      [1] "packageRecord" "gitlab"       
+
diff --git a/tests/testthat/resources/descriptions/github b/tests/testthat/resources/descriptions/github
new file mode 100644
index 0000000..ee1a98d
--- /dev/null
+++ b/tests/testthat/resources/descriptions/github
@@ -0,0 +1,23 @@
+Package: pkg
+Type: Package
+Title: Plain Old Package
+Version: 0.1.0
+Author: Toph Allen <toph.allen@gmail.com>
+Maintainer: Toph Allen <toph.allen@gmail.com>
+Description: This package is at the top level of its directory structure
+License: MIT
+Encoding: UTF-8
+RoxygenNote: 7.1.2
+RemoteType: github
+RemoteHost: api.github.com
+RemoteRepo: plain_ol_pkg
+RemoteUsername: my-github-username
+RemoteRef: HEAD
+RemoteSha: abc123
+GithubRepo: plain_ol_pkg
+GithubUsername: my-github-username
+GithubRef: HEAD
+GithubSHA1: abc123
+NeedsCompilation: no
+Packaged: 2023-02-22 17:15:10 UTC; root
+Built: R 4.2.1; ; 2023-02-22 17:15:10 UTC; unix
diff --git a/tests/testthat/resources/descriptions/github_subdir b/tests/testthat/resources/descriptions/github_subdir
new file mode 100644
index 0000000..33a2790
--- /dev/null
+++ b/tests/testthat/resources/descriptions/github_subdir
@@ -0,0 +1,25 @@
+Package: pkginsubdir
+Type: Package
+Title: Package In Subdirectory
+Version: 0.1.0
+Author: Toph Allen <toph.allen@gmail.com>
+Maintainer: Toph Allen <toph.allen@gmail.com>
+Description: This package lives in a subdirectory
+License: MIT
+Encoding: UTF-8
+RoxygenNote: 7.1.2
+RemoteType: github
+RemoteHost: api.github.com
+RemoteRepo: pkg_in_subdir
+RemoteUsername: my-github-username
+RemoteRef: HEAD
+RemoteSha: abc123
+RemoteSubdir: pkginsubdir
+GithubRepo: pkg_in_subdir
+GithubUsername: my-github-username
+GithubRef: HEAD
+GithubSHA1: abc123
+GithubSubdir: pkginsubdir
+NeedsCompilation: no
+Packaged: 2023-02-22 17:15:10 UTC; root
+Built: R 4.2.1; ; 2023-02-22 17:15:10 UTC; unix
diff --git a/tests/testthat/resources/descriptions/gitlab b/tests/testthat/resources/descriptions/gitlab
new file mode 100644
index 0000000..965a89c
--- /dev/null
+++ b/tests/testthat/resources/descriptions/gitlab
@@ -0,0 +1,19 @@
+Package: pkg
+Type: Package
+Title: Plain Old Package
+Version: 0.1.0
+Author: Toph Allen <toph.allen@gmail.com>
+Maintainer: Toph Allen <toph.allen@gmail.com>
+Description: This package is at the top level of its directory structure
+License: MIT
+Encoding: UTF-8
+RoxygenNote: 7.1.2
+RemoteType: gitlab
+RemoteHost: gitlab.com
+RemoteRepo: plain_ol_pkg
+RemoteUsername: my-gitlab-username
+RemoteRef: HEAD
+RemoteSha: abc123
+NeedsCompilation: no
+Packaged: 2023-02-22 17:15:10 UTC; root
+Built: R 4.2.1; ; 2023-02-22 17:15:10 UTC; unix
diff --git a/tests/testthat/resources/descriptions/gitlab_subdir b/tests/testthat/resources/descriptions/gitlab_subdir
new file mode 100644
index 0000000..5b35066
--- /dev/null
+++ b/tests/testthat/resources/descriptions/gitlab_subdir
@@ -0,0 +1,20 @@
+Package: pkginsubdir
+Type: Package
+Title: Package In Subdirectory
+Version: 0.1.0
+Author: Toph Allen <toph.allen@gmail.com>
+Maintainer: Toph Allen <toph.allen@gmail.com>
+Description: This package lives in a subdirectory
+License: MIT
+Encoding: UTF-8
+RoxygenNote: 7.1.2
+RemoteType: gitlab
+RemoteHost: gitlab.com
+RemoteRepo: pkg_in_subdir
+RemoteUsername: my-gitlab-username
+RemoteRef: HEAD
+RemoteSha: abc123
+RemoteSubdir: pkginsubdir
+NeedsCompilation: no
+Packaged: 2023-02-22 17:15:10 UTC; root
+Built: R 4.2.1; ; 2023-02-22 17:15:10 UTC; unix
diff --git a/tests/testthat/test-pkg.R b/tests/testthat/test-pkg.R
new file mode 100644
index 0000000..8aac587
--- /dev/null
+++ b/tests/testthat/test-pkg.R
@@ -0,0 +1,23 @@
+test_that("inferPackageRecord preserves fields: GitHub", {
+  # GitHub with no subdir.
+  df <- as.data.frame(readDcf(test_path("resources/descriptions/github")))
+  expect_snapshot(inferPackageRecord(df))
+})
+
+test_that("inferPackageRecord preserves fields: GitHub, pkg in subdir", {
+  # GitHub with subdir.
+  df <- as.data.frame(readDcf(test_path("resources/descriptions/github_subdir")))
+  expect_snapshot(inferPackageRecord(df))
+})
+
+test_that("inferPackageRecord preserves fields: GitLab", {
+  # GitLab with no subdir.
+  df <- as.data.frame(readDcf(test_path("resources/descriptions/gitlab")))
+  expect_snapshot(inferPackageRecord(df))
+})
+
+test_that("inferPackageRecord preserves fields: GitLab, pkg in subdir", {
+  # GitLab with subdir.
+  df <- as.data.frame(readDcf(test_path("resources/descriptions/gitlab_subdir")))
+  expect_snapshot(inferPackageRecord(df))
+})
diff --git a/tests/testthat/test-remote-info.R b/tests/testthat/test-remote-info.R
new file mode 100644
index 0000000..7fd4ba1
--- /dev/null
+++ b/tests/testthat/test-remote-info.R
@@ -0,0 +1,92 @@
+test_that("remote_info is correctly generated from a GitHub pkgRecord", {
+  pkgRecordGithub <- list(
+    name = 'adder',
+    source = 'github',
+    version = '0.9.3.1',
+    gh_repo = 'adder',
+    gh_username = 'my-username',
+    gh_ref = 'HEAD',
+    gh_sha1 = 'abc123'
+  )
+  expected <- data.frame(
+    RemoteType = "github",
+    GithubRepo = "adder",
+    GithubUsername = "my-username",
+    GithubRef = "HEAD",
+    GithubSHA1 = "abc123",
+    stringsAsFactors = FALSE
+  )
+  expect_identical(getRemoteInfo(pkgRecordGithub), expected)
+})
+
+test_that("remote_info is correctly generated from a GitHub pkgRecord with a subdirectory", {
+  pkgRecordGithubSubdir <- list(
+    name = 'subadder',
+    source = 'github',
+    version = '0.9.3.1',
+    gh_repo = 'sub_adder',
+    gh_username = 'my-username',
+    gh_ref = 'HEAD',
+    gh_sha1 = 'abc123',
+    gh_subdir = 'subadder'
+  )
+  expected <- data.frame(
+    RemoteType     = "github",
+    GithubRepo     = "sub_adder",
+    GithubUsername = "my-username",
+    GithubRef      = "HEAD",
+    GithubSHA1     = "abc123",
+    GithubSubdir   = "subadder",
+    stringsAsFactors = FALSE
+  )
+  expect_identical(getRemoteInfo(pkgRecordGithubSubdir), expected)
+})
+
+# GitLab package records will work for Bitbucket too
+test_that("remote_info is correctly generated from a GitLab pkgRecord", {
+  pkgRecordGitlab <- list(
+    name = 'adder',
+    source = 'gitlab',
+    version = '0.9.3.1',
+    remote_host = 'gitlab.com',
+    remote_repo = 'adder',
+    remote_username = 'my-username',
+    remote_ref = 'HEAD',
+    remote_sha = 'abc123'
+  )
+  expected <- data.frame(
+    RemoteType = "gitlab",
+    RemoteHost = "gitlab.com",
+    RemoteRepo = "adder",
+    RemoteUsername = "my-username",
+    RemoteRef = "HEAD",
+    RemoteSha = "abc123",
+    stringsAsFactors = FALSE
+  )
+  expect_identical(getRemoteInfo(pkgRecordGitlab), expected)
+})
+
+test_that("remote_info is correctly generated from a GitLab pkgRecord with a subdirectory", {
+  pkgRecordGitlabSubdir <- list(
+    name = 'subadder',
+    source = 'gitlab',
+    version = '0.9.3.1',
+    remote_host = 'gitlab.com',
+    remote_repo = 'sub_adder',
+    remote_username = 'my-username',
+    remote_ref = 'HEAD',
+    remote_sha = 'abc123',
+    remote_subdir = 'subadder'
+  )
+  expected <- data.frame(
+    RemoteType = "gitlab",
+    RemoteHost = "gitlab.com",
+    RemoteRepo = "sub_adder",
+    RemoteUsername = "my-username",
+    RemoteRef = "HEAD",
+    RemoteSha = "abc123",
+    RemoteSubdir = "subadder",
+    stringsAsFactors = FALSE
+  )
+  expect_identical(getRemoteInfo(pkgRecordGitlabSubdir), expected)
+})

More details

Full run details

Historical runs