-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add some tests for libgit2 and a function to list all the reference names #16728
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,13 @@ mktempdir() do dir | |
@test LibGit2.iszero(commit_oid2) | ||
commit_oid2 = LibGit2.commit(repo, commit_msg2; author=test_sig, committer=test_sig) | ||
@test !LibGit2.iszero(commit_oid2) | ||
auths = LibGit2.authors(repo) | ||
@test length(auths) == 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which repo is this, is it constructed from scratch in this test harness, or is it referring to something like Example.jl that may change over time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure it's from scratch
|
||
for auth in auths | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how many should there be in this test case? |
||
@test auth.name == test_sig.name | ||
@test auth.time == test_sig.time | ||
@test auth.email == test_sig.email | ||
end | ||
|
||
# lookup commits | ||
cmt = LibGit2.get(LibGit2.GitCommit, repo, commit_oid1) | ||
|
@@ -315,13 +322,21 @@ mktempdir() do dir | |
tags = LibGit2.tag_list(repo) | ||
@test length(tags) == 1 | ||
@test tag1 in tags | ||
tag1ref = LibGit2.GitReference(repo, "refs/tags/$tag1") | ||
@test isempty(LibGit2.fullname(tag1ref)) #because this is a reference to an OID | ||
tag1tag = LibGit2.peel(LibGit2.GitTag,tag1ref) | ||
@test LibGit2.name(tag1tag) == tag1 | ||
@test LibGit2.target(tag1tag) == commit_oid1 | ||
|
||
tag_oid2 = LibGit2.tag_create(repo, tag2, commit_oid2) | ||
@test !LibGit2.iszero(tag_oid2) | ||
tags = LibGit2.tag_list(repo) | ||
@test length(tags) == 2 | ||
@test tag2 in tags | ||
|
||
refs = LibGit2.ref_list(repo) | ||
@test refs == ["refs/heads/master","refs/heads/test_branch","refs/tags/tag1","refs/tags/tag2"] | ||
|
||
LibGit2.tag_delete(repo, tag1) | ||
tags = LibGit2.tag_list(repo) | ||
@test length(tags) == 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh in this case theOid
constructor actually does check and throw for null pointers already.Just so I'm clear, the old code was returning a
Ptr{Oid}
from theccall
, wrapping that in aRef
then dereferencing theRef
- what type was that returning, aPtr{Oid}
or anOid
?edit: nevermind I was looking at the wrong
Oid
constructor, theOid(ptr::Ptr{Oid})
just doesunsafe_load(ptr)::Oid
so leave the null check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should return an
Oid
, I think. @wildart ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I never used this function, but I'm pretty sure that it should return
Oid
. My implementation was wrong.