Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (60 sloc) 1.981 kB
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// A Tag
/// </summary>
public class Tag : ReferenceWrapper<GitObject>
{
/// <summary>
/// Needed for mocking purposes.
/// </summary>
protected Tag()
{ }
internal Tag(Repository repo, Reference reference, string canonicalName)
: base(repo, reference, _ => canonicalName)
{
}
/// <summary>
/// Gets the optional information associated to this tag.
/// <para>When the <see cref = "Tag" /> is a lightweight tag, <c>null</c> is returned.</para>
/// </summary>
public virtual TagAnnotation Annotation
{
get { return TargetObject as TagAnnotation; }
}
/// <summary>
/// Gets the <see cref = "GitObject" /> that this tag points to.
/// </summary>
public virtual GitObject Target
{
get
{
GitObject target = TargetObject;
if ((!(target is TagAnnotation)))
{
return target;
}
return ((TagAnnotation)target).Target;
}
}
/// <summary>
/// Indicates whether the tag holds any metadata.
/// </summary>
public virtual bool IsAnnotated
{
get { return Annotation != null; }
}
/// <summary>
/// Returns the friendly shortened name from a canonical name.
/// </summary>
/// <param name="canonicalName">The canonical name to shorten.</param>
/// <returns></returns>
protected override string Shorten(string canonicalName)
{
Ensure.ArgumentConformsTo(canonicalName, s => s.StartsWith("refs/tags/", StringComparison.Ordinal), "tagName");
return canonicalName.Substring("refs/tags/".Length);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.