R Under development (unstable) (2024-10-19 r87247 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## git2r, R bindings to the libgit2 library. > ## Copyright (C) 2013-2023 The git2r contributors > ## > ## This program is free software; you can redistribute it and/or modify > ## it under the terms of the GNU General Public License, version 2, > ## as published by the Free Software Foundation. > ## > ## git2r is distributed in the hope that it will be useful, > ## but WITHOUT ANY WARRANTY; without even the implied warranty of > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > ## GNU General Public License for more details. > ## > ## You should have received a copy of the GNU General Public License along > ## with this program; if not, write to the Free Software Foundation, Inc., > ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > > library(git2r) > source("util/check.R") > > ## For debugging > sessionInfo() R Under development (unstable) (2024-10-19 r87247 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] git2r_0.35.0 loaded via a namespace (and not attached): [1] compiler_4.5.0 > libgit2_version() $major [1] 1 $minor [1] 7 $rev [1] 2 > libgit2_features() $threads [1] TRUE $https [1] TRUE $ssh [1] FALSE > > > ## Create a directory in tempdir > path <- tempfile(pattern = "git2r-") > dir.create(path) > > ## is_bare: "Invalid repository" > tools::assertError(is_bare(new("git_repository"))) > > ## is_empty: "Invalid repository" > tools::assertError(is_empty(new("git_repository"))) > > ## Check that open an invalid repository fails > tools::assertError(repository(path)) > tools::assertError(repository(path, discover = FALSE)) > > ## Check that it fails to open/init a repository with a path to a > ## file. > writeLines("test", file.path(path, "test.txt")) > tools::assertError(repository(file.path(path, "test.txt"), + discover = FALSE)) > tools::assertError(init(file.path(path, "test.txt"))) > unlink(file.path(path, "test.txt")) > > ## Initialize a repository > repo <- init(path) > stopifnot(identical(print(repo), repo)) Local: D:/temp/RtmpoZEVeR/git2r-a5881b9568a0 Head: nothing commited (yet) > > ## Check the state of the repository > stopifnot(identical(is_bare(repo), FALSE)) > stopifnot(identical(is_empty(repo), TRUE)) > stopifnot(identical(is_shallow(repo), FALSE)) > stopifnot(identical(branches(repo), empty_named_list())) > stopifnot(identical(references(repo), empty_named_list())) > stopifnot(identical(commits(repo), list())) > stopifnot(identical(repository_head(repo), NULL)) > > # check that we can find repository from a path > wd <- sub(paste0("[", .Platform$file.sep, "]$"), "", workdir(repo)) > writeLines("test file", con = file.path(wd, "myfile.txt")) > stopifnot(identical(discover_repository(file.path(wd, "myfile.txt")), + file.path(wd, ".git"))) > stopifnot(identical(discover_repository(file.path(wd, "doesntexist.txt")), + NULL)) Warning message: In normalizePath(path.expand(path), winslash, mustWork) : path[1]="D:/temp/RtmpoZEVeR/git2r-a5881b9568a0/doesntexist.txt": Das System kann die angegebene Datei nicht finden > > # Check that we can use ceiling in discover repostiory > dir.create(file.path(wd, "temp")) > stopifnot(identical(discover_repository(file.path(wd, "temp"), 0), NULL)) > stopifnot(identical(discover_repository(file.path(wd, "temp"), 1), + file.path(wd, ".git"))) > tools::assertError(discover_repository(file.path(wd, "temp"), 2)) > > ## Check that lookup with a sha of less than 4 characters or more than > ## 40 characters fail. > tools::assertError(lookup(repo, paste0(rep("a", 3), collapse = ""))) > tools::assertError(lookup(repo, paste0(rep("a", 41), collapse = ""))) > > ## Check in_repository > stopifnot(identical(in_repository(path), TRUE)) > > ## Check: > ## - in_repository method with missing path argument > ## - repository method with missing path argument > ## - workdir method with missing path argument > ## - is_empty method with missing repo argument > ## - is_shallow method with missing repo argument > wd <- setwd(path) > stopifnot(identical(in_repository(), TRUE)) > stopifnot(identical(workdir(repository(path)), workdir(repository()))) > stopifnot(identical(workdir(repository(path)), workdir())) > stopifnot(identical(is_empty(), TRUE)) > stopifnot(identical(is_shallow(), FALSE)) > if (!is.null(wd)) + setwd(wd) > > ## Cleanup > unlink(path, recursive = TRUE) > > proc.time() user system elapsed 0.25 0.23 0.43