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

git2r compatibility #36

Merged
merged 9 commits into from Jul 10, 2018
Merged
22 changes: 20 additions & 2 deletions tests/testthat/test-git.R
Expand Up @@ -35,7 +35,16 @@ test_that("git-related functions work", {
expect_true(git2r::is_local(git2r::branches(testRepo)$master))
expect_identical(git2r::remote_url(testRepo),
"https://github.com/PredictiveEcology/reproducible.git")
expect_identical(git2r::head(testRepo)@sha, specificCommit)

## Backwards compatibility with git2r
## S4 <= 0.21.0
## S3 >= 0.22.0
if (isS4(testRepo)) {
expect_identical(git2r::head(testRepo)@sha, specificCommit)
} else {
expect_identical(git2r::sha(git2r::repository_head(testRepo)), specificCommit)
}

rm(testRepo)
unlink(tmpDir, force = TRUE, recursive = TRUE)

Expand All @@ -48,7 +57,16 @@ test_that("git-related functions work", {
expect_true(git2r::is_local(git2r::branches(testRepo)$master))
expect_identical(git2r::remote_url(testRepo),
"https://github.com/PredictiveEcology/reproducible.git")
expect_identical(git2r::head(testRepo)@name, "master")

## Backwards compatibility with git2r
## S4 <= 0.21.0
## S3 >= 0.22.0
if (isS4(testRepo)) {
expect_identical(git2r::head(testRepo)@name, "master")
} else {
expect_identical(git2r::repository_head(testRepo)$name, "master")
}

rm(testRepo)
unlink(tmpDir, force = TRUE, recursive = TRUE)

Expand Down