Skip to content
Snippets Groups Projects
Commit 4def7349 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch '24-expose-tags-git-object' into 'master'

Expose tags git object sha (if it's an annotated tag)

Closes #24

See merge request !104
parents 37c5c24c 36943fec
No related branches found
No related tags found
1 merge request!104Expose tags git object sha (if it's an annotated tag)
Pipeline #
v 10.4.1
- Expose tags git object sha (if it's an annotated tag)
v 10.4.0
- Move implementation of `local_branches` to `Gitlab::Git::Repository` from gitlab-ce
- Refactor Refs to preserve their target objects instead of just a string representation
Loading
Loading
Loading
Loading
@@ -98,14 +98,17 @@ module Gitlab
message = nil
 
if ref.target.is_a?(Rugged::Tag::Annotation)
object = ref.target
tag_message = ref.target.message
 
if tag_message.respond_to?(:chomp)
message = tag_message.chomp
end
else
object = nil # Lightweight tags aren't git objects
end
 
Tag.new(self, ref.name, ref.target, message)
Tag.new(self, object, ref.name, ref.target, message)
end.sort_by(&:name)
end
 
Loading
Loading
module Gitlab
module Git
class Tag < Ref
def initialize(repository, name, target, message = nil)
attr_reader :object_sha
def initialize(repository, object, name, target, message = nil)
super(repository, name, target)
@object_sha = if object.respond_to?(:oid)
object.oid
elsif object.respond_to?(:name)
object.name
elsif object.is_a? String
object
else
nil
end
@message = message
end
 
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ describe Gitlab::Git::Tag do
let(:tag) { repository.tags.first }
 
it { expect(tag.name).to eq("v1.0.0") }
it { expect(tag.object_sha).to eq("f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8") }
it { expect(tag.target.sha).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
it { expect(tag.message).to eq("Release") }
end
Loading
Loading
@@ -15,6 +16,7 @@ describe Gitlab::Git::Tag do
let(:tag) { repository.tags.last }
 
it { expect(tag.name).to eq("v1.2.1") }
it { expect(tag.object_sha).to eq("2ac1f24e253e08135507d0830508febaaccf02ee") }
it { expect(tag.target.sha).to eq("fa1b1e6c004a68b7d8763b86455da9e6b23e36d6") }
it { expect(tag.message).to eq("Version 1.2.1") }
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment