using System;
using System.Globalization;
namespace LibGit2Sharp
{
///
/// Represents a local reference data from a remote repository which
/// has been retreived through a Fetch process.
///
internal class FetchHead : ReferenceWrapper
{
///
/// Needed for mocking purposes.
///
protected FetchHead()
{ }
internal FetchHead(Repository repo, string remoteCanonicalName,
string url, ObjectId targetId, bool forMerge, int index)
: base(repo, new DirectReference(
string.Format(CultureInfo.InvariantCulture, "FETCH_HEAD[{0}]", index),
repo, targetId), r => r.CanonicalName)
{
Url = url;
ForMerge = forMerge;
RemoteCanonicalName = remoteCanonicalName;
}
///
/// Returns "FETCH_HEAD[i]", where i is the index of this fetch head.
///
protected override string Shorten()
{
return CanonicalName;
}
///
/// Gets the canonical name of the reference this
/// points to in the remote repository it's been fetched from.
///
public virtual string RemoteCanonicalName { get; private set; }
///
/// Gets the that this fetch head points to.
///
public virtual GitObject Target
{
get { return TargetObject; }
}
///
/// The URL of the remote repository this
/// has been built from.
///
public virtual String Url { get; private set; }
///
/// Determines if this fetch head entry has been explicitly fetched.
///
public virtual bool ForMerge { get; private set; }
}
}