Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 61 lines (52 sloc) 1.757 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Compat;
using LibGit2Sharp.Core.Handles;

namespace LibGit2Sharp
{
    /// <summary>
    /// A TagAnnotation
    /// </summary>
    public class TagAnnotation : GitObject
    {
        private Lazy<GitObject> targetBuilder;

        /// <summary>
        /// Needed for mocking purposes.
        /// </summary>
        protected TagAnnotation()
        { }

        internal TagAnnotation(ObjectId id)
            : base(id)
        {
        }

        /// <summary>
        /// Gets the name of this tag.
        /// </summary>
        public virtual string Name { get; private set; }

        /// <summary>
        /// Gets the message of this tag.
        /// </summary>
        public virtual string Message { get; private set; }

        /// <summary>
        /// Gets the <see cref = "GitObject" /> that this tag annotation points to.
        /// </summary>
        public virtual GitObject Target
        {
            get { return targetBuilder.Value; }
        }

        /// <summary>
        /// Gets the tagger.
        /// </summary>
        public virtual Signature Tagger { get; private set; }

        internal static TagAnnotation BuildFromPtr(GitObjectSafeHandle obj, ObjectId id, Repository repo)
        {
            ObjectId targetOid = Proxy.git_tag_target_oid(obj);

            return new TagAnnotation(id)
                       {
                           Message = Proxy.git_tag_message(obj),
                           Name = Proxy.git_tag_name(obj),
                           Tagger = Proxy.git_tag_tagger(obj),
                           targetBuilder = new Lazy<GitObject>(() => repo.Lookup<GitObject>(targetOid))
                       };
        }
    }
}
Something went wrong with that request. Please try again.