using System;
namespace LibGit2Sharp
{
///
/// Provides helpers to a .
///
public static class ReferenceExtensions
{
internal static bool LooksLikeLocalBranch(this string canonicalName)
{
return canonicalName.IsPrefixedBy(Reference.LocalBranchPrefix);
}
internal static bool LooksLikeRemoteTrackingBranch(this string canonicalName)
{
return canonicalName.IsPrefixedBy(Reference.RemoteTrackingBranchPrefix);
}
internal static bool LooksLikeTag(this string canonicalName)
{
return canonicalName.IsPrefixedBy(Reference.TagPrefix);
}
internal static bool LooksLikeNote(this string canonicalName)
{
return canonicalName.IsPrefixedBy(Reference.NotePrefix);
}
private static bool IsPrefixedBy(this string input, string prefix)
{
return input.StartsWith(prefix, StringComparison.Ordinal);
}
///
/// Determine if the current is a local branch.
///
/// The to test.
/// true if the current is a local branch, false otherwise.
public static bool IsLocalBranch(this Reference reference)
{
return reference.CanonicalName.LooksLikeLocalBranch();
}
///
/// Determine if the current is a remote tracking branch.
///
/// The to test.
/// true if the current is a remote tracking branch, false otherwise.
public static bool IsRemoteTrackingBranch(this Reference reference)
{
return reference.CanonicalName.LooksLikeRemoteTrackingBranch();
}
///
/// Determine if the current is a tag.
///
/// The to test.
/// true if the current is a tag, false otherwise.
public static bool IsTag(this Reference reference)
{
return reference.CanonicalName.LooksLikeTag();
}
///
/// Determine if the current is a note.
///
/// The to test.
/// true if the current is a note, false otherwise.
public static bool IsNote(this Reference reference)
{
return reference.CanonicalName.LooksLikeNote();
}
}
}