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

Conversation

maleadt
Copy link
Collaborator

@maleadt maleadt commented Jan 20, 2023

Git has two kinds of tags, simple lightweight ones (pointing to a commit):

julia> GitHub.tag("JuliaGPU/Adapt.jl", "v0.1.0")
Tag (all fields are Union{Nothing, T}):
  url: URI("https://api.github.com/repos/JuliaGPU/Adapt.jl/git/refs/tags/v0.1.0")
  object: Dict{String, Any}("sha"=>"87ba4fab1f6f87b6b3662e5aa217b0db1937f2a3", "type"=>"commit", "url"=>"https://api.github.com/repos/JuliaGPU/Adapt.jl/git/commits/87ba4fab1f6f87b6b3662e5aa217b0db1937f2a3")

And annotated ones, which are represented by a lightweight tag that points at the annotated tag object:

julia> GitHub.tag("JuliaGPU/Adapt.jl", "v3.4.0")
Tag (all fields are Union{Nothing, T}):
  url: URI("https://api.github.com/repos/JuliaGPU/Adapt.jl/git/refs/tags/v3.4.0")
  object: Dict{String, Any}("sha"=>"4ce0acfdc40d91d9a6198df344a2f9c64c483be5", "type"=>"tag", "url"=>"https://api.github.com/repos/JuliaGPU/Adapt.jl/git/tags/4ce0acfdc40d91d9a6198df344a2f9c64c483be5")

This is confusing, as the SHA returned here cannot be treated as a commit SHA. Furthermore, it's impossible right now to look up the underlying annotated tag, as the request needs to go to repo/git/tags and not repo/git/refs/tags (so we can't just call GitHub.tag a second time).

Instead, I'm opting here to have the tag and tags function automatically peek through lightweight tags that point to an annotated tags, thus always returning an object which should contain a commit object (which is probably what you want anyway):

julia> GitHub.tag("JuliaGPU/Adapt.jl", "v3.4.0")
Tag (all fields are Union{Nothing, T}):
  tag: "v3.4.0"
  sha: "4ce0acfdc40d91d9a6198df344a2f9c64c483be5"
  url: URI("https://api.github.com/repos/JuliaGPU/Adapt.jl/git/tags/4ce0acfdc40d91d9a6198df344a2f9c64c483be5")
  message: "## Adapt v3.4.0\n\n[Diff since v3.3.3](https://github.com/JuliaGPU/Adapt.jl/compare/v3.3.3...v3.4.0)\n\n\n\n**Merged pull requests:**\n- Improve typestability. (#53) (@N5N3)"
  tagger: Dict{String, Any}("name"=>"github-actions[bot]", "date"=>"2022-07-28T22:07:47Z", "email"=>"41898282+github-actions[bot]@users.noreply.github.com")
  object: Dict{String, Any}("sha"=>"4c07cccd182bd36a7cbb288d64c8281dd7be665d", "type"=>"commit", "url"=>"https://api.github.com/repos/JuliaGPU/Adapt.jl/git/commits/4c07cccd182bd36a7cbb288d64c8281dd7be665d")
  verification: Dict{String, Any}("signature"=>nothing, "payload"=>nothing, "reason"=>"unsigned", "verified"=>false)

If for some reason you really need the SHA of the annotated tag, it's still there in the tag.sha object (note how that SHA is different from the tag.object["sha"]).

@maleadt maleadt merged commit 20672eb into master Jan 20, 2023
@maleadt maleadt deleted the tb/lightweight_to_annotated_tags branch January 20, 2023 13:48
Copy link

codecov bot commented Nov 17, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 57.77%. Comparing base (fcf068f) to head (7be8dae).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
src/git/tag.jl 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #212      +/-   ##
==========================================
+ Coverage   56.39%   57.77%   +1.37%     
==========================================
  Files          37       37              
  Lines         860      888      +28     
==========================================
+ Hits          485      513      +28     
  Misses        375      375              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants