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

Look through lightweight tags pointing to annotated tags. #212

Merged
merged 1 commit into from
Jan 20, 2023
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GitHub"
uuid = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26"
version = "5.8.1"
version = "5.8.2"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
16 changes: 14 additions & 2 deletions src/git/tag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ end

namefield(tag::Tag) = tag.sha

@api_default function tag(api::GitHubAPI, repo, tag_obj; options...)
result = gh_get_json(api, "/repos/$(name(repo))/git/refs/tags/$(name(tag_obj))"; options...)
@api_default function tag(api::GitHubAPI, repo, tag_ref; options...)
result = gh_get_json(api, "/repos/$(name(repo))/git/refs/tags/$(name(tag_ref))"; options...)
if result["object"]["type"] == "tag"
# lightweight tag pointing to an annotated tag
result = gh_get_json(api, "/repos/$(name(repo))/git/tags/$(result["object"]["sha"])"; options...)
end
return Tag(result)
end

@api_default function tags(api::GitHubAPI, repo; options...)
result, paged_data = gh_get_paged_json(api, "/repos/$(name(repo))/git/refs/tags"; options...)
result = map(result) do entry
if entry["object"]["type"] == "tag"
# lightweight tag pointing to an annotated tag
gh_get_json(api, "/repos/$(name(repo))/git/tags/$(entry["object"]["sha"])"; options...)
else
entry
end
end
return map(Tag, result), paged_data
end

Expand Down
11 changes: 9 additions & 2 deletions test/read_only_api_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,17 @@ end
@test ref.object["type"] == "commit"

# Tag API
reponame = "QuantEcon/Expectations.jl"
version = "v1.0.1"
reponame = "JuliaGPU/Adapt.jl"
## lightweight tag
version = "v0.1.0"
exptag = tag(reponame, version; auth=auth)
@test isa(exptag, Tag)
@test exptag.object["type"] == "commit"
## lightweight tag pointing to an annotated tag (should return the annotated tag)
version = "v3.4.0"
exptag = tag(reponame, version; auth=auth)
@test isa(exptag, Tag)
@test exptag.object["type"] == "commit"
end

@testset "URI constructions" begin
Expand Down