namespace LibGit2Sharp
{
///
/// A Tag
///
public class Tag : ReferenceWrapper
{
///
/// Needed for mocking purposes.
///
protected Tag()
{ }
internal Tag(Repository repo, Reference reference, string canonicalName)
: base(repo, reference, _ => canonicalName)
{
}
///
/// Gets the optional information associated to this tag.
/// When the is a lightweight tag, null is returned.
///
public virtual TagAnnotation Annotation
{
get { return TargetObject as TagAnnotation; }
}
///
/// Gets the that this tag points to.
///
public virtual GitObject Target
{
get
{
GitObject target = TargetObject;
var annotation = target as TagAnnotation;
return annotation == null ? target : annotation.Target;
}
}
///
/// Indicates whether the tag holds any metadata.
///
public virtual bool IsAnnotated
{
get { return Annotation != null; }
}
///
/// Removes redundent leading namespaces (regarding the kind of
/// reference being wrapped) from the canonical name.
///
/// The friendly shortened name
protected override string Shorten()
{
return CanonicalName.Substring(Reference.TagPrefix.Length);
}
}
}