-
Notifications
You must be signed in to change notification settings - Fork 894
/
Copy pathTag.cs
81 lines (70 loc) · 2.25 KB
/
Tag.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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;
var annotation = target as TagAnnotation;
return annotation == null ? target : annotation.Target;
}
}
/// <summary>
/// Gets the peeled <see cref="GitObject"/> that this tag points to.
/// </summary>
public virtual GitObject PeeledTarget
{
get
{
GitObject target = TargetObject;
var annotation = target as TagAnnotation;
while (annotation != null)
{
target = annotation.Target;
annotation = target as TagAnnotation;
}
return target;
}
}
/// <summary>
/// Indicates whether the tag holds any metadata.
/// </summary>
public virtual bool IsAnnotated
{
get { return Annotation != null; }
}
/// <summary>
/// Removes redundent leading namespaces (regarding the kind of
/// reference being wrapped) from the canonical name.
/// </summary>
/// <returns>The friendly shortened name</returns>
protected override string Shorten()
{
return CanonicalName.Substring(Reference.TagPrefix.Length);
}
}
}