Skip to content

Add a RemoteName property to avoid lookups #1287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions LibGit2Sharp/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,26 @@ public virtual string UpstreamBranchCanonicalName
}
}

/// <summary>
/// Get the name of the remote for the branch.
/// <para>
/// If this is a local branch, this will return the configured
/// <see cref="Remote"/> to fetch from and push to. If this is a
/// remote-tracking branch, this will return the name of the remote
/// containing the tracked branch. If there no tracking information
/// this will return null.
/// </para>
/// </summary>
public virtual string RemoteName
{
get
{
return IsRemote
? RemoteNameFromRemoteTrackingBranch()
: RemoteNameFromLocalBranch();
}
}

/// <summary>
/// Get the remote for the branch.
/// <para>
Expand All @@ -162,20 +182,12 @@ public virtual string UpstreamBranchCanonicalName
/// the tracked branch.
/// </para>
/// </summary>
[Obsolete("This property is deprecated. Use Repository.Network.Remotes[] using the RemoteName property")]
public virtual Remote Remote
{
get
{
string remoteName;

if (IsRemote)
{
remoteName = RemoteNameFromRemoteTrackingBranch();
}
else
{
remoteName = RemoteNameFromLocalBranch();
}
string remoteName = RemoteName;

if (remoteName == null)
{
Expand Down